Jump to content

Trouble rendering mobs


whaling123

Recommended Posts

I have been having problems with getting my mob to show up i have tried very many things (all that i can think of) if anyone can help me that would be great

 

BOV6plg.png

 

Entity Class

 

package testing.models;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class EntityRedChicken extends EntityAnimal
{
    public float field_70886_e;
    public float destPos;
    public float field_70884_g;
    public float field_70888_h;
    public float field_70889_i = 1.0F;

    /** The time until the next egg is spawned. */
    public int timeUntilNextEgg;
private String texture;

    public EntityRedChicken(World par1World)
    {
        super(par1World);
        this.texture = "/mods/redchiken2.png";
        this.setSize(0.3F, 0.7F);
        this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIPanic(this, 1.4D));
        this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
        this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Item.seeds.itemID, false));
        this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
        this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(7, new EntityAILookIdle(this));
    }

    /**
     * Returns true if the newer Entity AI code should be run
     */
    public boolean isAIEnabled()
    {
        return true;
    }

    protected void func_110147_ax()
    {
        super.func_110147_ax();
        this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(4.0D);
        this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.25D);
    }

    /**
     * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
     * use this to react to sunlight and start to burn.
     */
    public void onLivingUpdate()
    {
        super.onLivingUpdate();
        this.field_70888_h = this.field_70886_e;
        this.field_70884_g = this.destPos;
        this.destPos = (float)((double)this.destPos + (double)(this.onGround ? -1 : 4) * 0.3D);

        if (this.destPos < 0.0F)
        {
            this.destPos = 0.0F;
        }

        if (this.destPos > 1.0F)
        {
            this.destPos = 1.0F;
        }

        if (!this.onGround && this.field_70889_i < 1.0F)
        {
            this.field_70889_i = 1.0F;
        }

        this.field_70889_i = (float)((double)this.field_70889_i * 0.9D);

        if (!this.onGround && this.motionY < 0.0D)
        {
            this.motionY *= 0.6D;
        }

        this.field_70886_e += this.field_70889_i * 2.0F;

        if (!this.isChild() && !this.worldObj.isRemote && --this.timeUntilNextEgg <= 0)
        {
            this.playSound("mob.chicken.plop", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
            this.dropItem(Item.egg.itemID, 1);
            this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
        }
    }

    /**
     * Called when the mob is falling. Calculates and applies fall damage.
     */
    protected void fall(float par1) {}

    /**
     * Returns the sound this mob makes while it's alive.
     */
    protected String getLivingSound()
    {
        return "mob.chicken.say";
    }

    /**
     * Returns the sound this mob makes when it is hurt.
     */
    protected String getHurtSound()
    {
        return "mob.chicken.hurt";
    }

    /**
     * Returns the sound this mob makes on death.
     */
    protected String getDeathSound()
    {
        return "mob.chicken.hurt";
    }

    /**
     * Plays step sound at given x, y, z for the entity
     */
    protected void playStepSound(int par1, int par2, int par3, int par4)
    {
        this.playSound("mob.chicken.step", 0.15F, 1.0F);
    }

    /**
     * Returns the item ID for the item the mob drops on death.
     */
    protected int getDropItemId()
    {
        return Item.feather.itemID;
    }

    /**
     * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param
     * par2 - Level of Looting used to kill this mob.
     */
    protected void dropFewItems(boolean par1, int par2)
    {
        int j = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);

        for (int k = 0; k < j; ++k)
        {
            this.dropItem(Item.feather.itemID, 1);
        }
        for (int k = 1; k < j; ++k)
        {
        	this.dropItem(Item.redstone.itemID, 6);
        }

        if (this.isBurning())
        {
            this.dropItem(Item.chickenCooked.itemID, 1);
        }
        else
        {
            this.dropItem(Item.chickenRaw.itemID, 1);
        }
    }

    /**
     * This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
     */
    public EntityRedChicken spawnBabyAnimal(EntityAgeable par1EntityAgeable)
    {
        return new EntityRedChicken(this.worldObj);
    }

    /**
     * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
     * the animal type)
     */
    public boolean isBreedingItem(ItemStack par1ItemStack)
    {
        return par1ItemStack != null && par1ItemStack.getItem() instanceof ItemSeeds;
    }

    public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
    {
        return this.spawnBabyAnimal(par1EntityAgeable);
    }
}

 

Model Class

 

