Jump to content

Geenium

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by Geenium

  1. I'm sorry, but how would I do that.
  2. I'm rather new to forge and I'm currently doing some basic tests. I have an item that has durability and I reduce the durability when the item is used to break blocks or is right clicked whilst being held. When the item breaks I am putting a different item into the player's mainhand. The problem is I can't put a new item into the player's hand when the item breaks from right clicking but works fine if the item breaks from breaking a block with it. These methods are in my new item class. @Override public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { damageTrinketInHand(stack, entityLiving); return true; } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) { ItemStack stack = player.getHeldItemMainhand(); damageTrinketInHand(stack, player); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } private void damageTrinketInHand(ItemStack stack, EntityLivingBase entityLiving) { stack.damageItem(1, entityLiving); if (entityLiving.getHeldItemMainhand().isEmpty()) { System.out.println("Trinket broken"); entityLiving.setHeldItem(EnumHand.MAIN_HAND, new ItemStack(ModItems.BROKEN_TRINKET)); } } I should point out that I can place items into another slot i.e. offhand and this will work for both ways the item can break, but currently it specifically won't work when putting a new item into the slot that the intial item was in before the item broke by right clicking with it.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.