Robotic Parts

Robotic Parts

2M Downloads

Experience Capsule cannot be used

mallrat208 opened this issue ยท 1 comments

commented

public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
if (!playerIn.capabilities.isCreativeMode)
{
stack.shrink(1);
}
int xp = 0;
if (stack.hasTagCompound())
{
NBTTagCompound c = stack.getTagCompound();
if (c.hasKey("xp"))
{
xp = c.getInteger("xp");
}
}
playerIn.addExperience(xp);
return new ActionResult(EnumActionResult.SUCCESS, stack);
}

This looks to be a similar issue to what Neuropozyne had. Replacing the onItemRightClick with the following should get it working again. Of note the shrinking of the held itemstack was moved to later in the process to ensure it didn't try to get the NBTTag of an empty itemstack.

	@Override
	public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
	{
		ItemStack stack = playerIn.getHeldItem(handIn);
		
		int xp = 0;
		if (stack.hasTagCompound())
		{
			NBTTagCompound c = stack.getTagCompound();
			if (c.hasKey("xp"))
			{
				xp = c.getInteger("xp");
			}
		}
		
		if (!playerIn.capabilities.isCreativeMode)
		{
			stack.shrink(1);
		}		
		
		playerIn.addExperience(xp);
		
		return new ActionResult(EnumActionResult.SUCCESS, stack);
	}
commented

good catch, i've merged this