當前位置: 首頁>>代碼示例>>Java>>正文


Java BreakEvent.setCanceled方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.world.BlockEvent.BreakEvent.setCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java BreakEvent.setCanceled方法的具體用法?Java BreakEvent.setCanceled怎麽用?Java BreakEvent.setCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.world.BlockEvent.BreakEvent的用法示例。


在下文中一共展示了BreakEvent.setCanceled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBreakBlock

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/**
 * On break block event, we are checking whether player is breaking director
 * block and it's not empty (has replays at least one replay). Thanks to
 * Tom Soel for suggesting this.
 */
@SubscribeEvent
public void onBreakBlock(BreakEvent event)
{
    World world = event.getWorld();

    if (!world.isRemote && event.getState().getBlock() instanceof AbstractBlockDirector)
    {
        TileEntity tile = world.getTileEntity(event.getPos());

        if (tile instanceof TileEntityDirector)
        {
            TileEntityDirector director = (TileEntityDirector) tile;

            if (!director.replays.isEmpty())
            {
                event.setCanceled(true);

                Dispatcher.sendTo(new PacketConfirmBreak(event.getPos(), director.replays.size()), (EntityPlayerMP) event.getPlayer());
            }
        }
    }
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:28,代碼來源:EventHandler.java

示例2: onBlockBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreakEvent(BreakEvent event)
{
	if (event.getWorld().isRemote) { return; }

	Main.console("[TERRITORIAL DEALINGS] Block at x " + event.getPos().getX() + " / y " + event.getPos().getY() + " / z " + event.getPos().getZ() + " broken by player " + event.getPlayer().getName() + ".");

	Chunk chunk = event.getPlayer().worldObj.getChunkFromBlockCoords(event.getPos());

	if (TerritoryHandler.canPlayerEditChunk(event.getPlayer(), chunk))	// Checks out
	{
		Main.console("[TERRITORIAL DEALINGS] Player is allowed to edit this chunk. Doing nothing.");
	}
	else
	{
		Main.console("[TERRITORIAL DEALINGS] Player is not allowed to edit this chunk. Cancelling.");
		event.setCanceled(true);	// Not having it
	}
}
 
開發者ID:Domochevsky,項目名稱:minecraft-territorialdealings,代碼行數:20,代碼來源:EventListener.java

示例3: onBlockBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreakEvent(BreakEvent event)
{
	if (event.getWorld().isRemote) { return; }	// Not doing this on client side

	Main.console("Block at x" + event.getPos().getX() + " y" + event.getPos().getY() + " z" + event.getPos().getZ() + " broken by player " + event.getPlayer().getName() + 
			" (ID " + event.getPlayer().getGameProfile().getId() + ").");

	Chunk chunk = event.getPlayer().worldObj.getChunkFromBlockCoords(event.getPos());

	if (TerritoryHandler.canPlayerEditChunk(event.getPlayer().worldObj, event.getPlayer(), chunk))	// Checks out
	{
		Main.console("Player is allowed to edit this chunk. Doing nothing.");
	}
	else
	{
		Main.console("Player is not allowed to edit this chunk. Cancelling.");
		event.setCanceled(true);	// Not having it
	}
}
 
開發者ID:Domochevsky,項目名稱:minecraft-territorialdealings,代碼行數:21,代碼來源:EventListener.java

示例4: apply

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@Override
public boolean apply(final BreakEvent evt) {
	
	if(!evt.isCanceled() && (evt.block instanceof MachineVending || evt.block instanceof MachineVendingTop)) {
		
		// Do the check only if player is non-OP
		if(!evt.getPlayer().capabilities.isCreativeMode) {
			
			int baseY = evt.y;
			if(evt.block instanceof MachineVendingTop)
				baseY--;
			
			final TileEntity te = evt.world.getTileEntity(evt.x, baseY, evt.z);
			if(te instanceof VendingTileEntity) {
				final VendingTileEntity vending = (VendingTileEntity) te;
				if(!vending.okToBreak(evt.getPlayer()))
					evt.setCanceled(true);
			}
		}
	}
	
	return true;
}
 
開發者ID:OreCruncher,項目名稱:ThermalRecycling,代碼行數:24,代碼來源:VendingMachineBreakHandler.java

示例5: onBlockBreak

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreak(BreakEvent event){
	EntityPlayer player = event.getPlayer();
	if (player != null) {
 	ItemStack stack = player.getHeldItemMainhand();
 	if (stack != null) {
 		Item item = stack.getItem();
 		if (item instanceof grappleBow || item instanceof multiBow) {
 			event.setCanceled(true);
 			return;
 		}
 	}
	}
	
	this.blockbreak(event);
}
 
開發者ID:yyon,項目名稱:grapplemod,代碼行數:17,代碼來源:CommonProxyClass.java

示例6: onBlockBreak

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreak (BreakEvent event) {
    
    if (PROTECTED.contains(event.getPos()))
        event.setCanceled(true);
        
    protectBlock(event.getPos());
}
 
開發者ID:Darkhax-Minecraft,項目名稱:WorldProtect,代碼行數:9,代碼來源:BlockHandler.java

示例7: enderPearlTeleport

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void enderPearlTeleport(BreakEvent ev) {
	if(ev.getPlayer() == null || ev.getPlayer().isCreative()){
		return;
	}
	
	if (ev.getState().getBlock() == BlockTeletoryPortal.INSTANCE || ev.getState().getBlock() == BlockLinkedTeletoryPortal.INSTANCE) {
		ev.setCanceled(true);
	}
}
 
開發者ID:ToroCraft,項目名稱:TeleToro,代碼行數:11,代碼來源:Teletory.java

示例8: onBlockBreak

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreak(BreakEvent e) {
	if (!e.world.isRemote) {
		TileEntity tileentity = e.world.getTileEntity(e.pos);
		if (tileentity instanceof TileEntityStorageCore) {
			TileEntityStorageCore core = (TileEntityStorageCore)tileentity;
			if (core.inventory.getTotalCount() > 0) {
				e.setCanceled(true);
			}
		}
	}
}
 
開發者ID:zerofall,項目名稱:EZStorage,代碼行數:13,代碼來源:XEventHandler.java

示例9: onBlockBreak

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/** Make sure that only empty systems can be broken */
@SubscribeEvent
public void onBlockBreak(BreakEvent e) {
	if (!e.getWorld().isRemote) {
		TileEntity tileentity = e.getWorld().getTileEntity(e.getPos());
		if (tileentity instanceof TileEntityStorageCore) {
			TileEntityStorageCore core = (TileEntityStorageCore) tileentity;
			if (core.inventory.getTotalCount() > 0) {
				e.setCanceled(true);
			}
		}
	}
}
 
開發者ID:zerofall,項目名稱:EZStorage2,代碼行數:14,代碼來源:CoreEvents.java

示例10: onHarvest

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
private void onHarvest(BreakEvent event)
{
	
	if(!this.hasMinLvl(harvest)) return;
	
	this.calculateGain(event.getPlayer(), harvest);
	
	if(this.success == 0)
	{
		event.setCanceled(true);
	}
}
 
開發者ID:GenDeathrow,項目名稱:Skills,代碼行數:13,代碼來源:FarmingSkill.java

示例11: onBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakEvent(BreakEvent event) {
	EntityPlayer player = event.getPlayer();

	if(CoreClaim.claimManager.checkEventCancel(event.getPlayer(), event.x, event.z)) {
		Utils.messageToPlayer(player, EnumChatFormatting.RED + "Oh snap, you are not allowed to break this!");
		event.setCanceled(true);
	}	
}
 
開發者ID:unitedworldminers,項目名稱:ClaimIO,代碼行數:10,代碼來源:EventBus.java

示例12: onEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEvent(BreakEvent event) {
    Block block = event.getState().getBlock();
    int meta = block.getMetaFromState(event.getState());
    if (ProgressionAPI.registry.fireTrigger(event.getPlayer(), getProvider().getUnlocalisedName(), block, meta) == Result.DENY) {
        event.setCanceled(true);
    }
}
 
開發者ID:joshiejack,項目名稱:Progression,代碼行數:9,代碼來源:TriggerBreakBlock.java

示例13: onBreakBlock

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakBlock(BreakEvent event) {
    EntityPlayer player = event.getPlayer();
    if (player != null) {
        Block block = event.getState().getBlock();
        int meta = block.getMetaFromState(event.getState());
        if (ProgressionEvents.isEventCancelled(player, ActionType.BREAKBLOCKWITH, player.getHeldItemMainhand(), ActionType.BREAKBLOCK, BlockActionHelper.getStackFromBlockData(block, meta))) {
            event.setCanceled(true);
        }
    }
}
 
開發者ID:joshiejack,項目名稱:Progression,代碼行數:12,代碼來源:ActionBreakBlock.java

示例14: onBlockBreak

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreak(BreakEvent parEvent)
{
	if (parEvent.state.getBlock() instanceof BlockCrops)
	{
		ItemStack playerItem = parEvent.getPlayer().getCurrentEquippedItem();
		if (playerItem != null && playerItem.getItem() == _Sickle.sickle)
		{
			if (!isFullGrownCrop(parEvent.world, parEvent.pos, parEvent.state))
			{
				parEvent.setCanceled(true);
			}
		}
	}
}
 
開發者ID:andykuo1,項目名稱:mcplus_mods,代碼行數:16,代碼來源:EventHandlerSickle.java

示例15: breakBlockEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void breakBlockEvent(BreakEvent event) {
	boolean cancel = WorldHandler.breakBlockS(event);
	if (cancel)
		event.setCanceled(true);
}
 
開發者ID:tom5454,項目名稱:Toms-Mod,代碼行數:7,代碼來源:EventHandler.java


注:本文中的net.minecraftforge.event.world.BlockEvent.BreakEvent.setCanceled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。