MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Créé une arme sans set d'outil !

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    20 Messages 3 Publieurs 2.7k Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • EryahE Hors-ligne
      Eryah
      dernière édition par

      Ah désolé je n’ai pas vu que tu demandais pour le code.
      Veux-tu que je te montre un de mes code ?
      J’ai une maniere très spéciale de coder 🙂
      Mon code est 100% Imcompatible avec ceux des autres :))

      Exemple, voici le code de mon Arc avec Lames en Fer ( Celui qui m’a servi de model pour les codes que je t’ai donné )

      package eryah.usefulthings.init;
      
      import com.google.common.collect.Multimap;
      
      import net.minecraft.block.Block;
      import net.minecraft.client.Minecraft;
      import net.minecraft.client.resources.model.ModelResourceLocation;
      import net.minecraft.enchantment.Enchantment;
      import net.minecraft.enchantment.EnchantmentHelper;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.entity.SharedMonsterAttributes;
      import net.minecraft.entity.ai.attributes.AttributeModifier;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.projectile.EntityArrow;
      import net.minecraft.init.Blocks;
      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.stats.StatList;
      import net.minecraft.util.DamageSource;
      import net.minecraft.world.World;
      import net.minecraftforge.fml.common.registry.GameRegistry;
      import eryah.usefulthings.Reference;
      import eryah.usefulthings.UsefulthingsMod;
      
      public class BladedBowIron extends ItemBow
      {
      public static final String[] bowPullIconNameArray = new String[] {"pulling_0", "pulling_1", "pulling_2"};
      public static Item iron_bladed_bow;
      private float attackDamage;
      
      public BladedBowIron()
      {
      this.maxStackSize = 1;
      this.setMaxDamage(634);
      this.attackDamage = 6.0F;
      }
      
      public static void init(){
      iron_bladed_bow = new BladedBowIron().setUnlocalizedName("iron_bladed_bow").setCreativeTab(UsefulthingsMod.UTTab);
      }
      
      public static void register()
      {
      GameRegistry.registerItem(iron_bladed_bow, iron_bladed_bow.getUnlocalizedName().substring(5));
      }
      
      public static void registerRenders()
      {
      registerRender(iron_bladed_bow);
      }
      
      public static void registerRender(Item item)
      {
      Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
      }
      
      public float getDamageVsEntity(float f)
      {
      return getDamageVsEntity(6.0F);
      }
      
      /**
      * Called when the player stops using an Item (stops holding the right mouse button).
      *
      * @param timeLeft The amount of ticks left before the using would have been complete
      */
      public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft)
      {
      int j = this.getMaxItemUseDuration(stack) - timeLeft;
      net.minecraftforge.event.entity.player.ArrowLooseEvent event = new net.minecraftforge.event.entity.player.ArrowLooseEvent(playerIn, stack, j);
      if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return;
      j = event.charge;
      
      boolean flag = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
      
      if (flag || playerIn.inventory.hasItem(Items.arrow))
      {
      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;
      }
      
      EntityArrow entityarrow = new EntityArrow(worldIn, playerIn, f * 2.0F);
      
      if (f == 1.0F)
      {
      entityarrow.setIsCritical(true);
      }
      
      int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
      
      if (k > 0)
      {
      entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D);
      }
      
      int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
      
      if (l > 0)
      {
      entityarrow.setKnockbackStrength(l);
      }
      
      if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
      {
      entityarrow.setFire(100);
      }
      
      stack.damageItem(1, playerIn);
      worldIn.playSoundAtEntity(playerIn, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
      
      if (flag)
      {
      entityarrow.canBePickedUp = 2;
      }
      else
      {
      playerIn.inventory.consumeInventoryItem(Items.arrow);
      }
      
      playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
      
      if (!worldIn.isRemote)
      {
      worldIn.spawnEntityInWorld(entityarrow);
      }
      }
      }
      
      /**
      * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
      * the Item before the action is complete.
      */
      public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn)
      {
      return stack;
      }
      
      /**
      * How long it takes to use or consume an item
      */
      public int getMaxItemUseDuration(ItemStack stack)
      {
      return 72000;
      }
      
      /**
      * returns the action that specifies what animation to play when the items is being used
      */
      public EnumAction getItemUseAction(ItemStack stack)
      {
      return EnumAction.BOW;
      }
      
      /**
      * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
      */
      public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
      {
      net.minecraftforge.event.entity.player.ArrowNockEvent event = new net.minecraftforge.event.entity.player.ArrowNockEvent(playerIn, itemStackIn);
      if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return event.result;
      
      if (playerIn.capabilities.isCreativeMode || playerIn.inventory.hasItem(Items.arrow))
      {
      playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
      }
      
      return itemStackIn;
      }
      
      /**
      * Return the enchantability factor of the item, most of the time is based on material.
      */
      public int getItemEnchantability()
      {
      return 14;
      }
      
      @Override
      public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
      {
      ModelResourceLocation modelresourcelocation = new ModelResourceLocation(Reference.MOD_ID + ":iron_bladed_bow_standby", "inventory");
      
      if(stack.getItem() == this && player.getItemInUse() != null)
      {
      if(useRemaining >= 71985)
      {
      modelresourcelocation = new ModelResourceLocation(Reference.MOD_ID + ":iron_bladed_bow_pulling_0", "inventory");
      }
      else if(useRemaining > 71979)
      {
      modelresourcelocation = new ModelResourceLocation(Reference.MOD_ID + ":iron_bladed_bow_pulling_1", "inventory");
      }
      else if(useRemaining > 0)
      {
      modelresourcelocation = new ModelResourceLocation(Reference.MOD_ID + ":iron_bladed_bow_pulling_2", "inventory");
      }
      }
      return modelresourcelocation;
      }
      
      public Multimap getItemAttributeModifiers()
      {
      Multimap multimap = super.getItemAttributeModifiers();
      multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", (double)this.attackDamage, 0));
      return multimap;
      }
      
      public boolean canHarvestBlock(Block blockIn)
      {
      return blockIn == Blocks.web;
      }
      
      public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
      {
      stack.damageItem(1, attacker);
      return true;
      }
      
      }
      
      

      Sinon, tu n’a pas besoin de modifier la valeur double ici

      public Multimap getItemAttributeModifiers()
      {
      (double)this.attackDamage, 6));
      
      }
      

      Membre fantôme
      Je développe maintenant un jeu sur UnrealEngine4


      Contact :…

      1 réponse Dernière réponse Répondre Citer 0
      • PadreDeLaCuartoP Hors-ligne
        PadreDeLaCuarto
        dernière édition par

        Tu fais des choses donc je suis incapable x)
        Je trifouille avec ton code et toute façon sa finis toujours par marcher x)

        Programmeur un peu trop ambicieux au vu des c'est capacité :D

        1 réponse Dernière réponse Répondre Citer 0
        • EryahE Hors-ligne
          Eryah
          dernière édition par

          Ne t’inquiète pas 🙂
          Il y a 2 mois, j’étais au même niveau que toi. Au lieu de voir cela :

          public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
             {
                 net.minecraftforge.event.entity.player.ArrowNockEvent event = new net.minecraftforge.event.entity.player.ArrowNockEvent(playerIn, itemStackIn);
                 if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return event.result;
          
                 if (playerIn.capabilities.isCreativeMode || playerIn.inventory.hasItem(Items.arrow))
                 {
                     playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
                 }
          
                 return itemStackIn;
             }
          

          je voyais :

          befhehfuehfhjkjkjb
          dzergryyuiuhgfsfreeg
          ffdggggggggggggggresgfefef(()fegf(ygddf)
          degeygzgfgsdiy[]zdnjsbfiubkbsqkubdc
          

          Sinon, j’ai bien dis que mon code est très spécial. Ne prends pas les méthodes init, register, registerRenders, etc. Ce sont les méthode qui me permtent de faire en sorte que mes Items existes
          C’est le code d’un arc, donc évite de faire en sorte que ton épée tire des flèches ^^’

          C’est un code 1.8. 
          Si les codes qu eje t’ai donnés bugés, c’est car ce n’est pas compatible avec ta version.
          Je fais un workspace 1.7 juste pour toi la, pour check le code de l’épée vanilla en 1.7

          Membre fantôme
          Je développe maintenant un jeu sur UnrealEngine4


          Contact :…

          1 réponse Dernière réponse Répondre Citer 0
          • PadreDeLaCuartoP Hors-ligne
            PadreDeLaCuarto
            dernière édition par

            Ahahaha mais non se n’est pas mon cas #L’Humour :s

            Programmeur un peu trop ambicieux au vu des c'est capacité :D

            1 réponse Dernière réponse Répondre Citer 0
            • EryahE Hors-ligne
              Eryah
              dernière édition par

              Après un passage sur les sources 1.7, itemModifierUUID a un nom différent en 1.7. Une fonction numérotée, et c’est compliqué

              public Multimap getItemAttributeModifiers()
              {
              Multimap multimap = super.getItemAttributeModifiers();
              multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)this.field_150934_a, 0));
              return multimap;
              }
              

              Remplace ta méthode par celle ci 🙂

              Membre fantôme
              Je développe maintenant un jeu sur UnrealEngine4


              Contact :…

              1 réponse Dernière réponse Répondre Citer 0
              • PadreDeLaCuartoP Hors-ligne
                PadreDeLaCuarto
                dernière édition par

                Le problème est réglé mais toujours une erreur au niveau des field ( 111210_e et 150934_a ) 😕

                Programmeur un peu trop ambicieux au vu des c'est capacité :D

                1 réponse Dernière réponse Répondre Citer 0
                • EryahE Hors-ligne
                  Eryah
                  dernière édition par

                  Rajoute private float field_150934_a; en haut de ta classe

                  Membre fantôme
                  Je développe maintenant un jeu sur UnrealEngine4


                  Contact :…

                  1 réponse Dernière réponse Répondre Citer 0
                  • PadreDeLaCuartoP Hors-ligne
                    PadreDeLaCuarto
                    dernière édition par

                    Fait et plus d’erreur 😄
                    Mais quand je lance pas de dégâts ni de moyen de faire un clique droit qui pare 😕

                    Programmeur un peu trop ambicieux au vu des c'est capacité :D

                    1 réponse Dernière réponse Répondre Citer 0
                    • robin4002R Hors-ligne
                      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                      dernière édition par

                      Regardes ce qu’il y a dans la classe ItemSword.

                      1 réponse Dernière réponse Répondre Citer 0
                      • PadreDeLaCuartoP Hors-ligne
                        PadreDeLaCuarto
                        dernière édition par

                        Robin4002 merci on regard avec Eyrah il m’aide via Skype et on poste les avancé sur le fofo 😛

                        Programmeur un peu trop ambicieux au vu des c'est capacité :D

                        1 réponse Dernière réponse Répondre Citer 0
                        • EryahE Hors-ligne
                          Eryah
                          dernière édition par

                          Bon, alors, supprime tout ce que je t’ai demandé d’ajouter, et reprenons, je vais pas prendre les méthodes 1.8, car elles n’existent pas en 1.7

                          et ajoute :
                          Un Float pour le nombre de dégats

                          private float field_150934_a;
                          

                          dans le constructeur, aoute :

                          this.field_150934_a = ?.0F();
                          

                          Si tu veut que l’item soit vraient comme une épée, rajoute également ceci dans le constructeur

                          this.maxStackSize = 1;
                          

                          Pour la durabilité :

                          this.setMaxDamage(?);
                          

                          Ensuite, dans la classe, ajoute ces méthodes :

                          public float func_150931_i()
                             {
                                 return this.field_150933_b.getDamageVsEntity();
                             }
                          
                          public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_)
                             {
                                 if (p_150893_2_ == Blocks.web)
                                 {
                                     return 15.0F;
                                 }
                                 else
                                 {
                                     Material material = p_150893_2_.getMaterial();
                                     return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F;
                                 }
                             }
                          
                          public boolean hitEntity(ItemStack p_77644_1_, EntityLivingBase p_77644_2_, EntityLivingBase p_77644_3_)
                             {
                                 p_77644_1_.damageItem(1, p_77644_3_);
                                 return true;
                             }
                          
                          public EnumAction getItemUseAction(ItemStack p_77661_1_)
                             {
                                 return EnumAction.block;
                             }
                          
                          public int getMaxItemUseDuration(ItemStack p_77626_1_)
                             {
                                 return 72000;
                             }
                          
                          public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
                             {
                                 p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_));
                                 return p_77659_1_;
                             }
                          
                             public boolean func_150897_b(Block p_150897_1_)
                             {
                                 return p_150897_1_ == Blocks.web;
                             }
                          
                          public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
                             {
                                 p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_));
                                 return p_77659_1_;
                             }
                          
                             public boolean func_150897_b(Block p_150897_1_)
                             {
                                 return p_150897_1_ == Blocks.web;
                             }
                          

                          Edit : j’ai oublié cette méthode, a mettre dans la classe

                           public Multimap getItemAttributeModifiers()
                              {
                                  Multimap multimap = super.getItemAttributeModifiers();
                                  multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)this.field_150934_a, 0));
                                  return multimap;
                              }
                          

                          Pfiouu, mes boutons ctrl et C on mal[/java]

                          Membre fantôme
                          Je développe maintenant un jeu sur UnrealEngine4


                          Contact :…

                          1 réponse Dernière réponse Répondre Citer 0
                          • 1 / 1
                          • Premier message
                            Dernier message
                          Design by Woryk
                          ContactMentions Légales

                          MINECRAFT FORGE FRANCE © 2024

                          Powered by NodeBB