MFF

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

    Plusieurs texture pour UNE entité.

    Planifier Épinglé Verrouillé Déplacé Résolu 1.9.x et 1.10.x
    1.10.x
    37 Messages 4 Publieurs 4.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.
    • H Hors-ligne
      Hugofounda
      dernière édition par

      Bon, je m’avoue un peu dépasser, c’est un peu hors de mes compétences.

      il n’y a pas plus simple ? Comme le rendu des lapins, et des ocelots ?

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

        Non, c’est d’ailleurs ce qu’utilisent les lapins/ocelots apprivoisés

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

          Justement , je pourrais peut etre me servir de ça ?

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

            Oui, c’est la seule manière simple de synchroniser le serveur (l’index du skin) avec tous les clients connectés (permettant de rendre le bon).
            Inspire toi des classes cités au-dessus, et reviens si tu as des questions.

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

              Prendre exemple sur le rendu des Ocelots est le plus simple.

              Ma seule question est par quoi remplacer: switch (entity.getTameSkin())

              package net.minecraft.client.renderer.entity;
              
              import net.minecraft.client.model.ModelBase;
              import net.minecraft.client.renderer.GlStateManager;
              import net.minecraft.entity.passive.EntityOcelot;
              import net.minecraft.util.ResourceLocation;
              import net.minecraftforge.fml.relauncher.Side;
              import net.minecraftforge.fml.relauncher.SideOnly;
              
              @SideOnly(Side.CLIENT)
              public class RenderOcelot extends RenderLiving <entityocelot>{
                 private static final ResourceLocation BLACK_OCELOT_TEXTURES = new ResourceLocation("textures/entity/cat/black.png");
                 private static final ResourceLocation OCELOT_TEXTURES = new ResourceLocation("textures/entity/cat/ocelot.png");
                 private static final ResourceLocation RED_OCELOT_TEXTURES = new ResourceLocation("textures/entity/cat/red.png");
                 private static final ResourceLocation SIAMESE_OCELOT_TEXTURES = new ResourceLocation("textures/entity/cat/siamese.png");
              
                 public RenderOcelot(RenderManager renderManagerIn, ModelBase modelBaseIn, float shadowSizeIn)
                 {
                     super(renderManagerIn, modelBaseIn, shadowSizeIn);
                 }
              
                 /**
                  * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
                  */
                 protected ResourceLocation getEntityTexture(EntityOcelot entity)
                 {
                     switch (entity.getTameSkin())
                     {
                         case 0:
                         default:
                             return OCELOT_TEXTURES;
                         case 1:
                             return BLACK_OCELOT_TEXTURES;
                         case 2:
                             return RED_OCELOT_TEXTURES;
                         case 3:
                             return SIAMESE_OCELOT_TEXTURES;
                     }
                 }
              

              J’arrive à tout remplacer ce qui faut mais comme j’ai dit il y a la ligne: switch (entity.getTameSkin())

              Je sais pas par quoi le remplacer pour ce ça marche avec mon mob. De type Humain , Biped :/</entityocelot>

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

                La méthode getTameSkin renvoie un int représentant l’index de la texture à bind, du coup à toi de faire ta propre méthode.

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

                  J’ai fait quelques changements dans la Classe de l’entité:

                  private static final DataParameter <integer>ASSASSIN_VARIANT = EntityDataManager.<integer>createKey(EntityAssassin.class, DataSerializers.VARINT);
                  
                  public int getAssassinSkin()
                         {
                             return ((Integer)this.dataManager.get(ASSASSIN_VARIANT)).intValue();
                         }
                  

                  Et la classe Render:

                  package fr.hard.mod.Render;
                  
                  import fr.hard.mod.Entity.EntityAssassin;
                  import fr.hard.mod.Models.ModelAssassin;
                  import fr.hard.mod.Models.ModelBandit;
                  import fr.hard.mod.Models.ModelRogue;
                  import net.minecraft.client.model.ModelBase;
                  import net.minecraft.client.model.ModelBiped;
                  import net.minecraft.client.renderer.GlStateManager;
                  import net.minecraft.client.renderer.entity.RenderBiped;
                  import net.minecraft.client.renderer.entity.RenderManager;
                  import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
                  import net.minecraft.entity.passive.EntityOcelot;
                  import net.minecraft.util.ResourceLocation;
                  import net.minecraftforge.fml.relauncher.Side;
                  import net.minecraftforge.fml.relauncher.SideOnly;
                  
                  @SideOnly(Side.CLIENT)
                  public class RenderAssassin extends RenderBiped
                  {
                  private static final ResourceLocation ASSASSIN1_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin1.png");
                  private static final ResourceLocation ASSASSIN2_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin2.png");
                  private static final ResourceLocation ASSASSIN3_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin3.png");
                  private static final ResourceLocation ASSASSIN4_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin4.png");
                  private static final ResourceLocation ASSASSIN5_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin5.png");
                  
                  public RenderAssassin(RenderManager renderManagerIn, ModelAssassin modelAssassin, float f)
                     {
                         super(renderManagerIn, new ModelBiped(), 0.5F, 1.0F);
                         this.addLayer(new LayerHeldItem(this));
                     }
                  
                     protected ResourceLocation getEntityTexture(EntityAssassin entity)
                     {
                         switch (entity.getAssassinSkin())
                         {
                             case 0:
                             default:
                                 return ASSASSIN1_TEXTURE;
                             case 1:
                                 return ASSASSIN2_TEXTURE;
                             case 2:
                                 return ASSASSIN3_TEXTURE;
                             case 3:
                                 return ASSASSIN4_TEXTURE;
                             case 4:
                                 return ASSASSIN5_TEXTURE;
                         }
                     }
                  }
                  

                  Et j’obtiens maintenant ceci: 
                  </integer></integer>

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

                    Une de tes textures est probablement bugguée

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

                      Bon je vois pas le problème. je verrai ça demain.

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

                        Je dirais plutôt que la méthode getEntityTexture n’est jamais appelée. Il faut que tu overrode la méthode getEntityTexture qui prends Entity en argument et que dedans, tu appelle getEntityTexture qui prends EntityAssassin en aguments. (Ou alors que tu garde qu’une fonction mais tu met Entity en argument et tu fait un cast pour pouvoir appeler getAssassinSkin)

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

                          J’arrive pas a mettre un @Override, il me dit de l’enlever a chaque fois.

                          J’ai creer une méthode getEntityTexture comme tu l’a dit.

                          package fr.hard.mod.Render;
                          
                          import fr.hard.mod.Entity.EntityAssassin;
                          import fr.hard.mod.Entity.EntityRogue;
                          import fr.hard.mod.Models.ModelAssassin;
                          import fr.hard.mod.Models.ModelBandit;
                          import fr.hard.mod.Models.ModelRogue;
                          import net.minecraft.client.model.ModelBase;
                          import net.minecraft.client.model.ModelBiped;
                          import net.minecraft.client.renderer.GlStateManager;
                          import net.minecraft.client.renderer.entity.RenderBiped;
                          import net.minecraft.client.renderer.entity.RenderManager;
                          import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
                          import net.minecraft.entity.Entity;
                          import net.minecraft.entity.passive.EntityOcelot;
                          import net.minecraft.util.ResourceLocation;
                          import net.minecraft.util.text.TextFormatting;
                          import net.minecraftforge.fml.relauncher.Side;
                          import net.minecraftforge.fml.relauncher.SideOnly;
                          
                          @SideOnly(Side.CLIENT)
                          public class RenderAssassin extends RenderBiped
                          {
                          private static final ResourceLocation ASSASSIN1_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin1.png");
                          private static final ResourceLocation ASSASSIN2_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin2.png");
                          private static final ResourceLocation ASSASSIN3_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin3.png");
                          private static final ResourceLocation ASSASSIN4_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin4.png");
                          private static final ResourceLocation ASSASSIN5_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin5.png");
                          
                          public RenderAssassin(RenderManager renderManagerIn, ModelAssassin modelAssassin, float f)
                             {
                                 super(renderManagerIn, new ModelBiped(), 0.5F, 1.0F);
                                 this.addLayer(new LayerHeldItem(this));
                             }
                          
                             protected ResourceLocation getEntityTexture(EntityAssassin entity)
                             {
                          
                                 switch (entity.getAssassinSkin())
                                 {
                                     case 0:
                                     default:
                                         return ASSASSIN1_TEXTURE;
                                     case 1:
                                         return ASSASSIN2_TEXTURE;
                                     case 2:
                                         return ASSASSIN3_TEXTURE;
                                     case 3:
                                         return ASSASSIN4_TEXTURE;
                                 }
                             }
                          
                             protected ResourceLocation getEntityTexture(Entity entity)
                             {
                                     return this.getEntityTexture((EntityAssassin)entity);
                             }
                          }
                          

                          Mais j’en arrive au point ou il n’arrive pas a faire le rendu de l’entité 😕

                          [23:46:56] [Client thread/ERROR]: Couldn't render entity
                          java.lang.NullPointerException
                          at net.minecraft.network.datasync.EntityDataManager.get(EntityDataManager.java:149) ~[EntityDataManager.class:?]
                          at fr.hard.mod.Entity.EntityAssassin.getAssassinSkin(EntityAssassin.java:161) ~[EntityAssassin.class:?]
                          at fr.hard.mod.Render.RenderAssassin.getEntityTexture(RenderAssassin.java:40) ~[RenderAssassin.class:?]
                          at fr.hard.mod.Render.RenderAssassin.getEntityTexture(RenderAssassin.java:56) ~[RenderAssassin.class:?]
                          at net.minecraft.client.renderer.entity.Render.bindEntityTexture(Render.java:113) ~[Render.class:?]
                          at net.minecraft.client.renderer.entity.RenderLivingBase.renderModel(RenderLivingBase.java:253) ~[RenderLivingBase.class:?]
                          at net.minecraft.client.renderer.entity.RenderLivingBase.doRender(RenderLivingBase.java:185) [RenderLivingBase.class:?]
                          at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:51) [RenderLiving.class:?]
                          at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:16) [RenderLiving.class:?]
                          at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:372) [RenderManager.class:?]
                          at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:356) [RenderManager.class:?]
                          at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:651) [RenderGlobal.class:?]
                          at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1368) [EntityRenderer.class:?]
                          at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1282) [EntityRenderer.class:?]
                          at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1091) [EntityRenderer.class:?]
                          at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1139) [Minecraft.class:?]
                          at net.minecraft.client.Minecraft.run(Minecraft.java:406) [Minecraft.class:?]
                          at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
                          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
                          at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
                          at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
                          at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
                          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
                          at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
                          at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
                          at GradleStart.main(GradleStart.java:26) [start/:?]
                          
                          1 réponse Dernière réponse Répondre Citer 0
                          • LeBossMax2L Hors-ligne
                            LeBossMax2
                            dernière édition par

                            Je ne connais pas trop les DataWatcher, mais dans ce cas, je ne vois pas trop à quoi il sert (si la valeur est défie à la création de l’entitée, puis n’est pas changée).
                            Sinon, je pense que tu n’as pas “register” ton DataWatcher ou alors tu ne l’as pas initialisée (mais, là, je ne m’y connais pas, donc je peux pas trop t’aider).

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

                              Les DataManagers sont obligés comme il compte save dans les NBT

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

                                Bonne nouvelle , les skins changent. Mais que quand je relance le jeu.

                                package fr.hard.mod.Render;
                                
                                import net.minecraft.client.model.ModelBase;
                                import net.minecraft.client.model.ModelBiped;
                                import net.minecraft.client.model.ModelZombie;
                                import net.minecraft.client.renderer.OpenGlHelper;
                                import net.minecraft.client.renderer.entity.RenderBiped;
                                import net.minecraft.client.renderer.entity.RenderLiving;
                                import net.minecraft.client.renderer.entity.RenderManager;
                                import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
                                import net.minecraft.entity.Entity;
                                import net.minecraft.entity.monster.EntityEnderman;
                                import net.minecraft.item.ItemStack;
                                import net.minecraft.util.ResourceLocation;
                                import net.minecraftforge.fml.relauncher.SideOnly;
                                import net.minecraftforge.fml.relauncher.Side;
                                
                                import java.util.Random;
                                
                                import org.lwjgl.opengl.GL11;
                                
                                import fr.hard.mod.Entity.EntityAssassin;
                                import fr.hard.mod.Entity.EntityRogue;
                                import fr.hard.mod.Models.ModelAssassin;
                                import fr.hard.mod.Models.ModelHerobrine;
                                import fr.hard.mod.Models.ModelRogue;
                                
                                @SideOnly(Side.CLIENT)
                                public class RenderAssassin extends RenderBiped
                                {
                                
                                public static ResourceLocation[] skins;
                                    public int currentSkin; {
                                
                                        Random rand = new Random();
                                
                                        currentSkin = rand.nextInt(skins.length);}
                                
                                private static final ResourceLocation ASSASSIN1_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin1.png");
                                private static final ResourceLocation ASSASSIN2_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin2.png");
                                private static final ResourceLocation ASSASSIN3_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin3.png");
                                private static final ResourceLocation ASSASSIN4_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin4.png");
                                private static final ResourceLocation ASSASSIN5_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin5.png");
                                
                                public RenderAssassin(RenderManager renderManagerIn, ModelAssassin modelAssassin, float f)
                                      {
                                          super(renderManagerIn, new ModelBiped(), 0.5F, 1.0F);
                                          this.addLayer(new LayerHeldItem(this));
                                      }
                                
                                static
                                      {
                                          skins = (new ResourceLocation[]
                                                  {
                                                      new ResourceLocation("hard", "textures/humans/assassin1.png"), new ResourceLocation("hard", "textures/humans/assassin2.png"), new ResourceLocation("hard", "textures/humans/assassin2.png"), new ResourceLocation("hard", "textures/humans/assassin3.png"), new ResourceLocation("hard", "textures/humans/assassin4.png"), new ResourceLocation("hard", "textures/humans/assassin5.png")
                                                  });
                                       }
                                
                                      protected ResourceLocation getAssassinTexture(EntityAssassin assassin)
                                      {
                                              return skins[currentSkin];
                                      }
                                
                                      protected ResourceLocation getEntityTexture(Entity entity)
                                      {
                                              return this.getAssassinTexture((EntityAssassin)entity);
                                      }
                                }
                                
                                1 réponse Dernière réponse Répondre Citer 0
                                • DeletedD Hors-ligne
                                  Deleted
                                  dernière édition par

                                  Qu’est-ce que cela veut dire “que quand je relance mon jeu” ?
                                  Au contraire si tu saves dans les NBT, il y aura de la persistance dans le monde généré, donc les skins une fois définis, ne changeront plus.

                                  EDIT: Vu l’état actuel de ton code, tu n’utilise pas du tout la structure NBT.

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

                                    Le skin de mon mob change quand je relance le jeu.

                                    Quand j’utilise les oeufs , sa fait spawner que la meme texture. Je dois relancer le jeu pour avoir une autre texture.

                                    Je vais essayer de mettre des NBT

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

                                      Il me semble que les classes Render sont de type Singleton, du coup instanciées qu’une seule fois. Il est donc normal, que ta variable currentSkin prendra toujours la même valeur pour n’importe quel instance d’entité dans le monde, jusqu’au prochaine redémarrage de mc.

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

                                        Je suis pas sur, mais pourquoi pas s’inspirer de ce code ?

                                        @Override
                                           public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata)
                                              {
                                           livingdata = super.onInitialSpawn(difficulty, livingdata);
                                           this.setEquipmentBasedOnDifficulty(difficulty);
                                           return livingdata;
                                           }
                                        
                                        1 réponse Dernière réponse Répondre Citer 0
                                        • DeletedD Hors-ligne
                                          Deleted
                                          dernière édition par

                                          Le constructeur serait + approprié

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

                                            Les skins changent bien en jeu 🙂 Mais quand je fais spawner un mob, il y a sa texture, OK .
                                            Quand j’en fait spawner un deuxieme, sa texture change.

                                            Le seul soucis c’est que quand le deuxieme spawn, tout les mobs (du meme type) prennent le meme skin et donc tout mes mobs ont le meme skin.

                                            Classe de l’entité:

                                            package fr.hard.mod.Entity;
                                            
                                            import java.util.Random;
                                            
                                            import fr.hard.mod.EntityAIAttackMelee;
                                            import fr.hard.mod.HSoundEvents;
                                            import net.minecraft.block.material.Material;
                                            import net.minecraft.enchantment.EnchantmentHelper;
                                            import net.minecraft.entity.Entity;
                                            import net.minecraft.entity.EntityLiving;
                                            import net.minecraft.entity.IEntityLivingData;
                                            import net.minecraft.entity.SharedMonsterAttributes;
                                            import net.minecraft.entity.ai.EntityAIFollowParent;
                                            import net.minecraft.entity.ai.EntityAIHurtByTarget;
                                            import net.minecraft.entity.ai.EntityAILookIdle;
                                            import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
                                            import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
                                            import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
                                            import net.minecraft.entity.ai.EntityAISwimming;
                                            import net.minecraft.entity.ai.EntityAIWander;
                                            import net.minecraft.entity.ai.EntityAIWatchClosest;
                                            import net.minecraft.entity.monster.EntityCreeper;
                                            import net.minecraft.entity.monster.EntityIronGolem;
                                            import net.minecraft.entity.monster.EntityMob;
                                            import net.minecraft.entity.monster.EntityPigZombie;
                                            import net.minecraft.entity.monster.EntityPolarBear;
                                            import net.minecraft.entity.monster.EntitySkeleton;
                                            import net.minecraft.entity.monster.EntityZombie;
                                            import net.minecraft.entity.passive.EntityOcelot;
                                            import net.minecraft.entity.passive.EntityPig;
                                            import net.minecraft.entity.passive.EntityRabbit;
                                            import net.minecraft.entity.passive.EntitySheep;
                                            import net.minecraft.entity.passive.EntityVillager;
                                            import net.minecraft.entity.player.EntityPlayer;
                                            import net.minecraft.init.Items;
                                            import net.minecraft.init.SoundEvents;
                                            import net.minecraft.inventory.EntityEquipmentSlot;
                                            import net.minecraft.item.Item;
                                            import net.minecraft.item.ItemStack;
                                            import net.minecraft.nbt.NBTTagCompound;
                                            import net.minecraft.network.datasync.DataParameter;
                                            import net.minecraft.network.datasync.DataSerializers;
                                            import net.minecraft.network.datasync.EntityDataManager;
                                            import net.minecraft.util.DamageSource;
                                            import net.minecraft.util.EnumHand;
                                            import net.minecraft.util.ResourceLocation;
                                            import net.minecraft.util.SoundEvent;
                                            import net.minecraft.util.math.MathHelper;
                                            import net.minecraft.util.text.ITextComponent;
                                            import net.minecraft.util.text.TextFormatting;
                                            import net.minecraft.world.DifficultyInstance;
                                            import net.minecraft.world.EnumDifficulty;
                                            import net.minecraft.world.World;
                                            import net.minecraftforge.event.entity.living.LivingDeathEvent;
                                            import net.minecraftforge.event.entity.player.AttackEntityEvent;
                                            
                                            public class EntityAssassin extends EntityMob
                                            {
                                            
                                            public static ItemStack equippedItems[];
                                               public int currentItem; {
                                            
                                               currentItem = rand.nextInt(equippedItems.length);}
                                            
                                               public static ResourceLocation[] skins;
                                               public static  int currentSkin; {
                                            
                                                   Random rand = new Random();
                                            
                                                   currentSkin = rand.nextInt(skins.length);}
                                            
                                            public EntityAssassin(World worldIn)
                                               {
                                                   super(worldIn);
                                            
                                                   this.tasks.addTask(0, new EntityAISwimming(this));
                                                   this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false));
                                                   this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
                                                   this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
                                                   this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
                                                   this.tasks.addTask(8, new EntityAILookIdle(this));
                                                   this.applyEntityAI();
                                            
                                               }
                                            
                                            protected void applyEntityAttributes()
                                               {
                                                   super.applyEntityAttributes();
                                                   this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(12.0D);
                                                   this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.39000000417232513D);
                                                   this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D);
                                                   this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
                                               }
                                            
                                               protected void applyEntityAI()
                                               {
                                                   this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[] {EntityPlayer.class}));
                                                   this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityBandit.class, false));
                                                   this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityCreeper.class, true));
                                                   this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityPirate.class, true));
                                                   this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityRogue.class, true));
                                                   this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityRogueArcher.class, true));
                                                   this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityShadow.class, true));
                                                   this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityZombie.class, true));
                                                   this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntitySkeleton.class, true));
                                                   this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityCreeper.class, true));
                                               }
                                            
                                                protected SoundEvent getHurtSound()
                                                {
                                                    return HSoundEvents.ENTITY_HURT;
                                                }
                                            
                                                protected SoundEvent getDeathSound()
                                                {
                                                    return HSoundEvents.ENTITY_NEUTRAL_DEATH;
                                                }
                                            
                                                public void dropFewItems(boolean b, int looting)
                                                {
                                                    this.dropItem(Items.GOLD_INGOT, 2);
                                                    this.dropItem(Items.REDSTONE, 1);
                                                }
                                            
                                                static
                                                {
                                                    equippedItems = (new ItemStack[]
                                                            {
                                                                new ItemStack(Items.WOODEN_PICKAXE, 1), new ItemStack(Items.WOODEN_SWORD, 1), new ItemStack(Items.BRICK, 1), new ItemStack(Items.IRON_AXE, 1), new ItemStack(Items.GOLDEN_AXE, 1), new ItemStack(Items.IRON_HOE, 1), new ItemStack(Items.DIAMOND_SWORD, 1), new ItemStack(Items.IRON_SWORD, 1), new ItemStack(Items.GOLDEN_SWORD, 1), new ItemStack(Items.IRON_PICKAXE, 1)
                                                            });
                                                 }
                                            
                                                public ItemStack getHeldItem()
                                                {
                                                    return equippedItems[currentItem];
                                                }
                                            
                                                public void writeEntityToNBT(NBTTagCompound nbttagcompound)
                                                {
                                                    nbttagcompound.setInteger("equippedItem", currentItem);
                                                    super.writeEntityToNBT(nbttagcompound);;
                                                }
                                            
                                                public void readEntityFromNBT(NBTTagCompound nbttagcompound)
                                                {
                                                    currentItem = nbttagcompound.getInteger("equippedItem");
                                                    super.readEntityFromNBT(nbttagcompound);
                                                }
                                            
                                                @Override
                                                public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata)
                                                   {
                                                livingdata = super.onInitialSpawn(difficulty, livingdata);
                                                this.setEquipmentBasedOnDifficulty(difficulty);
                                                return livingdata;
                                                }
                                            
                                                   @Override
                                                   protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
                                                   {
                                                       super.setEquipmentBasedOnDifficulty(difficulty);
                                                       this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, equippedItems[currentItem]);
                                                   }
                                            
                                                   @Override
                                                   protected boolean canDespawn() {
                                                   return true;
                                                   }
                                            
                                            }
                                            

                                            Classe du rendu:

                                            package fr.hard.mod.Render;
                                            
                                            import net.minecraft.client.model.ModelBase;
                                            import net.minecraft.client.model.ModelBiped;
                                            import net.minecraft.client.model.ModelZombie;
                                            import net.minecraft.client.renderer.OpenGlHelper;
                                            import net.minecraft.client.renderer.entity.RenderBiped;
                                            import net.minecraft.client.renderer.entity.RenderLiving;
                                            import net.minecraft.client.renderer.entity.RenderManager;
                                            import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
                                            import net.minecraft.entity.Entity;
                                            import net.minecraft.entity.IEntityLivingData;
                                            import net.minecraft.entity.monster.EntityEnderman;
                                            import net.minecraft.item.ItemStack;
                                            import net.minecraft.nbt.NBTTagCompound;
                                            import net.minecraft.util.ResourceLocation;
                                            import net.minecraftforge.fml.relauncher.SideOnly;
                                            import net.minecraftforge.fml.relauncher.Side;
                                            
                                            import java.util.Random;
                                            
                                            import org.lwjgl.opengl.GL11;
                                            
                                            import fr.hard.mod.Entity.EntityAssassin;
                                            import fr.hard.mod.Entity.EntityRogue;
                                            import fr.hard.mod.Models.ModelAssassin;
                                            import fr.hard.mod.Models.ModelHerobrine;
                                            import fr.hard.mod.Models.ModelRogue;
                                            
                                            @SideOnly(Side.CLIENT)
                                            public class RenderAssassin extends RenderBiped
                                            {
                                            
                                            private static final ResourceLocation ASSASSIN1_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin1.png");
                                            private static final ResourceLocation ASSASSIN2_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin2.png");
                                            private static final ResourceLocation ASSASSIN3_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin3.png");
                                            private static final ResourceLocation ASSASSIN4_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin4.png");
                                            private static final ResourceLocation ASSASSIN5_TEXTURE = new ResourceLocation("hard", "textures/humans/assassin5.png");
                                            
                                            public RenderAssassin(RenderManager renderManagerIn, ModelAssassin modelAssassin, float f)
                                                  {
                                                      super(renderManagerIn, new ModelBiped(), 0.5F, 1.0F);
                                                      this.addLayer(new LayerHeldItem(this));
                                                  }
                                            
                                            static
                                               {
                                            EntityAssassin.skins = (new ResourceLocation[]
                                                           {
                                                               new ResourceLocation("hard", "textures/humans/assassin1.png"), new ResourceLocation("hard", "textures/humans/assassin2.png"), new ResourceLocation("hard", "textures/humans/assassin2.png"), new ResourceLocation("hard", "textures/humans/assassin3.png"), new ResourceLocation("hard", "textures/humans/assassin4.png"), new ResourceLocation("hard", "textures/humans/assassin5.png")
                                                           });
                                                }
                                            
                                               protected ResourceLocation getAssassinTexture(EntityAssassin assassin)
                                               {
                                                       return EntityAssassin.skins[EntityAssassin.currentSkin];
                                               }
                                            
                                                  protected ResourceLocation getEntityTexture(Entity entity)
                                                  {
                                                          return this.getAssassinTexture((EntityAssassin)entity);
                                                  }
                                            }
                                            
                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 2 / 2
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB