Faire un enchantement
-
Le “weight” est utilisé dans la probabilité de génération. Certains coffres ont des livres enchantés dedans, bah c’est ça. Donc 0, pas de livre enchanté de ce type dans les coffres
Visiblement il est aussi utilisé dans l’enclume, mais c’est un gros bordel le code, ça doit surement jouer sur le coût de réparation. -
Ah d’accord

-
Il manque juste les balises aller et ancres pour qu’on puisse directement cliquer sur le menu.
-
Je viens de modifier le tutoriel pour appliquer le modèle, il reste à attendre le passage d’un correcteur.
-
Très bon tutoriel
Merci ! -
De rien merci à toi

-
bonjour,j’aimerais faire un enchantement avec les armures mais je n’y arrive pas est ce que quelqu’un pourrait m’aiguiller ? merci

-
public boolean hasEnchantment(ItemStack stack, int id) { boolean flag = false; if (stack.getEnchantmentTagList() != null) { for (int i = 0; i < stack.getEnchantmentTagList().tagCount(); i++) { if (stack.getEnchantmentTagList().getCompoundTagAt(i).getShort("id") == id) { flag = true; }* else { flag = false; }* } } return flag; }Je me trompe peut-être mais le “else” est une erreur car s’il y a d’autres enchantements après, la fonction va retourner false, je propose 2 fixes :
public boolean hasEnchantment(ItemStack stack, int id) { boolean flag = false; if (stack.getEnchantmentTagList() != null) { for (int i = 0; i < stack.getEnchantmentTagList().tagCount(); i++) { if (stack.getEnchantmentTagList().getCompoundTagAt(i).getShort("id") == id) { flag = true; } } } return flag; }ou
public boolean hasEnchantment(ItemStack stack, int id) { if (stack.getEnchantmentTagList() != null) { for (int i = 0; i < stack.getEnchantmentTagList().tagCount(); i++) { if (stack.getEnchantmentTagList().getCompoundTagAt(i).getShort("id") == id) { return true; } } } return false; }(Cette dernière permettrait d’éviter de faire tourner une boucle pour rien)
-
Bonjours, j’ai fais comme le tuto pour creer mon enchantement poison mais l’effet ne se produit que sur les mob et pas les joueur alors que lorsque que j’ai creer un autre enchantement (de soin se coup la) il agit sur toute les entité meme les joueur, voici mon code :
package fairytail.common; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraftforge.event.entity.living.LivingHurtEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class EnchantmentHandler { @SubscribeEvent public void onHurt(LivingHurtEvent event) { if (event.source.getEntity() instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase) event.source.getEntity(); if (entity.getHeldItem() != null) { if (hasEnchantment(entity.getHeldItem(), 121)) { event.entityLiving.addPotionEffect(new PotionEffect(Potion.heal.id, 1, 1)); } } } } public boolean hasEnchantment(ItemStack stack, int id) { boolean flag = false; if (stack.getEnchantmentTagList() != null) { for (int i = 0; i < stack.getEnchantmentTagList().tagCount(); i++) { if (stack.getEnchantmentTagList().getCompoundTagAt(i).getShort("id") == id) { flag = true; } else { flag = false; } } } return flag; } @SubscribeEvent public void onHurt1(LivingHurtEvent event) { if (event.source.getEntity() instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase) event.source.getEntity(); if (entity.getHeldItem() != null) { if (hasEnchantment(entity.getHeldItem(), 120)) { int level = EnchantmentHelper.getEnchantmentLevel(120, entity.getHeldItem()); event.entityLiving.addPotionEffect(new PotionEffect(Potion.poison.id, 100 * level, 1)); } } } } public boolean hasEnchantment1(ItemStack stack, int id) { boolean flag = false; if (stack.getEnchantmentTagList() != null) { for (int i = 0; i < stack.getEnchantmentTagList().tagCount(); i++) { if (stack.getEnchantmentTagList().getCompoundTagAt(i).getShort("id") == id) { flag = true; } else { flag = false; } } } return flag; } } -
Ce message a été supprimé ! -
R robin4002 a fait référence à ce sujet sur
-
R robin4002 a fait référence à ce sujet sur
-
R robin4002 a fait référence à ce sujet sur