My onItemRightClick event keeps going through twice, and even with diagnostics I can't find out why. Any help is appreciate, thank you! {note that many of the contents of this code are simply placeholders}
....................................................................
public class BakugoQuirk extends ItemBase
{
public BakugoQuirk(String name)
{
super(name);
this.setMaxDamage(500);
this.isDamageable();
}
public void onUpdate(ItemStack item, World worldIn, Entity playerIn)
{
if (item.getItemDamage() != 0)
{
item.setItemDamage(499); //Item damage gain per tick
}
}
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
ItemStack item = playerIn.getHeldItem(handIn);
Vec3d aim = playerIn.getLookVec();
System.out.println("testing for first condition, ItemDamage is " + item.getItemDamage());
if(item.getItemDamage() == 0)
{
playerIn.sendMessage(new TextComponentString("100% charge attack"));
EntityLargeFireball fireball = new EntityLargeFireball(worldIn, playerIn, 1,1,1);
fireball.setPosition(playerIn.posX + aim.x * 1.5D, playerIn.posY + aim.y * 1.5D , playerIn.posZ + aim.z * 1.5D);
fireball.accelerationX = aim.x * 0.1;
fireball.accelerationY = aim.y * 0.1;
fireball.accelerationZ = aim.z * 0.1;
worldIn.spawnEntity(fireball);
item.setItemDamage(499);
System.out.println("ItemDamage is " + item.getItemDamage() + " after test");
}
else if(item.getItemDamage() > 0)
{
System.out.println("Going into second condition with " + item.getItemDamage() + " Item Damage");
EntityLargeFireball fireball = new EntityLargeFireball(worldIn, playerIn, 1,1,1);
fireball.setPosition(playerIn.posX + aim.x * 1.5D, playerIn.posY + aim.y * 1.5D , playerIn.posZ + aim.z * 1.5D);
fireball.accelerationX = aim.x * 0.1;
fireball.accelerationY = aim.y * 0.1;
fireball.accelerationZ = aim.z * 0.1;
worldIn.spawnEntity(fireball);
playerIn.sendMessage(new TextComponentString("50%-100% charge attack"));
item.setItemDamage(item.getMaxDamage() - 1);
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, item);
}
EDIT {SOLVED}:
Just ended up adding a broad
"if (worldIn.isRemote == false )"
over much of the code including the entity spawn and the chat message