Ajout d'un arc personnalisé
-
Salut
Donc, j’ai bien fait ce que j’ai écrit au dessus
Quand je met ça dans la ligne de création de l’item ou dans la classe de l’item :.setPotionEffect(Potion.heal)ça dit que Potion.heal est une potion et non un string
Donc je ne sais pas quoi mettre
Merci d’avance
PS : Merci pour les dégâts enlevés
-
Tu as essayé de mettre ce que j’avais trouvé plus haut avec les mêmes paramètres.
-
@‘gagoi’:
Tu as essayé de mettre ce que j’avais trouvé plus haut avec les mêmes paramètres.
Le Problème, c’est que NewPotion n’existe pas et ils disent de le créer
-
Garde le nom de ta fonction , met juste les même paramètres.
-
Salut
Désolée, je suis un boulet, mais qu’est ce que je dois mettre à la place de NewPotion dans :public NewPotion setPotionEffect(int par1, int par2, int par3, float par4) { this.potionId = par1; this.potionDuration = par2; this.potionAmplifier = par3; this.potionEffectProbability = par4; return this; }Quand je met ça dans la ligne de création de l’item :
this.setPotionEffect(Potion.heal.id, 60, 2, 1F)ça bug quand même. J’ai essayer d’enlever le", 60, 2, 1F" mais non. Ils disent quand même que faut créer la fonction dans Item.java parce que dans les parenthèses c’est une potion et pas un string.
A la place de NewPotion, j’ai essayer de mettre le nom de la classe (ItemHeartBow), Item, et après rien; mais rien ne fait.
Merci d’avance
PS : Pour les dégâts de la flèche, dans l’entité de ma flèche, j’ai mis```java
private double damage = 0.0D; -
UP
Personne ? -
Envoie tout (item + arc + entité de ta flèche) car ce que tu es en train de faire actuellement ne fonctionnera pas.
-
EntityHeartArrow :
package TiVD; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class EntityHeartArrow extends EntityArrow{ public EntityHeartArrow(World par1World, EntityLivingBase par2EntityLivingBase, float par3) { super(par1World, par2EntityLivingBase, par3); // TODO Auto-generated constructor stub } private int potionId; private int potionDuration; private int potionAmplifier; private float potionEffectProbability; private double damage = 0.0D; protected void onImpact(MovingObjectPosition var1, ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par2World.isRemote && this.potionId > 0 && par2World.rand.nextFloat() < this.potionEffectProbability) { par3EntityPlayer.addPotionEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier)); } } }ItemHeartBow :
package TiVD; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionHealth; import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraftforge.event.entity.player.ArrowNockEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ItemHeartBow extends Item { public static final String[] bowPullIconNameArray = new String[] {"pulling_0", "pulling_1", "pulling_2"}; @SideOnly(Side.CLIENT) private Icon[] iconArray; private int potionId; private int potionDuration; private int potionAmplifier; private float potionEffectProbability; public ItemHeartBow(int par1) { super(par1); this.maxStackSize = 1; // this.setPotionEffect(Potion.heal); this.setMaxDamage(384); this.setCreativeTab(CreativeTabs.tabCombat); } /** * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount * @return */ public Item setPotionEffect(int par1, int par2, int par3, float par4) { this.potionId = par1; this.potionDuration = par2; this.potionAmplifier = par3; this.potionEffectProbability = par4; return this; } public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { int j = this.getMaxItemUseDuration(par1ItemStack) - par4; ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return; } j = event.charge; boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0; if (flag || par3EntityPlayer.inventory.hasItem(TiVD.HeartArrow.itemID)) { float f = (float)j / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if ((double)f < 0.1D) { return; } if (f > 1.0F) { f = 1.0F; } EntityHeartArrow entityheartarrow = new EntityHeartArrow(par2World, par3EntityPlayer, f * 2.0F); if (f == 1.0F) { entityheartarrow.setIsCritical(true); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack); if (k > 0) { entityheartarrow.setDamage(entityheartarrow.getDamage() + (double)k * 0.5D + 0.5D); } int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack); if (l > 0) { entityheartarrow.setKnockbackStrength(l); } par1ItemStack.damageItem(1, par3EntityPlayer); par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (flag) { entityheartarrow.canBePickedUp = 2; } else { par3EntityPlayer.inventory.consumeInventoryItem(TiVD.HeartArrow.itemID); } if (!par2World.isRemote) { par2World.spawnEntityInWorld(entityheartarrow); } } } public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { return par1ItemStack; } /** * How long it takes to use or consume an item */ public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } /** * returns the action that specifies what animation to play when the items is being used */ public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(TiVD.HeartArrow.itemID)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; } /** * Return the enchantability factor of the item, most of the time is based on material. */ public int getItemEnchantability() { return 1; } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { this.itemIcon = par1IconRegister.registerIcon(this.getIconString() + "_standby"); this.iconArray = new Icon[bowPullIconNameArray.length]; for (int i = 0; i < this.iconArray.length; ++i) { this.iconArray* = par1IconRegister.registerIcon(this.getIconString() + "_" + bowPullIconNameArray*); } } @SideOnly(Side.CLIENT) /** * used to cycle through icons based on their used duration, i.e. for the bow */ public Icon getItemIconForUseDuration(int par1) { return this.iconArray[par1]; } }ItemHeartArrow :
package TiVD; import net.minecraft.item.Item; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionHelper; import net.minecraft.util.MovingObjectPosition; public class ItemHeartArrow extends Item{ private int potionId; private int potionDuration; private int potionAmplifier; private float potionEffectProbability; public ItemHeartArrow(int par1) { super(par1); } } -
J’ai pas eclipse sous la main, je suis pas sûr de ce que je vais te donner.
Dans ItemHeartArrow :private int potionId; private int potionDuration; private int potionAmplifier; private float potionEffectProbability;Inutile, supprimes.
Dans ItemHeartBow :private int potionId; private int potionDuration; private int potionAmplifier; private float potionEffectProbability;et
/** * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount * @return */ public Item setPotionEffect(int par1, int par2, int par3, float par4) { this.potionId = par1; this.potionDuration = par2; this.potionAmplifier = par3; this.potionEffectProbability = par4; return this; }Même chose, retire ça ne peut pas fonctionner. Ça fonctionne avec ItemPotion.java, car ces variables sont utilisés dans d’autres codes.
Dans ta classe EntityHeartArrow, supprime onImpact et mets :
public void onCollideWithPlayer(EntityPlayer player) { player.addPotionEffect(new PotionEffect(Potion.heal.potionId, 400, 10)); } -
Salut
Merci, mais j’ai des problèmes :
J’obtiens l’effet à chaque fois que je tire avec l’arc et non quand la flèche me touche.Merci d’avance
PS : comment enlever les dégâts de flèches svp ?
-
Remplace tout ça :
float f = (float)j / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if ((double)f < 0.1D) { return; } if (f > 1.0F) { f = 1.0F; } EntityHeartArrow entityheartarrow = new EntityHeartArrow(par2World, par3EntityPlayer, f * 2.0F);par :
EntityHeartArrow entityheartarrow = new EntityHeartArrow(par2World, par3EntityPlayer, 0F);Ça devrait enlever les dégâts.
Pour l’effet je vais devoir encore regarder vu que ça fonctionne toujours pas

-
Salut
J’ai enlevé ce que tu m’as dit, ça marche, ça n’enlève plus de vie, mais il y a quand même l’action quand on perd de la vie(jueur qui devient rouge et son)Est-ce normal ?
Peut-on l’enlever ?Merci d’avance
PS : Aucune idée pour l’effet ? -
Personne ?
-
Je vais faire des essais de mon côté dès que j’aurai réinstaller mes programmes.
-
Ok, merci
-
Comme promis :
http://pastebin.com/Mx395M22
http://pastebin.com/EMrMSzuu
http://pastebin.com/EABa71dADans la classe principale, tu fais comme les items normaux pour l’arc, et dans la méthode init tu mets :
EntityRegistry.registerModEntity(EntityTestArrow.class, "arrowTest", 200, this.instance, 10, 10, true);Et dans ton client proxy :
RenderingRegistry.registerEntityRenderingHandler(EntityTestArrow.class, new RenderTestArrow()); -
Salut
Désolée du temps de réponse
Merci, mais voici mes flèche :

Et mes flèches qui reste en l’air :

-
Les flèches qui restent en l’air j’ai pas trouvé comment régler le soucis.
Par contre la rendu, c’est pas normal, ça fonctionnait lors de mes tests. Tu as sur que la méthode de l’enregistrement du rendu est bien appelé dans la classe principale ? -
Oui, c’est bien appeler pourtant
Dans le clientProxy, :@Override public void registerRenderThings() { RenderingRegistry.registerEntityRenderingHandler(EntityHeartArrow.class, new RenderHeartArrow()); }Et dans la classe principale :
EntityRegistry.registerModEntity(EntityHeartArrow.class, "HeartArrow", 200, this.instance, 10, 10, true);Mais je l’ai mis dans la méthode load(Init). C’est peut être pour ça
-
La méthode registerRenderThings est appelé dans la classe principale ? (proxy.registerRenderThings() dans la fonction init).