当前位置: 首页>>代码示例>>Java>>正文


Java BreakEvent类代码示例

本文整理汇总了Java中net.minecraftforge.event.world.BlockEvent.BreakEvent的典型用法代码示例。如果您正苦于以下问题:Java BreakEvent类的具体用法?Java BreakEvent怎么用?Java BreakEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BreakEvent类属于net.minecraftforge.event.world.BlockEvent包,在下文中一共展示了BreakEvent类的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: onBlockBreak

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BreakEvent event)
{
	Random rand = event.world.rand;
	
	//Drop nuts from leaves
	if(event.block == TFCBlocks.leaves && rand.nextInt(100) < 10)
	{
		Item nut = null;
		
		switch(event.blockMetadata)
		{
			case 0: nut = CWTFCItems.acorn; break;
			case 3: nut = CWTFCItems.chestnut; break;
			case 5: nut = CWTFCItems.pecan; break;
			case 8: nut = CWTFCItems.pineNut; break;
		}
		
		if(nut != null)
		{
			ItemStack is = ItemFoodTFC.createTag(new ItemStack(nut), CropIndex.getWeight(4, rand));
			event.world.spawnEntityInWorld(new EntityItem(event.world, event.x + 0.5, event.y + 0.5, event.z + 0.5, is));
		}
	}
}
 
开发者ID:StrayWolfe,项目名称:Cooking-with-TFC,代码行数:26,代码来源:PlayerHandler.java

示例3: 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

示例4: 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

示例5: blockDestroy

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
/**
 * ブロックを破壊します
 *
 * @param world       world
 * @param x           x座標
 * @param y           y座標
 * @param z           z座標
 * @param player      プレイヤー
 * @param centerBlock 中心のブロック
 * @param cX          中心のブロックのx座標
 * @param cY          中心のブロックのy座標
 * @param cZ          中心のブロックのz座標
 * @param toolStack   破壊に使用したツールのItemStack
 */
private void blockDestroy(World world, int x, int y, int z, EntityPlayerMP player, Block centerBlock, int cX, int cY, int cZ, ItemStack toolStack) {
	if (!world.isAirBlock(x, y, z)) {
		Block block = world.getBlock(x, y, z);
		int meta = world.getBlockMetadata(x, y, z);
		if (canDestroyBlock(toolStack, block, meta) && (centerBlock.getBlockHardness(world, cX, cY, cZ) - block.getBlockHardness(world, x, y, z)) <= 3F) {
			BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
			if (!event.isCanceled()) {
				block.onBlockHarvested(world, x, y, z, meta, player);
				if (block.removedByPlayer(world, player, x, y, z, false)) {
					block.onBlockDestroyedByPlayer(world, x, y, z, meta);
					block.harvestBlock(world, player, x, y, z, meta);
				}
				if (!world.isRemote) {
					player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
				}
				
			}
		}
	}
}
 
开发者ID:Team-Antimatter-Mod,项目名称:AntiMatterMod,代码行数:35,代码来源:MiningHammer.java

示例6: onBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBreakEvent(BreakEvent event){

	World world = event.getWorld();
	BlockPos pos = event.getPos();
	IBlockState state = event.getState();
	TileEntity ent = world.getTileEntity(pos);

	// TODO; check tool/pickaxe? if notHarvestable or whatever, drop the
	// buckets and the ..glass?

	if(ent != null && ent instanceof TileEntityBucketStorage){
		TileEntityBucketStorage t = (TileEntityBucketStorage) ent;
		ItemStack stack = new ItemStack(state.getBlock());

		setItemStackNBT(stack, BlockBucketStorage.NBTBUCKETS, t.getBuckets());

		dropItemStackInWorld(world, pos, stack);

		t.setBuckets(0);
	}
}
 
开发者ID:LothrazarMinecraftMods,项目名称:BucketBlocks,代码行数:23,代码来源:ModBucketBlocks.java

示例7: 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

