当前位置: 首页>>代码示例>>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;未经允许,请勿转载。