1.8 11.14.3.1450 : fonctionne, le problème vient de toi. As-tu bien enregistré l’événement avec MinecraftForge et non FMLComonHandler ?
Je te renvois le code utilisé :
| @SubscribeEvent |
| public void onLivingDeath(LivingDeathEvent event) { |
| if (event.entityLiving instanceof EntityPlayer) { |
| EntityPlayer player = (EntityPlayer) event.entityLiving; |
| |
| for (int i = 0; i < player.inventory.getSizeInventory(); i++) { |
| if (player.inventory.getStackInSlot(i) != null && player.inventory.getStackInSlot(i).getItem() == Items.apple) { |
| BlockPos pos = player.getPosition(); |
| player.getEntityData().setBoolean("ring", true); |
| player.getEntityData().setInteger("posX", pos.getX()); |
| player.getEntityData().setInteger("posY", pos.getY()); |
| player.getEntityData().setInteger("posZ", pos.getZ()); |
| } |
| } |
| } |
| } |
| |
| @SubscribeEvent |
| public void onEntitySpawn(PlayerEvent.Clone event) { |
| if (event.wasDeath) { |
| EntityPlayer player = event.original; |
| if (player.getEntityData().getBoolean("ring")) { |
| event.entityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.getId(), 800, 0, true, false)); |
| event.entityPlayer.setPosition(player.getEntityData().getInteger("posX"), player.getEntityData().getInteger("posY"), player.getEntityData().getInteger("posZ")); |
| } |
| } |
| } |