19 juil. 2016, 12:18

Bonjour,
J’ai encore un soucis avec ma fonction onUpdate.

Voici ma fonction:


public void onUpdate(ItemStack item, World world, Entity player, int slotIndex, boolean inHand) {
if(!item.hasTagCompound() && !world.isRemote) {
      item.setTagCompound(new NBTTagCompound());
}
if(world.isRemote){
int timer = !item.getTagCompound().hasKey("timer") ? 0 : item.getTagCompound().getInteger("timer");
timer++;
item.getTagCompound().setInteger("timer", timer);

int timer2 = !item.getTagCompound().hasKey("timer2") ? 0 : item.getTagCompound().getInteger("timer2");
timer2++;
item.getTagCompound().setInteger("timer2", timer2);

int timer3 = !item.getTagCompound().hasKey("timer3") ? 0 : item.getTagCompound().getInteger("timer3");
timer3++;
item.getTagCompound().setInteger("timer3", timer3);

super.onUpdate(item, world, player, slotIndex, inHand);
}
}

Cette fonction est utilisé dans une classe extends ItemBow .
Le soucis est que je désire faire un timer pour différents sorts mais le problème est que le timer marche pas vraiment 😕 , je procède comme ceci:

if(… && stack.getTagCompound().getInteger("timer") >= 20 * 20)
{
//Code
stack.getTagCompound().setInteger("timer", 0);
}

A mon avis c’est world.isremote dans la fonction onUpdate car la flèche est lancée côté serveur et donc cela fait un conflit mais quand je met !world.isremote je rencontre le soucis de la dernière fois:  https://youtu.be/wThsb3Fi4jU

Merci d’avance.