Alors j’ai essayé ça :
| public class EmotionLifeEvent |
| { |
| @SubscribeEvent |
| public void whenHurt(LivingAttackEvent e) |
| { |
| if(e.entity instanceof EntityPlayer) |
| { |
| EntityPlayer player = (EntityPlayer)e.entity; |
| BlockPos pos = player.getPosition(); |
| |
| |
| for(int i = 0; i < player.inventory.getSizeInventory(); i++) |
| { |
| if(player.inventory.getStackInSlot(i) != null && player.inventory.getStackInSlot(i).getItem() == EmotionItems.purpuraRing) |
| { |
| 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 whenSpawn(Clone e) |
| { |
| EntityPlayer player = e.entityPlayer; |
| |
| if(e.wasDeath == true) |
| { |
| if(player.getEntityData().getBoolean("ring") == true) |
| { |
| for(int i = 0; i <= 5; ++i) |
| { |
| if(i == 5) |
| { |
| |
| player.addPotionEffect(new PotionEffect(Potion.fireResistance.getId(), 800, 0, true, false)); |
| player.setPosition(player.getEntityData().getInteger("posX"), player.getEntityData().getInteger("posY"), player.getEntityData().getInteger("posZ")); |
| player.getEntityData().setBoolean("ring", false); |
| } |
| } |
| } |
| } |
| } |
| } |
Mais maintenant ça ne marche plus du tout aurais-je fais une erreur ? (A la base je ne pensais pas qu’on pouvais utiliser entity data sur un joueur alors j’ai pue faire une bêtise :S) Sinon pour les events de respawn j’ai essayé “LivingSpawnEvent” mais aucune idée si ça fonctionne puisque qu’à cause du code que j’ai rajouté ça ne fonctionne plus du tout ^^’
Ps: Pour le lit j’avais essayé :
player.setSpawnPoint(position, true);
Et d’augmenter le timer mais ça n’a pas fonctionné, le lit prend le devant 