當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。