Java Code Examples for net.minecraft.block.Block#getBlockFromItem()

The following examples show how to use net.minecraft.block.Block#getBlockFromItem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockKitunebi.java    From Sakura_mod with MIT License 6 votes vote down vote up
private void setVisibleFlg(World world, BlockPos pos,IBlockState state) {
    world.setBlockState(pos, state.withProperty(ISVISIBLE, false));
	EntityPlayer player = world.getClosestPlayer(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, 5.0D, false);
	if(player ==null){
		world.setBlockState(pos, state.withProperty(ISVISIBLE, false));
		return;
	}
    ItemStack is = player.getHeldItemMainhand();
    ItemStack offis =player.getHeldItemOffhand();
    if (!is.isEmpty()||!offis.isEmpty()) {
    	Item mainItem = is.getItem(),offItem=offis.getItem();
        if (mainItem instanceof ItemBlock||offItem instanceof ItemBlock) {
            if (Block.getBlockFromItem(mainItem) == this||Block.getBlockFromItem(offItem) == this) {
                world.setBlockState(pos, state.withProperty(ISVISIBLE, true));
            }
        }
    }
}
 
Example 2
Source File: ModelPneumaticDoorBase.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderDynamic(float size, TileEntity tile, float partialTicks){
    if(tile instanceof TileEntityPneumaticDoorBase) {
        TileEntityPneumaticDoorBase door = (TileEntityPneumaticDoorBase)tile;
        ItemStack camoStack = door.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
        boolean renderBase = true;
        if(camoStack != null && camoStack.getItem() instanceof ItemBlock) {
            Block block = Block.getBlockFromItem(camoStack.getItem());
            renderBase = !PneumaticCraftUtils.isRenderIDCamo(block.getRenderType());
        }
        PneumaticCraftUtils.rotateMatrixByMetadata(door.orientation.ordinal());
        renderModel(size, door.oldProgress + (door.progress - door.oldProgress) * partialTicks, renderBase, ((TileEntityPneumaticDoorBase)tile).rightGoing);
    } else {
        renderModel(size, 1, true, false);
    }
}
 
Example 3
Source File: TileEntityTrap.java    From Artifacts with MIT License 6 votes vote down vote up
/**
 * Add item stack in first available inventory slot
 */
@Override
//addItem
public int func_146019_a(ItemStack par1ItemStack)
{
    for (int i = 0; i < this.dispenserContents.length; ++i)
    {
        if (this.dispenserContents[i] == null || Block.getBlockFromItem(this.dispenserContents[i].getItem()) == Blocks.air)
        {
            this.setInventorySlotContents(i, par1ItemStack);
            return i;
        }
    }

    return -1;
}
 
Example 4
Source File: MapGenGeode.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
public MapGenGeode(int chancePerChunk) {
	this.chancePerChunk = chancePerChunk;

	if(ores == null) {
		ores = new LinkedList<BlockMeta>();
		for(int i = 0; i < Configuration.standardGeodeOres.size(); i++) {
			String oreDictName = Configuration.standardGeodeOres.get(i);
			List<ItemStack> ores2 = OreDictionary.getOres(oreDictName);

			if(ores2 != null && !ores2.isEmpty()) {
				Block block = Block.getBlockFromItem(ores2.get(0).getItem());
				if(block != null)
					ores.add(new BlockMeta(block, ores2.get(0).getItemDamage()));
			}
		}
	}
}
 
Example 5
Source File: GameBlockStore.java    From XRay-Mod with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method is used to fill the store as we do not intend to update this after
 * it has been populated, it's a singleton by nature but we still need some
 * amount of control over when it is populated.
 */
public void populate()
{
    // Avoid doing the logic again unless repopulate is called
    if( this.store.size() != 0 )
        return;

    for ( Item item : ForgeRegistries.ITEMS ) {
        if( !(item instanceof net.minecraft.item.BlockItem) )
            continue;

        Block block = Block.getBlockFromItem(item);
        if ( item == Items.AIR || block == Blocks.AIR || Controller.blackList.contains(block) )
            continue; // avoids troubles

        store.add(new BlockWithItemStack(block, new ItemStack(item)));
    }
}
 
Example 6
Source File: ItemCarvable.java    From Chisel with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips)
{
    if(!Configurations.blockDescriptions) return;

    Item item = General.getItem(stack);
    if(item == null) return;

    Block block = Block.getBlockFromItem(this);
    if(!(block instanceof ICarvable)) return;

    ICarvable carvable = (ICarvable) block;
    CarvableVariation var = carvable.getVariation(stack.getItemDamage());
    if(var == null)
        return;

    lines.add(var.description);
}
 