package testing.models;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelRedChicken extends ModelBase
{
  //fields
    ModelRenderer body;
    ModelRenderer wing_right;
    ModelRenderer wing_left;
    ModelRenderer head;
    ModelRenderer bill;
    ModelRenderer under_bill;
    ModelRenderer left_leg;
    ModelRenderer right_leg;
    ModelRenderer right_foot;
    ModelRenderer left_foot;
    ModelRenderer left_point;
    ModelRenderer right_point;
  
  public ModelRedChicken()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      body = new ModelRenderer(this, 0, 18);
      body.addBox(0F, 0F, 0F, 6, 6, ;
      body.setRotationPoint(-3F, 11F, -4F);
      body.setTextureSize(64, 32);
      body.mirror = true;
      setRotation(body, 0F, 0F, 0F);
      wing_right = new ModelRenderer(this, 41, 0);
      wing_right.addBox(0F, 0F, 0F, 1, 4, 6);
      wing_right.setRotationPoint(3F, 11F, -3F);
      wing_right.setTextureSize(64, 32);
      wing_right.mirror = true;
      setRotation(wing_right, 0F, 0F, 0F);
      wing_left = new ModelRenderer(this, 41, 0);
      wing_left.addBox(0F, 0F, 0F, 1, 4, 6);
      wing_left.setRotationPoint(-4F, 11F, -3F);
      wing_left.setTextureSize(64, 32);
      wing_left.mirror = true;
      setRotation(wing_left, 0F, 0F, 0F);
      head = new ModelRenderer(this, 41, 11);
      head.addBox(0F, 0F, 0F, 4, 6, 3);
      head.setRotationPoint(-2F, 8F, 3F);
      head.setTextureSize(64, 32);
      head.mirror = true;
      setRotation(head, 0F, 0F, 0F);
      bill = new ModelRenderer(this, 0, 11);
      bill.addBox(0F, 0F, 0F, 4, 2, 2);
      bill.setRotationPoint(-2F, 10F, 6F);
      bill.setTextureSize(64, 32);
      bill.mirror = true;
      setRotation(bill, 0F, 0F, 0F);
      under_bill = new ModelRenderer(this, 0, 7);
      under_bill.addBox(0F, 0F, 0F, 2, 2, 1);
      under_bill.setRotationPoint(-1F, 12F, 6F);
      under_bill.setTextureSize(64, 32);
      under_bill.mirror = true;
      setRotation(under_bill, 0F, 0F, 0F);
      left_leg = new ModelRenderer(this, 24, 9);
      left_leg.addBox(0F, 0F, 0F, 1, 5, 0);
      left_leg.setRotationPoint(1F, 17F, -1F);
      left_leg.setTextureSize(64, 32);
      left_leg.mirror = true;
      setRotation(left_leg, 0F, 0F, 0F);
      right_leg = new ModelRenderer(this, 24, 9);
      right_leg.addBox(0F, 0F, 0F, 1, 5, 0);
      right_leg.setRotationPoint(-2F, 17F, -1F);
      right_leg.setTextureSize(64, 32);
      right_leg.mirror = true;
      setRotation(right_leg, 0F, 0F, 0F);
      right_foot = new ModelRenderer(this, 20, 15);
      right_foot.addBox(0F, 0F, 0F, 3, 0, 2);
      right_foot.setRotationPoint(-3F, 21.9F, -1F);
      right_foot.setTextureSize(64, 32);
      right_foot.mirror = true;
      setRotation(right_foot, 0F, 0F, 0F);
      left_foot = new ModelRenderer(this, 20, 15);
      left_foot.addBox(0F, 0F, 0F, 3, 0, 2);
      left_foot.setRotationPoint(0F, 21.9F, -1F);
      left_foot.setTextureSize(64, 32);
      left_foot.mirror = true;
      setRotation(left_foot, 0F, 0F, 0F);
      left_point = new ModelRenderer(this, 24, 15);
      left_point.addBox(0F, 0F, 0F, 1, 0, 1);
      left_point.setRotationPoint(1F, 21.9F, 1F);
      left_point.setTextureSize(64, 32);
      left_point.mirror = true;
      setRotation(left_point, 0F, 0F, 0F);
      right_point = new ModelRenderer(this, 24, 15);
      right_point.addBox(0F, 0F, 0F, 1, 0, 1);
      right_point.setRotationPoint(-2F, 21.9F, 1F);
      right_point.setTextureSize(64, 32);
      right_point.mirror = true;
      setRotation(right_point, 0F, 0F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    body.render(f5);
    wing_right.render(f5);
    wing_left.render(f5);
    head.render(f5);
    bill.render(f5);
    under_bill.render(f5);
    left_leg.render(f5);
    right_leg.render(f5);
    right_foot.render(f5);
    left_foot.render(f5);
    left_point.render(f5);
    right_point.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  }

}

 

Render Class

 

package testing.renderers;

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 testing.models.EntityRedChicken;
import testing.models.ModelRedChicken;


public class RenderRedChicken extends RenderLiving
{

public RenderRedChicken(ModelBase par1ModelBase, float par2) {
	super(par1ModelBase, par2);
	model = ((ModelRedChicken)mainModel);
}

protected ModelRedChicken model;

public void func_177_a(EntityRedChicken entity, double par2, double par4, double par6, float par8, float par9){
	super.doRenderLiving(entity, par2, par4, par6, par8, par9);
}

public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9){
	func_177_a((EntityRedChicken)par1EntityLiving, par2, par4, par6, par8, par9);
}

public void dorender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){
	func_177_a((EntityRedChicken)par1Entity, par2, par4, par6, par8, par9);
}

@Override
protected ResourceLocation func_110775_a(Entity entity) {
	return null;
}

}

 

Main Class Edited

 

	public void mobs() {

	ModLoader.registerEntityID(EntityRedChicken.class, "Red Chicken", ModLoader.getUniqueEntityId());
	ModLoader.addSpawn(EntityRedChicken.class, 90, 6, 19, EnumCreatureType.creature, new BiomeGenBase[] {BiomeGenBase.plains});
}

public void AddRenderer(Map map){

	map.put(EntityRedChicken.class, new RenderRedChicken(new ModelRedChicken(), 10.0F));

}

 

 

Link to comment
Share on other sites

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.