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;
}
Aggregations