Example 7
Source File: PartPressureTube.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void update(){
    //Log.info("sides connected " + world().isRemote + ": " + Arrays.toString(sidesConnected));
    if(Config.convertMultipartsToBlocks && !world().isRemote) {
        Log.info("Converting Pressure Tube part to Pressure Tube block at " + x() + ", " + y() + ", " + z());
        Block pressureTube = Block.getBlockFromItem(getItem().getItem());
        world().setBlock(x(), y(), z(), pressureTube);
        TileEntityPressureTube t = (TileEntityPressureTube)world().getTileEntity(x(), y(), z());
        NBTTagCompound tag = new NBTTagCompound();
        tube.writeToNBTI(tag);
        t.readFromNBT(tag);
        world().notifyBlocksOfNeighborChange(x(), y(), z(), pressureTube);
        return;
    }
    tube.updateEntityI();
}
 
Example 8
Source File: BlockGardenContainer.java    From GardenCollection with MIT License 6 votes vote down vote up
protected boolean isValidSubstrate (World world, int x, int y, int z, int slot, ItemStack itemStack) {
    if (itemStack == null || itemStack.getItem() == null)
        return false;

    Block block = Block.getBlockFromItem(itemStack.getItem());
    if (block == null)
        return false;

    return block == Blocks.dirt
        || block == Blocks.sand
        || block == Blocks.gravel
        || block == Blocks.soul_sand
        || block == Blocks.grass
        || block == Blocks.water
        || block == Blocks.farmland
        || block == Blocks.mycelium
        || block == ModBlocks.gardenSoil
        || block == ModBlocks.gardenFarmland;
}
 
Example 9
Source File: InventoryChiselSelection.java    From Chisel with GNU General Public License v2.0 5 votes vote down vote up
public void updateItems()
{
    ItemStack chiseledItem = inventory[normalSlots];

    clearItems();

    if(chiseledItem == null)
    {
        container.onChiselSlotChanged();
        return;
    }

    Item item = chiseledItem.getItem();
    if(item == null) return;

    if(Block.getBlockFromItem(item) == null)
        return;

    ArrayList<ItemStack> list = container.carving.getItems(chiseledItem);

    activeVariations = 0;
    while(activeVariations < normalSlots && activeVariations < list.size())
    {
        inventory[activeVariations] = list.get(activeVariations);
        activeVariations++;
    }

    container.onChiselSlotChanged();
}
 
Example 10
Source File: ItemMarbleSlab.java    From Chisel with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack)
{
    BlockMarbleSlab block = (BlockMarbleSlab) Block.getBlockFromItem(this);

    switch(side)
    {
        case 0:
            --y;
            break;
        case 1:
            ++y;
            break;
        case 2:
            --z;
            break;
        case 3:
            ++z;
            break;
        case 4:
            --x;
            break;
        case 5:
            ++x;
            break;
    }

    Block targetBlock = world.getBlock(x, y, z);
    int meta = world.getBlockMetadata(x, y, z);

    return (targetBlock.equals(block) || targetBlock.equals(block.top)) && meta == stack.getItemDamage() || world.canPlaceEntityOnSide(block, x, y, z, false, side, (Entity) null, stack);

}
 
Example 11
Source File: FurnaceRecipeHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private static void findFuels() {
    afuels = new ArrayList<FuelPair>();
    Set<Item> efuels = excludedFuels();
    for (ItemStack item : ItemList.items) {
        Block block = Block.getBlockFromItem(item.getItem());
        if (block instanceof BlockDoor)
            continue;
        if (efuels.contains(item.getItem()))
            continue;

        int burnTime = TileEntityFurnace.getItemBurnTime(item);
        if (burnTime > 0)
            afuels.add(new FuelPair(item.copy(), burnTime));
    }
}
 
