Ok je vais faire ça
Mais c’est tout de même bizarre que ça marche nikel pour le premier item mais pas pour les autres.
Mon code ne semblait pas faux pourtant o_O
Voici ma version avec plus de logs
:::
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
NBTTagCompound compound = new NBTTagCompound();
if(player.capabilities.isCreativeMode)
{
if(world.isRemote)
{
player.addChatComponentMessage(new ChatComponentTranslation("item.gun.inGodMode"));
}
//Code pour tirer illimité
}
else
{
if(!stack.hasTagCompound() || !stack.getTagCompound().getBoolean("isReloading"))
{
System.out.println("tag null ? " + stack.hasTagCompound() == null);
compound.setBoolean("isReloading", false);
stack.setTagCompound(compound);
if(player.inventory.hasItem(itemUsedToShoot))
{
if(player.inventory.consumeInventoryItem(itemUsedToShoot))
{
compound.setByte("munitionsUsedCount", munitionsUsedCount);
compound.setShort("fireRate", fireRate);
stack.setTagCompound(compound);
if(stack.getTagCompound().getByte("munitionsUsedCount") == reloadingCounter)
{
//rechargemnt
System.out.println("rechargement");
compound.setBoolean("isReloading", true);
}
else
{
stack.getTagCompound().setByte("munitionsUsedCount", munitionsUsedCount++);
stack.setTagCompound(compound);
System.out.println("Avant dernier else " + stack.getTagCompound().getByte("munitionsUsedCount"));
if(world.isRemote)
{
for (int i = 0; i < 4; ++i)
{
world.spawnParticle("explode", player.posX + (world.rand.nextDouble() - 0.5D) * (double)player.width, player.posY + world.rand.nextDouble() * (double)player.height - 0.25D, player.posZ + (world.rand.nextDouble() - 0.5D) * (double)player.width, (world.rand.nextDouble() - 0.5D) * 2.0D, -world.rand.nextDouble(), (world.rand.nextDouble() - 0.5D) * 2.0D);
}
}
else
{
EntitySheep sheeptest = new EntitySheep(world);
sheeptest.setLocationAndAngles(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
world.spawnEntityInWorld(sheeptest);
stack.damageItem(1, player);
world.playSoundAtEntity(player, "random.explode", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
}
}
}
}
}
else if(stack.getTagCompound().getBoolean("isReloading"))
{
compound.setBoolean("isReloading", true);
stack.setTagCompound(compound);
}
}
System.out.println(stack.getTagCompound().getBoolean("isReloading"));
return stack;
}
:::
Par-contre ça ne m’a pas du tout + aidé. Je ne comprends rien du tout c’est à croire que mon ItemStack ne retient pas la variable compound. Pourtant je la set bien , à plusieurs reprises même. Tu as sûrement déjà des items avec des NBTTagCompound en +.
Y’en aurait-il sur le github de MFF ?