Généré un mob quand le joueur frappe le mob
-
Voila merci
mais comment faire spawn le mob???private void attackEntityFrom(LivingHurtEvent e,EntityPlayer player,KingRobber entity) { if (e.entityLiving.attackEntityAsMob(entity)) { System.out.println("mob test"); } } -
e.entity.worldObj.spawnEntityInWorld(new NomDelentity(x, y, z));
(il faut bien sûr remplacer NomDelentity, x, y, et z). -
J’ai fait sa sa marche pas
@SubscribeEvent public void onHurtMob(LivingHurtEvent e, int x, int y, int z) { if(e.entity instanceof KingRobber) { e.setCanceled(true); e.entity.worldObj.spawnEntityInWorld(new EntitySkeleton(x, y, z); } } -
http://www.minecraftforgefrance.fr/showthread.php?tid=716 Encore une fois…
La fonction ne peut pas être appelée car il faut obligatoirement un seul paramètre.
-
Alors comment faire???
-
@SubscribeEvent public void onHurtMob(LivingHurtEvent e) { if(e.entity instanceof KingRobber) { e.setCanceled(true); e.entity.worldObj.spawnEntityInWorld(new EntitySkeleton(e.entity.posX - 5 + e.entity.worldObj.rand.nextInt(10), e.entity.posY - 5 + e.entity.worldObj.rand.nextInt(10), e.entity.posZ - 5 + e.entity.worldObj.rand.nextInt(10))); } }Pas compliqué non ? Suffit juste d’utiliser les coordonnées de ton entité + faire un petit random entre 0 et 10 et retirer 5.
Comme ça tes skeleton spawnerons sur les 5 blocs autours de ton king. -
Je crois qu’en 1.7, tu es obligé de localiser ton entity avant le spawn avec cette methode : entity.setPosition ou encore entity.setLocationAndAngles
De + il faut faire attention à ne faire spawn ton entity que côté serveur sinon tu auras un bug de rendu. -
Ah oui en effet en 1.8 le EntitySkeleton n’a plus de constructeur x, y, z.
-
Je ne comprend pas ^^
-
@SubscribeEvent public void onHurtMob(LivingHurtEvent e) { if(e.entity instanceof KingRobber) { e.setCanceled(true); EntitySkeleton skeleton = new EntitySkeleton(e.entity.worldObj); skeleton.setPosition(e.entity.posX - 5 + e.entity.worldObj.rand.nextInt(10), e.entity.posY - 5 + e.entity.worldObj.rand.nextInt(10), e.entity.posZ - 5 + e.entity.worldObj.rand.nextInt(10)); e.entity.worldObj.spawnEntityInWorld(skeleton); } } -
sa marche

-
sa marche mais le problème c’est que l’entity ne prend pas de dégâts lié à sa
-
Hein ? Sois + précis, stp
Quel entity ne prend pas de dégât ? KingRobber ou EntitySkeleton ? -
Normal, tu cancel levent
-
L’entité king robber
-
Retires la ligne e.setCanceled(true);
-
Sa marche merci

-
Balise résolu ?
-
Oui Résolu x)
-
AymericRed te demande de mettre la balise résolu.
Tu dois retourner sur le premier message de ton post, cliquer sur éditer puis l’ajouter avant le titre.