Example 12
Source File: WoodFenceRecipe.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public ItemStack getCraftingResult (InventoryCrafting inventory) {
    int size = getGridSize(inventory);
    for (int row = 0; row < size - 1; row++) {
        for (int col = 0; col < size - 2; col++) {
            ItemStack string1 = inventory.getStackInRowAndColumn(col, row);
            ItemStack string2 = inventory.getStackInRowAndColumn(col + 2, row);
            if (string1 == null || string2 == null || string1.getItem() != Items.string || !string1.isItemEqual(string2))
                continue;

            ItemStack wood1 = inventory.getStackInRowAndColumn(col + 1, row);
            ItemStack wood2 = inventory.getStackInRowAndColumn(col + 1, row + 1);
            if (wood1 == null || wood2 == null || !wood1.isItemEqual(wood2))
                continue;
            if (Block.getBlockFromItem(wood1.getItem()) != ModBlocks.thinLog)
                continue;

            Block woodBlock = TileEntityWoodProxy.getBlockFromComposedMetadata(wood1.getItemDamage());
            int woodMeta = TileEntityWoodProxy.getMetaFromComposedMetadata(wood1.getItemDamage());

            if (!WoodRegistry.instance().contains(woodBlock, woodMeta))
                continue;

            if (woodBlock == woodType.getBlock() && woodMeta == woodType.meta)
                return new ItemStack(ModBlocks.thinLogFence, 3, TileEntityWoodProxy.composeMetadata(woodBlock, woodMeta));
        }
    }

    return null;
}
 
Example 13
Source File: InventoryChiselSelection.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
public void updateItems() {
	ItemStack chiseledItem = inventory[normalSlots];
	clearItems();

	if (chiseledItem == null) {
		container.onChiselSlotChanged();
		return;
	}

	Item item = chiseledItem.getItem();
	if (item == null)
		return;

	if (Block.getBlockFromItem(item) == null)
		return;

	if (!((IChiselItem) chisel.getItem()).canChisel(container.playerInventory.player.worldObj, chisel, General.getVariation(chiseledItem)))
		return;

	List<ItemStack> list = container.carving.getItemsForChiseling(chiseledItem);

	activeVariations = 0;
	while (activeVariations < normalSlots && activeVariations < list.size()) {
		if(Block.blockRegistry.getNameForObject(Block.getBlockFromItem(list.get(activeVariations).getItem())) != null) {
			inventory[activeVariations] = list.get(activeVariations);
			activeVariations++;
		}
	}

	container.onChiselSlotChanged();
}
 
Example 14
Source File: TunnellerHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private boolean equipSolidBlock(BlockPos pos)
{
	for(int slot = 0; slot < 9; slot++)
	{
		// filter out non-block items
		ItemStack stack = MC.player.inventory.getStack(slot);
		if(stack.isEmpty() || !(stack.getItem() instanceof BlockItem))
			continue;
		
		Block block = Block.getBlockFromItem(stack.getItem());
		
		// filter out non-solid blocks
		BlockState state = block.getDefaultState();
		if(!state.isFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN))
			continue;
		
		// filter out blocks that would fall
		if(block instanceof FallingBlock && FallingBlock
			.canFallThrough(BlockUtils.getState(pos.down())))
			continue;
		
		MC.player.inventory.selectedSlot = slot;
		return true;
	}
	
	return false;
}
 
Example 15
Source File: PLModelRegistry.java    From Production-Line with MIT License 4 votes vote down vote up
private static ModelResourceLocation getItemModelResLoc(Item item, int meta) {
        Block block = Block.getBlockFromItem(item);
        if (block instanceof IBlockModelProvider) {
            return ((IBlockModelProvider) block).getModelResourceLocation(meta);
        }

        String name = item.getRegistryName().getResourcePath();
        String path = "";
        String variant = "inventory";

        if (item instanceof IItemModelProvider) {
            path = ((IItemModelProvider) item).getModelResourcePath() + "/";

            String custom = ((IItemModelProvider) item).getModelResourceName(meta);
            if (custom != null) {
                name = custom;
            }
        }


//        Block block = Block.getBlockFromItem(item);
//        if (block instanceof IMultiIDBlock) {
//            PropertyEnum propertyEnum = ((IMultiIDBlock) block).getBlockTypeContainer();
//            Object object = propertyEnum.getAllowedValues().toArray()[meta];
//
//            if (object instanceof IBlockType) {
//                StringBuilder builder = new StringBuilder();
//                builder.append(propertyEnum.getName());
//                builder.append("=");
//                builder.append(((IBlockType) object).getTypeName());

                //// TODO: 2017/3/5 better variant registry
//                if (block instanceof BlockMachine) {
//                    builder.append(",active=false");
//                }
//                variant = builder.toString();
//            }

//        }

        ResourceLocation ret = new ResourceLocation(RESOURCE_DOMAIN, path + name);
        ModelResourceLocation t = new ModelResourceLocation(ret, variant);
        return new ModelResourceLocation(ret, variant);
    }
 
Example 16
Source File: ReplacementBlock.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public ReplacementBlock(Item block, NBTTagCompound tag)
{
	this(Block.getBlockFromItem(block), tag);
}
 
Example 17
Source File: TileEntityEnderFurnace.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't fuel
 * @param stack
 * @return
 */
