Effectivement, ça marche mieux. Merci 
Mais j’ai un nouveau problème quand j’ai essayer de faire un truc (décidemment, je les accumule)
Plus tôt, j’ai fait en sorte que quand c’est l’apocalypse et que l’entité détecté est un chien, ça le transforme en loup-garou. Tout à l’heure, j’ai décidé de modifier et de faire qu’il ne se transforme qui s’il n’est pas apprivoisé (ce qui est mieux). Mais quoique je fasse, il se transforme quand même. Voilà mon code :
| @SubscribeEvent |
| public void apocalypseMobReplace(LivingEvent event) |
| { |
| World world = event.entity.worldObj; |
| if(!world.isRemote) |
| { |
| if(ThisisHalloween.apocalypse) |
| { |
| if(event.entity instanceof EntityWolf) |
| { |
| System.out.println("wolf …"); |
| EntityWolf wolf = new EntityWolf(world); |
| if(!wolf.isTamed()) |
| { |
| System.out.println("... not tamed"); |
| EntityWerewolf werewolf = new EntityWerewolf(world); |
| double x = event.entity.posX; |
| double y = event.entity.posY; |
| double z = event.entity.posZ; |
| float rotateX = event.entity.rotationPitch; |
| float rotateY = event.entity.rotationYaw; |
| |
| event.entity.setDead(); |
| |
| werewolf.setPositionAndRotation(x, y, z, rotateX, rotateY); |
| world.spawnEntityInWorld(werewolf); |
| } |
| else |
| { |
| System.out.println("... tamed"); |
| } |
| } |
| } |
| else |
| { |
| |
| Random rand = new Random(); |
| int n = rand.nextInt(3); |
| |
| switch(n) |
| { |
| case 1 : |
| if(event.entity instanceof EntityWerewolf) |
| { |
| event.entity.setDead(); |
| break; |
| } |
| case 2 : |
| if(event.entity instanceof EntityWerewolf) |
| { |
| EntityWolf wolf = new EntityWolf(world); |
| double x = event.entity.posX; |
| double y = event.entity.posY; |
| double z = event.entity.posZ; |
| float rotateX = event.entity.rotationPitch; |
| float rotateY = event.entity.rotationYaw; |
| |
| event.entity.setDead(); |
| |
| wolf.setPositionAndRotation(x, y, z, rotateX, rotateY); |
| world.spawnEntityInWorld(wolf); |
| break; |
| } |
| } |
| } |
| } |
| } |
Voilà les logs :
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:212]: wolf …
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:216]: … not tamed
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:212]: wolf …
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:216]: … not tamed
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:212]: wolf …
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:216]: … not tamed
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:212]: wolf …
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:216]: … not tamed
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:212]: wolf …
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:216]: … not tamed
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:212]: wolf …
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:216]: … not tamed
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:212]: wolf …
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:216]: … not tamed
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:212]: wolf …
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:216]: … not tamed
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:212]: wolf …
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:216]: … not tamed
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:212]: wolf …
[18:09:32] [Server thread/INFO] [STDOUT]: [thisishalloween.CommonEventHandler:apocalypseMobReplace:216]: … not tamed
...
(J’ai coupé parce que y’a que ça)
Apparemment, ça serait la variable isTamed qui fait buguer. J’ai aussi essayer de détecté si le chien a un propriétaire (qui revient au même) mais c’est pareil, ça marche pas.