Launcheur a popo
-
Bonjour/Bonsoir je voudrais savoir si il y’a moyen de jeter une popo en particulier avec un arc car quand on lance une popo sa nous mets une popo d’eau et non de healing ou de harming ect
Merci d’avance voila ma classe:package testcode; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import fr.Addon.Sangloz.Arthania.init.ItemMod; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityPotion; import net.minecraft.entity.projectile.EntitySnowball; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemBow; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionHealth; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraftforge.event.entity.player.ArrowNockEvent; public class PotionLauncher extends ItemBow { public static final String[] bowPullIconNameArray = new String[] {"pulling_0", "pulling_1", "pulling_2"}; @SideOnly(Side.CLIENT) private IIcon[] iconArray; private Object par3EntityPlayer; private static final String __OBFID = "CL_00001777"; public PotionLauncher() { this.maxStackSize = 1; this.setMaxDamage(384); this.setCreativeTab(CreativeTabs.tabCombat); } /** * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount */ public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) { int j = this.getMaxItemUseDuration(p_77615_1_) - p_77615_4_; ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return; } j = event.charge; boolean flag = p_77615_3_.capabilities.isCreativeMode; if (flag || p_77615_3_.inventory.hasItem(Items.potionitem)) { 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; } EntityPotion entityarrow = new EntityPotion(p_77615_2_, p_77615_3_, p_77615_1_); if (f == 1.0F) { } if (flag) { } else { p_77615_3_.inventory.consumeInventoryItem(Items.potionitem); } if (!p_77615_2_.isRemote) { p_77615_2_.spawnEntityInWorld(entityarrow); } } } public ItemStack onEaten(ItemStack p_77654_1_, World p_77654_2_, EntityPlayer p_77654_3_) { return p_77654_1_; } /** * How long it takes to use or consume an item */ public int getMaxItemUseDuration(ItemStack p_77626_1_) { return 72000; } /** * returns the action that specifies what animation to play when the items is being used */ public EnumAction getItemUseAction(ItemStack p_77661_1_) { return EnumAction.bow; } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (p_77659_3_.capabilities.isCreativeMode || p_77659_3_.inventory.hasItem(Items.potionitem)) { p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_)); } return p_77659_1_; } /** * 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(IIconRegister p_94581_1_) { this.itemIcon = p_94581_1_.registerIcon(this.getIconString() + "_standby"); this.iconArray = new IIcon[bowPullIconNameArray.length]; for (int i = 0; i < this.iconArray.length; ++i) { this.iconArray* = p_94581_1_.registerIcon(this.getIconString() + "_" + bowPullIconNameArray*); } } /** * used to cycle through icons based on their used duration, i.e. for the bow */ @SideOnly(Side.CLIENT) public IIcon getItemIconForUseDuration(int p_94599_1_) { return this.iconArray[p_94599_1_]; } }
-
Je dirais qu’il faut que tu remplace
“EntityPotion entityarrow = new EntityPotion(p_77615_2_, p_77615_3_, p_77615_1_);”
par
" EntityPotion entityarrow = new EntityPotion(p_77615_2_, p_77615_3_, new ItemStack(Items.potionitem, 1, metadata_de_la_potion_que_tu_veux));" -
Est dans future pense a utilis les se de code "```java
Comme te la dit LeBossMax2 fait en sorte l'entité que tu fait spawn soit une potion :)
-
Merci d’arrêter de signaler à la modération des messages pour une raison inutile, @Snowy_1803.
-
Raison du rapport : Balise Java manquante
raison inutile ?!?
Le règlement de la section demande la présente de la balise java pour le code java, le rapport est donc bien justifié.
-
@‘LeBossMax2’:
Je dirais qu’il faut que tu remplace
“EntityPotion entityarrow = new EntityPotion(p_77615_2_, p_77615_3_, p_77615_1_);”
par
" EntityPotion entityarrow = new EntityPotion(p_77615_2_, p_77615_3_, new ItemStack(Items.potionitem, 1, metadata_de_la_potion_que_tu_veux));"Merci j’essaye ça et on verra en tout cas merci d’avoir répondu si vite.