private static int getItemBurnTime(ItemStack stack)
{
    if (stack.isEmpty())
    {
        return 0;
    }

    int burnTime = ForgeEventFactory.getItemBurnTime(stack) * COOKTIME_DEFAULT * 3 / 400;

    if (burnTime >= 0)
    {
        return burnTime;
    }

    Item item = stack.getItem();

    if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR)
    {
        Block block = Block.getBlockFromItem(item);
        if (block.getDefaultState().getMaterial() == Material.WOOD) { return COOKTIME_DEFAULT * 225 / 100; }
        if (block == Blocks.COAL_BLOCK) { return COOKTIME_DEFAULT * 120; }
        if (block == Blocks.WOODEN_SLAB) { return COOKTIME_DEFAULT * 45 / 40; }
        if (block == Blocks.SAPLING) return COOKTIME_DEFAULT * 3 / 4;
    }
    else
    {
        if (item == Items.COAL) return COOKTIME_DEFAULT * 12;
        if (item == Items.BLAZE_ROD) return COOKTIME_DEFAULT * 18;

        if (item == Items.LAVA_BUCKET) return COOKTIME_DEFAULT * 150;
        if (item == Items.STICK) return COOKTIME_DEFAULT * 3 / 4;
        if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;
        if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;
        if (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;

        // Ender Furnace custom fuels
        if (item == Items.BLAZE_POWDER) return COOKTIME_DEFAULT * 9;
        if (item == Items.ENDER_PEARL) { return COOKTIME_DEFAULT * 8; }
        if (item == Items.ENDER_EYE) { return COOKTIME_DEFAULT * 17; }
    }

    return 0;
}
 
Example 18
Source File: BlockParty.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	Item item = mc.player.inventory.getMainHandStack().getItem();
	Block block = Block.getBlockFromItem(item);
	if (block == Blocks.AIR) return;
	
	if (mc.world.getBlockState(mc.player.getBlockPos().add(0, -1, 0)).getBlock() == block
			|| mc.world.getBlockState(mc.player.getBlockPos().add(0, -2, 0)).getBlock() == block) {
		mc.player.setVelocity(0, mc.player.getVelocity().y, 0);
		KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), false);
		return;
	}
	
	List<BlockPos> poses = new ArrayList<>();
	for (int x = -50; x < 50; x++) {
		for (int y = -2; y < 1; y++) {
			for (int z = -50; z < 50; z++) {
				if (mc.world.getBlockState(mc.player.getBlockPos().add(x, y, z)).getBlock() == block
						&& mc.world.getBlockState(mc.player.getBlockPos().add(x, y+1, z)).getBlock() == Blocks.AIR) poses.add(mc.player.getBlockPos().add(x, y, z));
			}
		}
	}
	
	if (poses.isEmpty()) return;
	
	poses.sort((a,b) -> Double.compare(a.getSquaredDistance(mc.player.getBlockPos()), b.getSquaredDistance(mc.player.getBlockPos())));
	
	double diffX = poses.get(0).getX() + 0.5 - mc.player.x;
	double diffZ = poses.get(0).getZ() + 0.5 - mc.player.z;
		
	float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
		
	mc.player.yaw += MathHelper.wrapDegrees(yaw - mc.player.yaw);
	
	KeyBinding.setKeyPressed(mc.options.keyForward.getDefaultKeyCode(), true);
	
	if (mc.player.getBlockPos().getSquaredDistance(poses.get(0)) < (mc.player.isSprinting() ? 25 : 8)
			&& Math.abs(mc.player.getVelocity().x) + Math.abs(mc.player.getVelocity().z) > 0.15
			&& mc.player.verticalCollision) {
		mc.player.jump();
		mc.player.verticalCollision = false;
		//mc.player.setPosition(mc.player.x, mc.player.y + 0.02, mc.player.z);
	}
	
	if (getSettings().get(1).toToggle().state && mc.player.fallDistance < 0.25) {
		if (jumping && mc.player.y >= mc.player.prevY + 0.399994D) {
			mc.player.setVelocity(mc.player.getVelocity().x, -0.9, mc.player.getVelocity().z);
			mc.player.y = mc.player.prevY;
			jumping = false;
		}
		
		if (mc.player.forwardSpeed != 0.0F && !mc.player.horizontalCollision) {
			if (mc.player.verticalCollision) {
				mc.player.setVelocity(mc.player.getVelocity().x * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300),
						mc.player.getVelocity().y,
						mc.player.getVelocity().z * Math.min(1.3, 0.85 + mc.player.getBlockPos().getSquaredDistance(poses.get(0)) / 300));
				jumping = true;
				mc.player.jump();
			}
			
			if (jumping && mc.player.y >= mc.player.prevY + 0.399994D) {
				mc.player.setVelocity(mc.player.getVelocity().x, -100, mc.player.getVelocity().z);
				jumping = false;
			}
		}
	}
}
 
