Search in sources :

Example 6 with ICamouflageHandler

use of forestry.api.core.ICamouflageHandler in project ForestryMC by ForestryMC.

the class ItemCamouflageSprayCan method onItemUseFirst.

@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
    if (player.isSneaking()) {
        return EnumActionResult.PASS;
    }
    ItemStack heldItem = player.getHeldItem(hand);
    ItemInventoryCamouflageSprayCan inventory = new ItemInventoryCamouflageSprayCan(player, heldItem);
    ItemStack camouflage = inventory.getStackInSlot(0);
    ICamouflageHandler handler = TileUtil.getTile(world, pos, ICamouflageHandler.class);
    if (handler != null && !camouflage.isEmpty()) {
        if (world.isRemote) {
            handler.setCamouflageBlock(camouflage, true);
        }
        return EnumActionResult.SUCCESS;
    }
    return EnumActionResult.PASS;
}
Also used : ICamouflageHandler(forestry.api.core.ICamouflageHandler) ItemStack(net.minecraft.item.ItemStack) ItemInventoryCamouflageSprayCan(forestry.greenhouse.inventory.ItemInventoryCamouflageSprayCan)

Aggregations

ICamouflageHandler (forestry.api.core.ICamouflageHandler)6 ICamouflagedTile (forestry.api.core.ICamouflagedTile)4 IMultiblockComponent (forestry.api.multiblock.IMultiblockComponent)4 IMultiblockController (forestry.api.multiblock.IMultiblockController)4 ItemStack (net.minecraft.item.ItemStack)4 TileEntity (net.minecraft.tileentity.TileEntity)4 ItemInventoryCamouflageSprayCan (forestry.greenhouse.inventory.ItemInventoryCamouflageSprayCan)1 Nullable (javax.annotation.Nullable)1