• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu Plusieurs textures pour un même modèle custom d'une entité

    1.7.x
    1.7.10
    4
    37
    3944
    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.
    • Folgansky
      Folgansky Correcteurs dernière édition par

      Voilà,

      Donc mon but n’est pas d’avoir une texture random à chaque spawn mais bien utiliser un item différent pour faire spawn une même entité mais dont la texture est différente.  (en l’occurence une entité montable vesant office de véhicule)
      On m’a conseillé le datawatcher (qui à ce que j’ai compris fait en sorte que le serveur rappelle au client ce qu’il a fait auparavant).

      J’vous montre mes classes et puis vous me direz si y’a moyen d’y caler des lignes ou si je dois refaire ça d’une manière plus appropriée.

      :::

      public class ItemMonture extends Item
      {
      public static String[] type = new String[]{"ItemMonture1", "ItemMonture2", "ItemMonture3", "ItemMonture4", "ItemMonture5"};
      public IIcon[] iconArray = new IIcon[type.length];
      
      public ItemMonture()
      {
      super();
      this.setHasSubtypes(true); 
      }
      
      public int getMaxItemUseDuration(ItemStack stack)
         {
             return 1;
         }
      
          public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
          {
          int metadata = stack.getItemDamage();
          if (metadata == 0)
          {
          if(!world.isRemote)
              {
          EntityMoto e = new EntityMoto(world);
          e.setPosition(x, y + 1.0F, z);
          world.spawnEntityInWorld(e);
          stack.stackSize–;
              }
                 return true;
          }
          else if (metadata == 1)
          {
          if(!world.isRemote)
              {
          EntityKart e = new EntityKart(world);
          e.setPosition(x, y + 1.0F, z);
          world.spawnEntityInWorld(e);
          stack.stackSize--;
              }
                  return true;
          }
          else if (metadata == 2)
          {
          if(!world.isRemote)
              {
          EntityBMX e = new EntityBMX(world);
          e.setPosition(x, y + 1.0F, z);
          world.spawnEntityInWorld(e);
          stack.stackSize--;
              }
                  return true;
          }
          else if (metadata == 3)
          {
          if(!world.isRemote)
              {
          EntityBuggy e = new EntityBuggy(world);
          e.setPosition(x, y + 1.0F, z);
          world.spawnEntityInWorld(e);
          stack.stackSize--;
              }
                  return true;
          }
          else if (metadata == 4)
          {
          if(!world.isRemote)
              {
          EntityBaignoire e = new EntityBaignoire(world);
          e.setPosition(x, y + 1.0F, z);
          world.spawnEntityInWorld(e);
          stack.stackSize--;
              }
                  return true;
          }
          return metadata == 0;
      }
      
          public int getMetadata(int metadata)
      {
      return metadata;
      }
      
          public String getUnlocalizedName(ItemStack stack)
          {
              int metadata = stack.getItemDamage();
      
              if(metadata > type.length || metadata < 0)
              {
              metadata = 0;
              }
      
              return super.getUnlocalizedName() + "." + type[metadata];
          }
      
      @SuppressWarnings({ "rawtypes", "unchecked" })
      public void getSubItems(Item item, CreativeTabs tabs, List list)
          {
          for(int i = 0; i < type.length; i++)
          {
              list.add(new ItemStack(item, 1, i));
          }
          }
      
          public void registerIcons(IIconRegister iconRegister)
          {
          for(int i = 0; i < type.length; i++)
              this.iconArray* = iconRegister.registerIcon(Modpg.MODID + ":" + type*);
          }
      
          public IIcon getIcon(int side, int metadata)
          {
          if(metadata >= 0 && metadata < type.length)
          {
          return this.iconArray[metadata];
          }
              return this.iconArray[0];
          }
      
          public IIcon getIconFromDamage(int metadata)
      {
      return metadata < type.length && metadata >= 0 ? iconArray[metadata] : iconArray[0];
      }
      }
      

      :::

      :::

      public class RenderMoto extends RenderLiving
      {
          public final ResourceLocation texture = new ResourceLocation("Modpg:textures/entity/Moto.png");
      
          public RenderMoto(ModelBase model, float shadow)
          {
              super(model, shadow);
          }
      
      private ResourceLocation getMotoTexture(EntityMoto moto)
          {
              return texture;
          }
      
          @Override
          protected ResourceLocation getEntityTexture(Entity entity)
          {
              return this.getMotoTexture((EntityMoto)entity);
          }
      }
      

      :::

      Dites moi si il faut d’autres classes, il me semble que ces deux là sont les concernées.

      1 réponse Dernière réponse Répondre Citer 0
      • DiabolicaTrix
        DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par

        Ok donc example que ton meta data 1 et ton metadata 2 sont deux entités moto et que tu veux mettre la texture bleu et la texture rouge.

        dans ton onItemUse:

        @Override
        public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
        {
        int metadata = stack.getItemDamage();
        if(metadata == 1)
        {
        EntityMarketPNJ e = new EntityMarketPNJ(world);
           if(!world.isRemote)
               {
            e.setPosition(x, y + 1.0F, z);
            world.spawnEntityInWorld(e);
            stack.stackSize–;
               }
           else
           {
            DataWatcher dw = e.getDataWatcher();
            dw.updateObject(20, "bleu");
           }
               return true;
        }
        else if(metadata == 2)
        {
        EntityMarketPNJ e = new EntityMarketPNJ(world);
           if(!world.isRemote)
               {
            e.setPosition(x, y + 1.0F, z);
            world.spawnEntityInWorld(e);
            stack.stackSize--;
               }
           else
           {
            DataWatcher dw = e.getDataWatcher();
            dw.updateObject(20, "rouge");
           }
               return true;
        }
        return false;
        }
        

        Il faut que tu mettes ceci dans ton event handler de forge:

        @SubscribeEvent
        public void handleConstruction(EntityConstructing event)
        {
           if(event.entity instanceof EntityMoto)
           {
               DataWatcher dw = event.entity.getDataWatcher();
               dw.addObject(20, "couleurpardefaut");
           }
        }
        

        Dans ton render:

        public class RenderMoto extends RenderLiving
        {
        
           public RenderMoto(ModelBase model, float shadow)
           {
               super(model, shadow);
           }
        
        private ResourceLocation getMotoTexture(EntityMoto moto)
           {
        DataWatcher dw = moto.getDataWatcher();
               return new ResourceLocation("Modpg:textures/entity/" + dw.getWatchableObjectString(20) + ".png");
           }
        
           @Override
           protected ResourceLocation getEntityTexture(Entity entity)
           {
               return this.getMotoTexture((EntityMoto)entity);
           }
        }
        

        Je n’ai pas testé, c’est possible qu’il y est des erreurs.

        1 réponse Dernière réponse Répondre Citer 0
        • Folgansky
          Folgansky Correcteurs dernière édition par

          D’acc, cette méthode ne m’autorise qu’une texture en plus?

          (je check si ça marche chez moi, je vois qu’on ne met pas ```java
          [size=smallEntityMarketPNJ][size=small e ][size=small=] [size=smallnew] [size=smallEntityMarketPNJ]size=small;

          
          Edit:
          
          En fait, là tu me passes du code pour m'aider mais je ne le comprends pas vraiment.
          Notamment comment quand j'utilise mon item, le jeu comprend que je veux faire apparaitre mon entité avec telle texture et pas l'autre.
          ça va me créer un item différent?
          
          Re-Edit: Han ok en fait y'a deux items différents dans ton exemple, ma faute
          1 réponse Dernière réponse Répondre Citer 0
          • DiabolicaTrix
            DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par

            Merde le EntityMarketPNJ tu peux le remplacer par EntityMoto. En fait j’étais encore en train de construire le post pour les explications mais je vais les mettre ici.

            En fait dans ta méthode onItemUse tu n’as qu’à vérifier le metadata comme tu le fais déjà sauf que tu dois sortir ton objet (EntityMoto) de la condition car tu dois mettre a jour le datawatcher à partir du serveur. Donc tu crée une nouvelle instance de EntityMoto, si c’est le client tu le fais spawn et si c’est le serveur, tu mets a jour le datawatcher pour la couleur que tu veux. Ensuite dans ton render, tu récupère le datawatcher et tu l’inclus dans la texture donc si tu change la valeur du datawatcher la texture va changer.

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

              Euh ce n’est pas une bonne idée de confier au client le spawn de l’EntityMoto ^^’

              1 réponse Dernière réponse Répondre Citer 0
              • Folgansky
                Folgansky Correcteurs dernière édition par

                Bon comme j’ai un crash me suis de suite dis que j’ai mal fais niveau eventHandler

                Dans am classe principale j’ai

                public void Init(FMLInitializationEvent event)
                {
                MinecraftForge.EVENT_BUS.register(new LivingEventHandler());
                […]
                

                Et dans ce LivingEventHandler

                public class LivingEventHandler
                {
                @SubscribeEvent
                public void handleConstruction(EntityConstructing event)
                {
                  if(event.entity instanceof EntityMoto)
                  {
                      DataWatcher dw = event.entity.getDataWatcher();
                      dw.addObject(20, "couleurpardefaut");
                  }
                }
                […]
                

                Autre possibilité, c’est que tu parles de client et serveur, la base du DataWatcher, donc quand je teste ça sur Eclipse je suis sensé lancer un test serveur nan? (Parce que ça je ne sais pas faire non plus… Si j’ose dire)

                Edit: Voilà ce que j’ai fais de ma classe ItemMonture afin de tester tout ça

                :::

                @Override
                public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
                {
                int metadata = stack.getItemDamage();
                if(metadata == 0)
                {
                EntityMoto e = new EntityMoto(world);
                  if(!world.isRemote)
                      {
                   e.setPosition(x, y + 1.0F, z);
                   world.spawnEntityInWorld(e);
                   stack.stackSize--;
                      }
                  else
                  {
                   DataWatcher dw = e.getDataWatcher();
                   dw.updateObject(20, "Moto");
                  }
                      return true;
                }
                else if(metadata == 1)
                {
                EntityMoto e = new EntityMoto(world);
                  if(!world.isRemote)
                      {
                   e.setPosition(x, y + 1.0F, z);
                   world.spawnEntityInWorld(e);
                   stack.stackSize--;
                      }
                  else
                  {
                   DataWatcher dw = e.getDataWatcher();
                   dw.updateObject(20, "Moto2");
                  }
                      return true;
                }
                else if (metadata == 2)
                    {
                    if(!world.isRemote)
                        {
                    EntityBMX e = new EntityBMX(world);
                    e.setPosition(x, y + 1.0F, z);
                    world.spawnEntityInWorld(e);
                    stack.stackSize--;
                        }
                            return true;
                    }
                else if (metadata == 3)
                    {
                    if(!world.isRemote)
                        {
                    EntityBuggy e = new EntityBuggy(world);
                    e.setPosition(x, y + 1.0F, z);
                    world.spawnEntityInWorld(e);
                    stack.stackSize--;
                        }
                            return true;
                    }
                    else if (metadata == 4)
                    {
                    if(!world.isRemote)
                        {
                    EntityBaignoire e = new EntityBaignoire(world);
                    e.setPosition(x, y + 1.0F, z);
                    world.spawnEntityInWorld(e);
                    stack.stackSize--;
                        }
                            return true;
                    }
                return metadata == 0;
                }
                

                :::

                Du coup je vois que le code prédédent fonctionne (les 3 derniers metadata spawnent bien l’entité voulue), par contre le nouveau me fait crash.
                Y’a aussi le coup de bleu, rouge, couleurpardefaut, je dois mettre le nom de ma texture? (ce que tu expliques dans ta dernière réponse, je veux juste savoir si j’ai compris ou si chui en mode boulet ce soir)

                1 réponse Dernière réponse Répondre Citer 0
                • DiabolicaTrix
                  DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par

                  Peux-tu envoyer ton crash report stp?

                  Pour le bleu, rouge et couleurpardefaut, tu as vu juste j’avais oublié de le dire mais c’est bien le nom de la texture.

                  1 réponse Dernière réponse Répondre Citer 0
                  • Folgansky
                    Folgansky Correcteurs dernière édition par

                    Crash report

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

                      Ligne 18 de ta classe LivingEventHandler ?
                      Apparemment l’id choisie du DataWatcher n’est pas le bon, c’est bizarre….

                      1 réponse Dernière réponse Répondre Citer 0
                      • Folgansky
                        Folgansky Correcteurs dernière édition par

                        :::

                        public class LivingEventHandler
                        {
                        @SubscribeEvent
                        public void handleConstruction(EntityConstructing event)
                        {
                          if(event.entity instanceof EntityMoto)
                          {
                              DataWatcher dw = event.entity.getDataWatcher();
                              dw.addObject(20, "Moto");
                          }
                        }
                        

                        :::

                        :::

                        public class RenderMoto extends RenderLiving
                        {
                            public RenderMoto(ModelBase model, float shadow)
                            {
                                super(model, shadow);
                            }
                        
                        private ResourceLocation getMotoTexture(EntityMoto moto)
                            {
                        DataWatcher dw = moto.getDataWatcher();
                           return new ResourceLocation("Modpg:textures/entity/" + dw.getWatchableObjectString(20) + ".png");
                            }
                        
                            @Override
                            protected ResourceLocation getEntityTexture(Entity entity)
                            {
                                return this.getMotoTexture((EntityMoto)entity);
                            }
                        }
                        

                        :::

                        J’avais édit justement pour les mettre mais tu es plus rapide que moi.

                        1 réponse Dernière réponse Répondre Citer 0
                        • DiabolicaTrix
                          DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par

                          Essaie de créer un nouveau monde. ou de changer les ids pour un autre.

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

                            Le problème c’est que le bout de classe d’EventHandler que tu m’as donné ne possède même pas 18 lignes x)
                            Passe moi la ligne 18 précisément, juste la ligne 18 ^^

                            1 réponse Dernière réponse Répondre Citer 0
                            • Folgansky
                              Folgansky Correcteurs dernière édition par

                              @‘DiabolicaTrix’:

                              Essaie de créer un nouveau monde. ou de changer les ids pour un autre.

                              Ok bonne nouvelle, j’ai mis l’id à 30 et changé le world, plus de crash.
                              Ceci dit ce qui spawn est invisible, montable, mais invisible.

                              Edit: Si la ligne 18 est bien "       dw.addObject(30, “Moto”);         "

                              Edit2: Rectification

                              J’avais oublié de changer l’Id du render pour “30”.
                              Ceci dit mon metadata 0 et 1 font spawn une moto ayant la même texture.
                              Bien que:
                              :::

                              {
                              EntityMoto e = new EntityMoto(world);
                                if(!world.isRemote)
                                    {
                                 e.setPosition(x, y + 1.0F, z);
                                 world.spawnEntityInWorld(e);
                                 stack.stackSize–;
                                    }
                                else
                                {
                                 DataWatcher dw = e.getDataWatcher();
                                 dw.updateObject(30, "Moto");
                                }
                                    return true;
                              }
                              else if(metadata == 1)
                              {
                              EntityMoto e = new EntityMoto(world);
                                if(!world.isRemote)
                                    {
                              :::
                              
                                 e.setPosition(x, y + 1.0F, z);
                                 world.spawnEntityInWorld(e);
                                 stack.stackSize--;
                                    }
                                else
                                {
                                 DataWatcher dw = e.getDataWatcher();
                                 dw.updateObject(30, "Moto1");
                                }
                                    return true;
                              }
                              

                              Que j’ai bien rafraichis mes fichiers de textures et qu’elle sont très facilement différenciable (simplement la palette de couleur opposée)

                              1 réponse Dernière réponse Répondre Citer 0
                              • DiabolicaTrix
                                DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par

                                C’est étange, tu peux renvoyer tes code (render+EntityMoto surtout)

                                1 réponse Dernière réponse Répondre Citer 0
                                • Folgansky
                                  Folgansky Correcteurs dernière édition par

                                  Les voici, je te préviens, la classe de la moto est une jungle je pense.

                                  :::

                                  package fr.powergame.modpg.common;
                                  
                                  import java.util.Iterator;
                                  import java.util.List;
                                  
                                  import net.minecraft.block.Block;
                                  import net.minecraft.block.material.Material;
                                  import net.minecraft.entity.Entity;
                                  import net.minecraft.entity.EntityAgeable;
                                  import net.minecraft.entity.IEntityLivingData;
                                  import net.minecraft.entity.SharedMonsterAttributes;
                                  import net.minecraft.entity.item.EntityItem;
                                  import net.minecraft.entity.passive.EntityHorse;
                                  import net.minecraft.entity.player.EntityPlayer;
                                  import net.minecraft.init.Blocks;
                                  import net.minecraft.init.Items;
                                  import net.minecraft.item.Item;
                                  import net.minecraft.item.ItemArmor;
                                  import net.minecraft.item.ItemStack;
                                  import net.minecraft.item.ItemSword;
                                  import net.minecraft.stats.AchievementList;
                                  import net.minecraft.util.DamageSource;
                                  import net.minecraft.util.MathHelper;
                                  import net.minecraft.world.World;
                                  
                                  public  class EntityMoto extends EntityHorse
                                  {
                                  @SuppressWarnings("unused")
                                  private boolean field_110294_bI;
                                  private int field_110285_bP;
                                      @SuppressWarnings("unused")
                                  private boolean persistenceRequired;
                                  public EntityMoto(World model)
                                  {
                                      super(model);
                                      }
                                  
                                  public int getHorseType()
                                      {
                                          return 0;
                                      }
                                  
                                      public boolean isAdultHorse()
                                      {
                                          return true;
                                      }
                                  
                                      public int getGrowingAge()
                                      {
                                          return 12000;
                                      }
                                  
                                  public double getMountedYOffset()
                                      {
                                          return (double)this.height * 0.5D;
                                      } 
                                  
                                      protected void applyEntityAttributes()
                                      {
                                          super.applyEntityAttributes();
                                          this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
                                      }
                                  
                                  public boolean isEntityInvulnerable()
                                      {
                                          return true;
                                      }
                                  
                                  public void setJumpPower(int p_110206_1_)
                                      {
                                          if (this.isHorseSaddled())
                                          {
                                              if (p_110206_1_ < 0)
                                              {
                                                  p_110206_1_ = 0;
                                              }
                                              else
                                              {
                                                  this.field_110294_bI = true;
                                              }
                                  
                                              if (p_110206_1_ >= 90)
                                              {
                                                  this.jumpPower = 0.0F;
                                              }
                                              else
                                              {
                                                  this.jumpPower = 0.0F + 0.0F * (float)p_110206_1_ / 90.0F;
                                              }
                                          }
                                      }
                                  
                                  @SuppressWarnings("rawtypes")
                                  public void onLivingUpdate()
                                      {
                                  if(this.ticksExisted>=12000)
                                  {
                                  this.setDead();
                                  }
                                  else if (this.riddenByEntity == null)
                                      {
                                      motionX = motionY = motionZ = 0.0F;
                                      }
                                      else
                                      {
                                      super.onLivingUpdate();
                                             this.worldObj.theProfiler.startSection("looting");
                                  
                                             if (!this.worldObj.isRemote && this.canPickUpLoot() && !this.dead && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"))
                                             {
                                                 List list = this.worldObj.getEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(1.0D, 0.0D, 1.0D));
                                                 Iterator iterator = list.iterator();
                                  
                                                 while (iterator.hasNext())
                                                 {
                                                     EntityItem entityitem = (EntityItem)iterator.next();
                                  
                                                     if (!entityitem.isDead && entityitem.getEntityItem() != null)
                                                     {
                                                         ItemStack itemstack = entityitem.getEntityItem();
                                                         int i = getArmorPosition(itemstack);
                                  
                                                         if (i > -1)
                                                         {
                                                             boolean flag = true;
                                                             ItemStack itemstack1 = this.getEquipmentInSlot(i);
                                  
                                                             if (itemstack1 != null)
                                                             {
                                                                 if (i == 0)
                                                                 {
                                                                     if (itemstack.getItem() instanceof ItemSword && !(itemstack1.getItem() instanceof ItemSword))
                                                                     {
                                                                         flag = true;
                                                                     }
                                                                     else if (itemstack.getItem() instanceof ItemSword && itemstack1.getItem() instanceof ItemSword)
                                                                     {
                                                                         ItemSword itemsword = (ItemSword)itemstack.getItem();
                                                                         ItemSword itemsword1 = (ItemSword)itemstack1.getItem();
                                  
                                                                         if (itemsword.func_150931_i() == itemsword1.func_150931_i())
                                                                         {
                                                                             flag = itemstack.getItemDamage() > itemstack1.getItemDamage() || itemstack.hasTagCompound() && !itemstack1.hasTagCompound();
                                                                         }
                                                                         else
                                                                         {
                                                                             flag = itemsword.func_150931_i() > itemsword1.func_150931_i();
                                                                         }
                                                                     }
                                                                     else
                                                                     {
                                                                         flag = false;
                                                                     }
                                                                 }
                                                                 else if (itemstack.getItem() instanceof ItemArmor && !(itemstack1.getItem() instanceof ItemArmor))
                                                                 {
                                                                     flag = true;
                                                                 }
                                                                 else if (itemstack.getItem() instanceof ItemArmor && itemstack1.getItem() instanceof ItemArmor)
                                                                 {
                                                                     ItemArmor itemarmor = (ItemArmor)itemstack.getItem();
                                                                     ItemArmor itemarmor1 = (ItemArmor)itemstack1.getItem();
                                  
                                                                     if (itemarmor.damageReduceAmount == itemarmor1.damageReduceAmount)
                                                                     {
                                                                         flag = itemstack.getItemDamage() > itemstack1.getItemDamage() || itemstack.hasTagCompound() && !itemstack1.hasTagCompound();
                                                                     }
                                                                     else
                                                                     {
                                                                         flag = itemarmor.damageReduceAmount > itemarmor1.damageReduceAmount;
                                                                     }
                                                                 }
                                                                 else
                                                                 {
                                                                     flag = false;
                                                                 }
                                                             }
                                  
                                                             if (flag)
                                                             {
                                                                 if (itemstack1 != null && this.rand.nextFloat() - 0.1F < this.equipmentDropChances*)
                                                                 {
                                                                     this.entityDropItem(itemstack1, 0.0F);
                                                                 }
                                  
                                                                 if (itemstack.getItem() == Items.diamond && entityitem.func_145800_j() != null)
                                                                 {
                                                                     EntityPlayer entityplayer = this.worldObj.getPlayerEntityByName(entityitem.func_145800_j());
                                  
                                                                     if (entityplayer != null)
                                                                     {
                                                                         entityplayer.triggerAchievement(AchievementList.field_150966_x);
                                                                     }
                                                                 }
                                  
                                                                 this.setCurrentItemOrArmor(i, itemstack);
                                                                 this.equipmentDropChances* = 2.0F;
                                                                 this.persistenceRequired = true;
                                                                 this.onItemPickup(entityitem, 1);
                                                                 entityitem.setDead();
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                  
                                             this.worldObj.theProfiler.endSection();
                                      }
                                      }
                                  
                                      public IEntityLivingData onSpawnWithEgg(IEntityLivingData p_110161_1_)
                                      {
                                          Object p_110161_1_1 = super.onSpawnWithEgg(p_110161_1_);
                                  @SuppressWarnings("unused")
                                  boolean flag = false;
                                          int i = 0;
                                          int l;
                                  
                                          if (p_110161_1_1 instanceof EntityHorse.GroupData)
                                          {
                                              l = ((EntityHorse.GroupData)p_110161_1_1).field_111107_a;
                                              i = ((EntityHorse.GroupData)p_110161_1_1).field_111106_b & 255 | this.rand.nextInt(5) << 8;
                                          }
                                          else
                                          {
                                              if (this.rand.nextInt(10) == 0)
                                              {
                                                  l = 1;
                                              }
                                              else
                                              {
                                                  int j = this.rand.nextInt(7);
                                                  int k = this.rand.nextInt(5);
                                                  l = 0;
                                                  i = j | k << 8;
                                              }
                                  
                                              p_110161_1_1 = new EntityHorse.GroupData(l, i);
                                          }
                                  
                                          this.setHorseType(l);
                                          this.setHorseVariant(i);
                                  
                                          if (this.rand.nextInt(5) == 0)
                                          {
                                              this.setGrowingAge(-24000);
                                          }
                                          else
                                          {
                                              this.getEntityAttribute(SharedMonsterAttributes.maxHealth);
                                              this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2D );
                                          }
                                  
                                          this.setHealth(this.getMaxHealth());
                                          return (IEntityLivingData)p_110161_1_1;
                                      }
                                  
                                      public boolean hasCustomNameTag()
                                      {
                                          return false;
                                      }
                                  
                                      public boolean shouldExecute()
                                      {
                                          return false;
                                      }
                                  
                                  protected boolean isMovementCeased()
                                      {
                                          return true;
                                      }
                                  
                                      protected boolean isAIEnabled()
                                      {
                                      if (this.riddenByEntity == null)
                                      {
                                      return false;
                                      }
                                          return true;
                                      } 
                                  
                                      public float getAIMoveSpeed()
                                      {
                                          return 0.5F;
                                      }
                                  
                                  public boolean canBeSteered()
                                      {
                                          return true;
                                      }
                                  
                                      public boolean isHorseSaddled()
                                      {
                                          return true;
                                      }
                                  
                                  public boolean isTame()
                                      {
                                          return true;
                                      }
                                  
                                      public boolean isChested()
                                      {
                                          return false;
                                      }
                                  
                                      public boolean isEatingHaystack()
                                      {
                                          return false;
                                      }
                                  
                                      public boolean isRearing()
                                      {
                                          return false;
                                      }
                                  
                                      public boolean func_110205_ce()
                                      {
                                          return false;
                                      }
                                  
                                      public boolean allowLeashing()
                                      {
                                          return false;
                                      }
                                  
                                      public boolean canBePushed()
                                      {
                                          return true;
                                      }
                                  
                                      public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
                                      {
                                          Entity entity = p_70097_1_.getEntity();
                                          return this.riddenByEntity != null && this.riddenByEntity.equals(entity) ? false : super.attackEntityFrom(p_70097_1_, p_70097_2_);
                                      }
                                  
                                      protected Item getDropItem()
                                      {
                                          return null;
                                      }
                                  
                                      protected float getSoundVolume()
                                      {
                                          return 0.0F;
                                      }
                                  
                                      public boolean canBreatheUnderwater()
                                      {
                                          return false;
                                      }
                                  
                                      protected int getExperiencePoints(EntityPlayer p_70693_1_)
                                      {
                                              return this.experienceValue = 0;
                                      }
                                  
                                      public void openGUI(EntityPlayer p_110199_1_)
                                      {
                                          if (!this.worldObj.isRemote && (this.riddenByEntity == null || this.riddenByEntity == p_110199_1_) && this.isTame() && p_110199_1_.inventory.getCurrentItem() == null)
                                          {
                                          worldObj.playSoundAtEntity(this, "modpg:klaxonMoto", 1.0F, 1.0F);
                                          }
                                      }
                                  
                                      protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_)
                                      {
                                          Block.SoundType soundtype = p_145780_4_.stepSound;
                                          if (this.worldObj.getBlock(p_145780_1_, p_145780_2_ + 1, p_145780_3_) == Blocks.snow_layer)
                                          {
                                              soundtype = Blocks.snow_layer.stepSound;
                                          }
                                  
                                          if (!p_145780_4_.getMaterial().isLiquid())
                                          {
                                              int l = this.getHorseType();
                                  
                                              if (this.riddenByEntity != null && l != 1 && l != 2)
                                              {
                                                  ++this.field_110285_bP;
                                  
                                                  if (this.field_110285_bP > 5 && this.field_110285_bP % 3 == 0)
                                                  {
                                                      if (l == 0 && this.rand.nextInt(10) == 0)
                                                      {
                                                          this.playSound("modpg:moto1", soundtype.getVolume() * 0.6F, soundtype.getPitch());
                                                      }
                                                  }
                                              }
                                          }
                                      }
                                  
                                      protected void fall(float p_70069_1_)
                                      {
                                          if (p_70069_1_ > 1.0F)
                                          {
                                          this.playSound("modpg:chute", 0.4F, 1.0F);
                                          }
                                  
                                          int i = MathHelper.ceiling_float_int(p_70069_1_ * 0.5F - 3.0F);
                                  
                                          if (i > 0)
                                          {
                                              this.attackEntityFrom(DamageSource.fall, (float)i);
                                  
                                              if (this.riddenByEntity != null)
                                              {
                                                  this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float)i);
                                              }
                                  
                                              Block block = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY - 0.2D - (double)this.prevRotationYaw), MathHelper.floor_double(this.posZ));
                                  
                                              if (block.getMaterial() != Material.air)
                                              {
                                                  Block.SoundType soundtype = block.stepSound;
                                                  this.worldObj.playSoundAtEntity(this, soundtype.getStepResourcePath(), soundtype.getVolume() * 0.0F, soundtype.getPitch() * 0.0F);
                                              }
                                          }
                                      }    
                                  
                                  public boolean interact(EntityPlayer par1EntityPlayer)
                                    {
                                        if (super.interact(par1EntityPlayer) && par1EntityPlayer.inventory.getCurrentItem() == null)
                                        {
                                        worldObj.playSoundAtEntity(this, "modpg:davidson", 1.0F, 1.0F);
                                        par1EntityPlayer.mountEntity(this);
                                        return true;
                                        }
                                        return false;
                                    }
                                  
                                  @Override
                                  public EntityAgeable createChild(EntityAgeable p_90011_1_)
                                  {
                                  return null;
                                  }
                                  }
                                  

                                  :::

                                  :::

                                  package fr.powergame.modpg.common;
                                  
                                  import net.minecraft.client.model.ModelBase;
                                  import net.minecraft.client.renderer.entity.RenderLiving;
                                  import net.minecraft.entity.DataWatcher;
                                  import net.minecraft.entity.Entity;
                                  import net.minecraft.util.ResourceLocation;
                                  
                                  public class RenderMoto extends RenderLiving
                                  {
                                      public RenderMoto(ModelBase model, float shadow)
                                      {
                                          super(model, shadow);
                                      }
                                  
                                  private ResourceLocation getMotoTexture(EntityMoto moto)
                                      {
                                  DataWatcher dw = moto.getDataWatcher();
                                     return new ResourceLocation("Modpg:textures/entity/" + dw.getWatchableObjectString(30) + ".png");
                                      }
                                  
                                      @Override
                                      protected ResourceLocation getEntityTexture(Entity entity)
                                      {
                                          return this.getMotoTexture((EntityMoto)entity);
                                      }
                                  }
                                  

                                  :::

                                  Ps: Pas taper.

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • DiabolicaTrix
                                    DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par

                                    Es-tu sur que la texture existe? Au pire fais un System.out.println(dw.getWatchableObjectString(30)) pour voir si ça donne bien moto.

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • Folgansky
                                      Folgansky Correcteurs dernière édition par

                                      Ouaip niveau des textures je suis sûr que tout est bon. Fichier entity, textures: Moto et Moto1

                                      Pour le println metadata 0 me donne Moto
                                                           metadata 1 me donne Moto1

                                      Donc là je vois pas.
                                      Le problème ne vient pas du fait que le render renvoie toujours à Moto? (Mec qui gratte au risque de dire une bêtise)

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • DiabolicaTrix
                                        DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par

                                        Par contre personellement mon ressource location ressemble à ça: new ResourceLocation(“t4pro”, “textures/entity/steve.png”);

                                        Donc essaie: return new RessourceLocation(“Modpg”, “textures/entity/Moto.png”

                                        1 réponse Dernière réponse Répondre Citer 0
                                        • Folgansky
                                          Folgansky Correcteurs dernière édition par

                                          Avec

                                          return new ResourceLocation("Modpg:textures/entity/" + dw.getWatchableObjectString(30) + ".png");
                                          

                                          ou

                                          return new ResourceLocation("Modpg", ":textures/entity/" + dw.getWatchableObjectString(30) + ".png");
                                          

                                          mes entités ont une texture, la même, c’est à dire “Moto”.

                                          Edit:

                                          avec

                                           return new ResourceLocation("Modpg", "textures/entity/" + dw.getWatchableObjectString(30) + ".png");
                                          

                                          aucune texture trouvée

                                          Edit:
                                          PAR CONTRE
                                          dans l’event handler quand je mets Moto1 ça me met la texture Moto1 pour les deux.
                                          A toi de me dire ce que t’en penses =d

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • DiabolicaTrix
                                            DiabolicaTrix Correcteurs Moddeurs confirmés dernière édition par

                                            Et bien dans ce cas, ça veut dire que le datawatcher n’est pas updaté. essaie de mettre un sysout dans le dw.update.

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

                                            MINECRAFT FORGE FRANCE © 2018

                                            Powered by NodeBB