Example 19
Source File: ItemMarbleSlab.java    From Chisel with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hx, float hy, float hz)
{
    BlockMarbleSlab block = (BlockMarbleSlab) Block.getBlockFromItem(this);

    Block targetBlock = world.getBlock(x, y, z);
    int meta = world.getBlockMetadata(x, y, z);
    boolean metaMatches = meta == stack.getItemDamage();

    if(metaMatches && side == 0 && targetBlock.equals(block.top))
    {
        world.setBlock(x, y, z, block.master, meta, 2);
        stack.stackSize -= 1;
        return true;
    } else if(metaMatches && side == 1 && targetBlock.equals(block.bottom))
    {
        world.setBlock(x, y, z, block.master, meta, 2);
        stack.stackSize -= 1;
        return true;
    }

    boolean result = super.onItemUse(stack, player, world, x, y, z, side, hz, hy, hz);


    switch(side)
    {
        case 0:
            --y;
            break;
        case 1:
            ++y;
            break;
        case 2:
            --z;
            break;
        case 3:
            ++z;
            break;
        case 4:
            --x;
            break;
        case 5:
            ++x;
            break;
    }

    targetBlock = world.getBlock(x, y, z);
    meta = world.getBlockMetadata(x, y, z);

    if(!result && (targetBlock.equals(block.top) || targetBlock.equals(block.bottom)) && meta == stack.getItemDamage())
    {
        world.setBlock(x, y, z, block.master, meta, 2);
        return true;
    }

    if(!result)
        return false;

    if(side != 0 && (side == 1 || hy <= 0.5D))
        return true;


    //TODO allow top slabs
    //world.setBlock(x, y, z, block.top, meta, 2);
    return true;
}
 
Example 20
Source File: FMPPlacementListener.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static boolean place(EntityPlayer player, World world){
    MovingObjectPosition hit = RayTracer.reTrace(world, player);
    if(hit == null) return false;

    BlockCoord pos = new BlockCoord(hit.blockX, hit.blockY, hit.blockZ);
    ItemStack held = player.getHeldItem();
    PartPressureTube part = null;
    if(held == null) return false;

    Block heldBlock = Block.getBlockFromItem(held.getItem());
    if(heldBlock == Blockss.pressureTube) {
        part = new PartPressureTube();
    } else if(heldBlock == Blockss.advancedPressureTube) {
        part = new PartAdvancedPressureTube();
    }

    if(part == null) return false;

    if(world.isRemote && !player.isSneaking())//attempt to use block activated like normal and tell the server the right stuff
    {
        Vector3 f = new Vector3(hit.hitVec).add(-hit.blockX, -hit.blockY, -hit.blockZ);
        Block block = world.getBlock(hit.blockX, hit.blockY, hit.blockZ);
        if(!ignoreActivate(block) && block.onBlockActivated(world, hit.blockX, hit.blockY, hit.blockZ, player, hit.sideHit, (float)f.x, (float)f.y, (float)f.z)) {
            player.swingItem();
            PacketCustom.sendToServer(new C08PacketPlayerBlockPlacement(hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, player.inventory.getCurrentItem(), (float)f.x, (float)f.y, (float)f.z));
            return true;
        }
    }

    TileMultipart tile = TileMultipart.getOrConvertTile(world, pos);
    if(tile == null || !tile.canAddPart(part)) {
        pos = pos.offset(hit.sideHit);
        tile = TileMultipart.getOrConvertTile(world, pos);
        if(tile == null || !tile.canAddPart(part)) return false;
    }

    if(!world.isRemote) {
        TileMultipart.addPart(world, pos, part);
        world.playSoundEffect(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, Blockss.pressureTube.stepSound.func_150496_b(), (Blockss.pressureTube.stepSound.getVolume() + 1.0F) / 2.0F, Blockss.pressureTube.stepSound.getPitch() * 0.8F);
        if(!player.capabilities.isCreativeMode) {
            held.stackSize--;
            if(held.stackSize == 0) {
                player.inventory.mainInventory[player.inventory.currentItem] = null;
                MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held));
            }
        }
    } else {
        player.swingItem();
        NetworkHandler.sendToServer(new PacketFMPPlacePart());
    }
    return true;
}