Search in sources :

Example 1 with ItemInventoryCamouflageSprayCan

use of forestry.greenhouse.inventory.ItemInventoryCamouflageSprayCan 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)1 ItemInventoryCamouflageSprayCan (forestry.greenhouse.inventory.ItemInventoryCamouflageSprayCan)1 ItemStack (net.minecraft.item.ItemStack)1