-
J’ai essayer plein de trucs mais je ne vois pas comment faire la

-
La réponse est pourtant si évidente …
protected ResourceLocation getAssassinTexture(EntityAssassin assassin) { return EntityAssassin.skins[assassin.currentSkin]; }Tu as l’instance de la classe directement en argument, sous le nom de
assassin. Suffit donc de l’utiliser … -
bonsoir, pendant la journée j’ai changer pas mal le code.
Je me suis inspiré des ocelots et j’en suis arrivé à ça: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(); } public void setAssassinSkin(int skinId) { this.dataManager.set(ASSASSIN_VARIANT, Integer.valueOf(skinId)); } protected void entityInit() { super.entityInit(); this.dataManager.register(ASSASSIN_VARIANT, Integer.valueOf(0)); }Et dans la classe du rendu:
package fr.hugo.hostile.renders; import fr.hugo.hostile.Reference; import fr.hugo.hostile.entity.EntityAssassin; import fr.hugo.hostile.models.ModelAssassin; import net.minecraft.client.model.ModelBiped; 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.minecraftforge.fml.relauncher.SideOnly; public class RenderAssassin extends RenderBiped { public static final ResourceLocation ASSASSIN1_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin1.png"); public static final ResourceLocation ASSASSIN2_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin2.png"); public static final ResourceLocation ASSASSIN3_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin3.png"); public static final ResourceLocation ASSASSIN4_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin4.png"); public static final ResourceLocation ASSASSIN5_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin5.png"); public RenderAssassin(RenderManager renderManagerIn) { super(renderManagerIn, new ModelBiped(), 0.5F); this.addLayer(new LayerHeldItem(this)); } protected ResourceLocation getAssassinTexture(EntityAssassin assassin) { switch (assassin.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; } } }Mais j’obtiens une entité avec ce skin :

-
C’est parce qu’il te manque cette fonction :
protected ResourceLocation getEntityTexture(Entity entity) { return this.getAssassinTexture((EntityAssassin)entity); } -
@robin4002 a dit dans [1.12.2] Textures random pour un mob :
protected ResourceLocation getEntityTexture(Entity entity)
Merci de ta réponse.
Voici le code actuellement.
package fr.hugo.hostile.renders; import fr.hugo.hostile.Reference; import fr.hugo.hostile.entity.EntityAssassin; import fr.hugo.hostile.models.ModelAssassin; import net.minecraft.client.model.ModelBiped; 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.minecraftforge.fml.relauncher.SideOnly; public class RenderAssassin extends RenderBiped { public static final ResourceLocation ASSASSIN1_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin1.png"); public static final ResourceLocation ASSASSIN2_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin2.png"); public static final ResourceLocation ASSASSIN3_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin3.png"); public static final ResourceLocation ASSASSIN4_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin4.png"); public static final ResourceLocation ASSASSIN5_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin5.png"); public RenderAssassin(RenderManager renderManagerIn) { super(renderManagerIn, new ModelBiped(), 0.5F); this.addLayer(new LayerHeldItem(this)); } protected ResourceLocation getAssassinTexture(EntityAssassin assassin) { switch (assassin.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; } } protected ResourceLocation getEntityTexture(Entity entity) { return this.getAssassinTexture((EntityAssassin)entity); } }Je n’ai plus le problème que j’ai rencontré sur la vidéo.
Cependant, j’ai beau faire spawner autant d’entités que je veux, toute les entités ont la meme texture (la 1ere texture pour etre exact) -
Car le
defaultest mal placé dans ton code.
Il devrait être à la fin. -
Ce message a été supprimé ! -
@robin4002 J’ai fait comme tu as dit. J’ai mit le default a la fin. Mais comme à la fin il y avait la dernière texture (texture 5). Mes mobs avaient tous la 5e texture.
J’ai essayé en prenant modèle sur les perroquets.
Ca donne ça dans la classe de l’entité:private static final DataParameter<Integer> ASSASSIN_VARIANT = EntityDataManager.<Integer>createKey(EntityAssassin.class, DataSerializers.VARINT); public int getVariant() { return MathHelper.clamp(((Integer)this.dataManager.get(ASSASSIN_VARIANT)).intValue(), 0, 5); } protected void entityInit() { super.entityInit(); this.dataManager.register(ASSASSIN_VARIANT, Integer.valueOf(0)); }Et sa donne ça dans la classe du rendu:
package fr.hugo.hostile.renders; import fr.hugo.hostile.Reference; import fr.hugo.hostile.entity.EntityAssassin; import fr.hugo.hostile.models.ModelAssassin; import net.minecraft.client.model.ModelBiped; 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.passive.EntityOcelot; import net.minecraft.entity.passive.EntityParrot; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.SideOnly; public class RenderAssassin extends RenderLiving<EntityAssassin> { public static final ResourceLocation[] ASSASSINS_TEXTURES = new ResourceLocation[] {new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin1.png"), new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin2.png"), new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin3.png"), new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin4.png"), new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin5.png")}; public RenderAssassin(RenderManager renderManagerIn) { super(renderManagerIn, new ModelBiped(), 0.5F); this.addLayer(new LayerHeldItem(this)); } protected ResourceLocation getEntityTexture(EntityAssassin entity) { return ASSASSINS_TEXTURES[entity.getVariant()]; } }Avec ce code, j’obtient toujours des mobs avec la première texture

-
En fait le problème là c’est que tu n’as plus aucun random de fait, donc entity.getVariant() renvoie toujours la même valeur.
-
Merci!!
J’ai enfin réussi. Désolé pour avoir un niveau minable @robin4002

Pour ceux qui veulent avoir des textures random pour leur mobs:A ajouter dans la classe Entité:
private static final DataParameter<Integer> ASSASSIN_VARIANT = EntityDataManager.<Integer>createKey(EntityAssassin.class, DataSerializers.VARINT); public int getVariant() { return MathHelper.clamp(((Integer)this.dataManager.get(ASSASSIN_VARIANT)).intValue(), 0, 4); } public void setVariant(int p_191997_1_) { this.dataManager.set(ASSASSIN_VARIANT, Integer.valueOf(p_191997_1_)); } protected void entityInit() { super.entityInit(); this.dataManager.register(ASSASSIN_VARIANT, Integer.valueOf(0)); }@Override public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); this.setVariant(this.rand.nextInt(5)); this.setEquipmentBasedOnDifficulty(difficulty); return livingdata; }Et dans la classe du Rendu:
package fr.hugo.hostile.renders; import fr.hugo.hostile.Reference; import fr.hugo.hostile.entity.EntityAssassin; import fr.hugo.hostile.models.ModelAssassin; import net.minecraft.client.model.ModelBiped; 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.passive.EntityOcelot; import net.minecraft.entity.passive.EntityParrot; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.SideOnly; public class RenderAssassin extends RenderLiving<EntityAssassin> { public static final ResourceLocation[] ASSASSINS_TEXTURES = new ResourceLocation[] {new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin1.png"), new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin2.png"), new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin3.png"), new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin4.png"), new ResourceLocation(Reference.MOD_ID + ":textures/humans/assassin5.png")}; public RenderAssassin(RenderManager renderManagerIn) { super(renderManagerIn, new ModelBiped(), 0.5F); this.addLayer(new LayerHeldItem(this)); } protected ResourceLocation getEntityTexture(EntityAssassin entity) { return ASSASSINS_TEXTURES[entity.getVariant()]; } }Merci beaucoup!