Posted June 24, 201510 yr hi i'm trying to make a mob with multiple skins, like horse have. but when i try then i can't seem to let it work proper-ly. it just shifts between all the skins. Any suggestions? Source code Render Entity class package dk.MathiasVO053.RobinsamseCraft.entity; import java.util.Random; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; import dk.MathiasVO053.RobinsamseCraft.Strings; import dk.MathiasVO053.RobinsamseCraft.Model.modelButtMob; public class RenderButtMobRed extends RenderLiving { private static ResourceLocation texture1 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_blue.png"); private static ResourceLocation texture2 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_gray.png"); private static ResourceLocation texture3 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_green.png"); private static ResourceLocation texture4 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_lime.png"); private static ResourceLocation texture5 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_orange.png"); private static ResourceLocation texture6 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_pink.png"); private static ResourceLocation texture7 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_purple.png"); private static ResourceLocation texture8 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_red.png"); private ResourceLocation TE; protected modelButtMob modelEntity; public RenderButtMobRed(ModelBase par1ModelBase, float par2) { super(par1ModelBase, par2); modelEntity = ((modelButtMob) mainModel); } public void renderButt(entityButtMobRed entity, double x, double y, double z, float u, float v){ super.doRender(entity, x, y, z, u, v); } public void doRenderLiving(EntityLiving entityliving, double x, double y, double z, float u, float v){ renderButt((entityButtMobRed)entityliving, x, y, z, u, v); } public void doRender(Entity entity, double x, double y, double z, float u, float v){ renderButt((entityButtMobRed)entity, x, y, z, u, v); } int p1 = 9; private boolean l = true; private ResourceLocation p; protected ResourceLocation getEntityTexture(Entity entity){ Random r; r = new Random(); int rand = r.nextInt(; switch (rand) { case 1: default: TE = texture1; break; case 2: TE = texture2; break; case 3: TE = texture3; break; case 4: TE = texture4; break; case 5: TE = texture5; break; case 6: TE = texture6; break; case 7: TE = texture7; break; case 8: TE = texture8; } return TE; } }
June 24, 201510 yr You are randomly picking the texture each time the getTexture is called. What did you think would happen? Pick that random value in the initilization of the entity. Then check for the value in your render method and pick the right texture. That or just do all the texture stuff in the entity and just call the entity for the right texture. I've done both. Long time Bukkit & Forge Programmer Happy to try and help
June 25, 201510 yr Author hmm. i'm sorry but i don't think i understand. i've tried it but can't seem to get that working either. source code public class RenderButtMobRed extends RenderLiving { private static ResourceLocation texture1 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_blue.png"); private static ResourceLocation texture2 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_gray.png"); private static ResourceLocation texture3 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_green.png"); private static ResourceLocation texture4 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_lime.png"); private static ResourceLocation texture5 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_orange.png"); private static ResourceLocation texture6 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_pink.png"); private static ResourceLocation texture7 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_purple.png"); private static ResourceLocation texture8 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_red.png"); protected modelButtMob modelEntity; private int randText; private static int rendText(entityButtMobRed entity){ return entity.buttText(); } public RenderButtMobRed(ModelBase par1ModelBase, float par2) { super(par1ModelBase, par2); modelEntity = ((modelButtMob) mainModel); } public void renderButt(entityButtMobRed entity, double x, double y, double z, float u, float v){ super.doRender(entity, x, y, z, u, v); } public void doRenderLiving(EntityLiving entityliving, double x, double y, double z, float u, float v){ renderButt((entityButtMobRed)entityliving, x, y, z, u, v); } public void doRender(Entity entity, double x, double y, double z, float u, float v){ renderButt((entityButtMobRed)entity, x, y, z, u, v); } protected ResourceLocation getEntityTexture(Entity entity){ return this.rendText(entity) } } public class entityButtMobRed extends EntityAnimal{ private static int TE; public entityButtMobRed(World par1World) { super(par1World); this.setSize(0.5F, 0.4F); this.tasks.addTask(0, new EntityAIWander(this, 0.5D)); this.tasks.addTask(1, new EntityAIPanic(this, 1.0D)); this.tasks.addTask(2, new EntityAITempt(this, 0.7D, Items.beef, false)); this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D)); this.tasks.addTask(2, new EntityAIMate(this, 1.0D)); } public boolean isAIEnabled(){ return true; } protected void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(16.0F); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); } @Override public EntityAgeable createChild(EntityAgeable age) { return new entityButtMobRed(worldObj); } public boolean isBreedingItem(ItemStack item) { return item != null && item.getItem() == Main.RainbowPowder; } public static int buttText(){ Random r; r = new Random(); int rand = r.nextInt(; switch(rand){ case 1: TE = 1; break; case 2: TE = 2; break; case 3: TE = 3; break; case 4: TE = 4; break; case 5: TE = 5; break; case 6: TE = 6; break; case 7: TE = 7; break; case 8: TE = 8; } return TE; } }
June 25, 201510 yr Why don't you start your class with a capital letter? its sort of a convention to do so, and what he meant is that every time getEntityTexture() was being called, it was selecting a random number and changing your mobs skin to that
June 25, 201510 yr Author yes. I know that about the class names, but i've never really felt a need to do it. and i know about that texture thing. i just don't know how to fix it thanks :3
June 25, 201510 yr Author yes. but where do i find that. is it in the entity class, render entity class or Main modded class?
June 25, 201510 yr Author yes i know what i would call basic basic programming(i'm kind of a noob to java) end would you please tell me?
June 26, 201510 yr yes. but where do i find that. is it in the entity class, render entity class or Main modded class? It would be, as diesieben07 said, in the constructor of your entity class.
June 26, 201510 yr Author hmm. now i've tried that but i get an error and idk how to fix it source code package dk.MathiasVO053.RobinsamseCraft.entity; import java.util.Random; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; import dk.MathiasVO053.RobinsamseCraft.Strings; import dk.MathiasVO053.RobinsamseCraft.Model.modelButtMob; public class RenderButtMobRed extends RenderLiving { private static ResourceLocation texture1 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_blue.png"); private static ResourceLocation texture2 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_gray.png"); private static ResourceLocation texture3 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_green.png"); private static ResourceLocation texture4 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_lime.png"); private static ResourceLocation texture5 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_orange.png"); private static ResourceLocation texture6 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_pink.png"); private static ResourceLocation texture7 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_purple.png"); private static ResourceLocation texture8 = new ResourceLocation(Strings.MODID + ":" + "textures/model/numse_red.png"); private ResourceLocation TE; protected modelButtMob modelEntity; public RenderButtMobRed(ModelBase par1ModelBase, float par2) { super(par1ModelBase, par2); modelEntity = ((modelButtMob) mainModel); } public void renderButt(entityButtMobRed entity, double x, double y, double z, float u, float v){ super.doRender(entity, x, y, z, u, v); } public void doRenderLiving(EntityLiving entityliving, double x, double y, double z, float u, float v){ renderButt((entityButtMobRed)entityliving, x, y, z, u, v); } public void doRender(Entity entity, double x, double y, double z, float u, float v){ renderButt((entityButtMobRed)entity, x, y, z, u, v); } private static void randT(entityButtMobRed entity){ entity.getButtText(); } private boolean l = true; private ResourceLocation p; protected ResourceLocation getEntityTexture(Entity entity){ switch(rand){ case 1: TE = texture1; break; case 2: TE = texture2; break; case 3: TE = texture3; break; case 4: TE = texture4; break; case 5: TE = texture5; break; case 6: TE = texture6; break; case 7: TE = texture7; break; case 8: TE = texture8; break; } return TE; } } package dk.MathiasVO053.RobinsamseCraft.entity; import java.util.Random; import dk.MathiasVO053.RobinsamseCraft.Main; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIFollowParent; import net.minecraft.entity.ai.EntityAIMate; import net.minecraft.entity.ai.EntityAIPanic; import net.minecraft.entity.ai.EntityAITempt; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class entityButtMobRed extends EntityAnimal{ public entityButtMobRed(World world) { super(world); this.setSize(0.5F, 0.4F); this.tasks.addTask(0, new EntityAIWander(this, 0.5D)); this.tasks.addTask(1, new EntityAIPanic(this, 1.0D)); this.tasks.addTask(2, new EntityAITempt(this, 0.7D, Items.beef, false)); this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D)); this.tasks.addTask(2, new EntityAIMate(this, 1.0D)); } public boolean isAIEnabled(){ return true; } public static Random getButtText(){ Random r; r = new Random(); int rand = r.nextInt(; return r; } protected void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(16.0F); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); } @Override public EntityAgeable createChild(EntityAgeable age) { return new entityButtMobRed(worldObj); } public boolean isBreedingItem(ItemStack item) { return item != null && item.getItem() == Main.RainbowPowder; } }
June 26, 201510 yr Author BTW i've all forgot to say this is for 1.7.10 not 1.8 thanks for the help everybody
June 26, 201510 yr Learn java. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.