public boolean placeItem( EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) { // CraftBukkit start - handle all block place event logic here int data = this.getData(); int count = this.count; if (!(this.getItem() instanceof ItemBucket)) { // if not bucket world.captureBlockStates = true; // special case bonemeal if (this.getItem() instanceof ItemDye && this.getData() == 15) { Block block = world.getType(blockposition).getBlock(); if (block == Blocks.SAPLING || block instanceof BlockMushroom) { world.captureTreeGeneration = true; } } } boolean flag = this.getItem() .interactWith(this, entityhuman, world, blockposition, enumdirection, f, f1, f2); int newData = this.getData(); int newCount = this.count; this.count = count; this.setData(data); world.captureBlockStates = false; if (flag && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { world.captureTreeGeneration = false; Location location = new Location( world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); TreeType treeType = BlockSapling.treeType; BlockSapling.treeType = null; List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone(); world.capturedBlockStates.clear(); StructureGrowEvent event = null; if (treeType != null) { event = new StructureGrowEvent( location, treeType, false, (Player) entityhuman.getBukkitEntity(), blocks); org.bukkit.Bukkit.getPluginManager().callEvent(event); } if (event == null || !event.isCancelled()) { // Change the stack to its new contents if it hasn't been tampered with. if (this.count == count && this.getData() == data) { this.setData(newData); this.count = newCount; } for (BlockState blockstate : blocks) { blockstate.update(true); } } return flag; } world.captureTreeGeneration = false; if (flag) { org.bukkit.event.block.BlockPlaceEvent placeEvent = null; List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone(); world.capturedBlockStates.clear(); if (blocks.size() > 1) { placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent( world, entityhuman, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ()); } else if (blocks.size() == 1) { placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent( world, entityhuman, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ()); } if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { flag = false; // cancel placement // revert back all captured blocks for (BlockState blockstate : blocks) { blockstate.update(true, false); } } else { // Change the stack to its new contents if it hasn't been tampered with. if (this.count == count && this.getData() == data) { this.setData(newData); this.count = newCount; } for (BlockState blockstate : blocks) { int x = blockstate.getX(); int y = blockstate.getY(); int z = blockstate.getZ(); int updateFlag = ((CraftBlockState) blockstate).getFlag(); org.bukkit.Material mat = blockstate.getType(); Block oldBlock = CraftMagicNumbers.getBlock(mat); BlockPosition newblockposition = new BlockPosition(x, y, z); IBlockData block = world.getType(newblockposition); if (!(block instanceof BlockContainer)) { // Containers get placed automatically block.getBlock().onPlace(world, newblockposition, block); } world.notifyAndUpdatePhysics( newblockposition, null, oldBlock, block.getBlock(), updateFlag); // send null chunk as chunk.k() returns false by this point } entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this.item)]); } } world.capturedBlockStates.clear(); // CraftBukkit end return flag; }