示例8: onBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onBreakEvent(BreakEvent event) {
  World world = event.getWorld();
  EntityPlayer player = event.getPlayer();
  if (player == null) {
    return;
  }
  BlockPos pos = event.getPos();
  int level = this.getCurrentLevelTool(player);
  if (level <= 0) {
    return;
  }
  Block block = event.getState().getBlock();
  int xpDropped = block.getExpDrop(event.getState(), world, pos, 0);
  int bonus = xpDropped * XP_PER_LVL * level;
  UtilExperience.incrementExp(player, bonus);
  //    dropExp(world, pos, xpDropped * XP_PER_LVL * level);
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:19,代码来源:EnchantXpBoost.java

示例9: onBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
/**
 * tile entity data saved to item stack
 * 
 * @param event
 */
@SubscribeEvent
public static void onBreakEvent(BreakEvent event) {
  if (event.getPlayer() != null && event.getPlayer().capabilities.isCreativeMode) {
    return;
  } // dont drop in creative https://github.com/PrinceOfAmber/Cyclic/issues/93
  World world = event.getWorld();
  BlockPos pos = event.getPos();
  IBlockState state = event.getState();
  TileEntity ent = world.getTileEntity(pos);
  if (ent != null && ent instanceof TileEntityWirelessTr) {
    TileEntityWirelessTr t = (TileEntityWirelessTr) ent;
    ItemStack stack = new ItemStack(state.getBlock());
    if (t.getTargetPos() != null)
      UtilNBT.setItemStackBlockPos(stack, t.getTargetPos());
    //      saveTileDataToStack(stack, t);
    UtilItemStack.dropItemStackInWorld(world, pos, stack);
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:24,代码来源:BlockRedstoneWireless.java

示例10: onBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBreakEvent(BreakEvent event) {
  if (event.getPlayer() != null && event.getPlayer().capabilities.isCreativeMode) {
    return;
  } // dont drop in creative https://github.com/PrinceOfAmber/Cyclic/issues/93
  World world = event.getWorld();
  BlockPos pos = event.getPos();
  IBlockState state = event.getState();
  TileEntity ent = world.getTileEntity(pos);
  if (ent != null && ent instanceof TileEntityVector) {
    TileEntityVector t = (TileEntityVector) ent;
    ItemStack stack = new ItemStack(state.getBlock());
    saveTileDataToStack(stack, t);
    UtilItemStack.dropItemStackInWorld(world, pos, stack);
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:17,代码来源:BlockVectorPlate.java

示例11: 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

示例12: mineOutEverything

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
public void mineOutEverything(int[][] locations, BreakEvent event)
{
    EntityPlayer player = event.getPlayer();
    ItemStack current = player.getCurrentEquippedItem();

    for (int i = 0; i < locations.length; i++)
    {
        int curX = event.x + locations[i][0];
        int curY = event.y + locations[i][1];
        int curZ = event.z + locations[i][2];

        Block miningBlock = event.world.getBlock(curX, curY, curZ);
        int meta = event.world.getBlockMetadata(curX, curY, curZ);
        if (canHarvestBlock(player, event.block, miningBlock, meta, curX, curY, curZ))
        {
            if (!((ItemTool) current.getItem()).onBlockStartBreak(current, curX, curY, curZ, player))
            {
                mineBlock(event.world, curX, curY, curZ, meta, player, miningBlock);
                ((ItemTool) current.getItem()).onBlockDestroyed(current, event.world, miningBlock, curX, curY, curZ, player);
                player.addExhaustion((float) 0.025);
            }
        }
    }
}
 
开发者ID:Wolfofthenyght,项目名称:M4Armory,代码行数:25,代码来源:AOEHandler.java

示例13: mineGrass

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
public void mineGrass(int[][] blocks, BreakEvent event)
{
    EntityPlayer player = event.getPlayer();
    ItemStack current = player.getCurrentEquippedItem();

    for (int i = 0; i < blocks.length; i++)
    {
        Block currentBlock = event.world.getBlock(event.x + blocks[i][0], event.y + blocks[i][1], event.z + blocks[i][2]);
        int currentMeta = event.world.getBlockMetadata(event.x + blocks[i][0], event.y + blocks[i][1], event.z + blocks[i][2]);
        if (canHoeHarvest(currentBlock))
        {
            mineBlock(event.world, event.x + blocks[i][0], event.y + blocks[i][1], event.z + blocks[i][2], currentMeta, player, currentBlock);
            current.damageItem(1, player);
            if (current.getItemDamage() >= current.getMaxDamage())
            {
                return;
            }
        }
    }
}
 
开发者ID:Wolfofthenyght,项目名称:M4Armory,代码行数:21,代码来源:AOEHandler.java

示例14: onBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBreakEvent(BreakEvent event) {
	Side side = FMLCommonHandler.instance().getEffectiveSide();

	if (side != Side.SERVER) return;
	
	if (event.getPlayer() instanceof EntityPlayerMP) {
		EntityPlayerMP thePlayer = (EntityPlayerMP) event.getPlayer();
		List<MocapAction> aList = Mocap.instance
				.getActionListForPlayer(thePlayer);
		if (aList != null) {
			MocapAction ma = new MocapAction(
					MocapActionTypes.BREAKBLOCK);
			
			ma.xCoord = event.x;
			ma.yCoord = event.y;
			ma.zCoord = event.z;
			aList.add(ma);
		}
	}
	
}
 
开发者ID:EchebKeso,项目名称:Mocap,代码行数:23,代码来源:MocapEventHandler.java

示例15: onBlockBreak

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BreakEvent event) {
    // check if the block broken was a leaf block
    if (event.block.getMaterial() == Material.leaves) {
        // get a random number instance
        Random random = new Random();
        // calculate the percentage and continue if fortunate. Note that random.nextInt will return an int from 0-99
        if ((random.nextInt(100)) < leafBrushwoodChance) {
            // get the height of surface from where the leaf was destroyed
            int y = event.world.getTopSolidOrLiquidBlock(event.x, event.z);
            // get the surface block of where the leaf was destroyed as 'spawnCandidate' 
            Block spawnCandidate = event.world.getBlock(event.x, y, event.z);
            // ensure that spawnCandidate is (a) an air block and (b) below the leaf block that was destroyed
            if (spawnCandidate.isAir(event.world, event.x, y, event.z) && y < event.y) {
                // spawnCandidate is valid, place Brushwood block!
                event.world.setBlock(event.x, y, event.z, ModBlocks.brushwood);
            }
        }
    }
}
 
开发者ID:CosmicDan-Minecraft,项目名称:Imperium,代码行数:21,代码来源:BlockEvents.java


注:本文中的net.minecraftforge.event.world.BlockEvent.BreakEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。