Jump to content

Recommended Posts

Posted

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(8);

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;

}

}

Posted

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

Posted

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(8);

        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;

}

}

Posted

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

Posted

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(8);

        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;

    }

 

 

 

}

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.