Jump to content

Recommended Posts

Posted

I have two mobs one the CaveMan renders properly and the other one is just a white cube,

here are the the renders and models for my mobs and my client proxy

 

CaveMan Model:

package mymod.entity.CaveMan;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

import net.minecraft.entity.monster.EntityZombie;

import net.minecraft.util.math.MathHelper;

 

public class MyModelCaveMan extends ModelBase

{

  //fields

    ModelRenderer head;

    ModelRenderer body;

    ModelRenderer rightarm;

    ModelRenderer leftarm;

    ModelRenderer rightleg;

    ModelRenderer leftleg;

   

 

 

 

  public MyModelCaveMan()

  {

    textureWidth = 64;

    textureHeight = 32;

   

   

      head = new ModelRenderer(this, 0, 0);

      head.addBox(-4F, -7.5F, -4F, 8, 8, 8);

      head.setRotationPoint(0F, 0F, 0F);

      head.setTextureSize(64, 32);

      head.mirror = true;

      setRotation(head, 0.1047198F, 0F, 0F);

 

      body = new ModelRenderer(this, 32,0);

      body.addBox(-4F, 0F, -2F, 8, 12, 4);

      body.setRotationPoint(0F, 0.5F, 1F);

      body.setTextureSize(64, 32);

      body.mirror = true;

    setRotation(body, 0.296706F, 0F, 0F);

      rightarm = new ModelRenderer(this, 16, 16);

      rightarm.addBox(-3F, -2F, -2F, 4, 12, 4);

      rightarm.setRotationPoint(-5F, 3F, 0F);

      rightarm.setTextureSize(64, 32);

      rightarm.mirror = true;

      setRotation(rightarm, 0.3316126F, 0F, 0F);

      leftarm = new ModelRenderer(this, 16, 16);

      leftarm.addBox(-1F, -2F, -2F, 4, 12, 4);

      leftarm.setRotationPoint(5F, 2F, 0F);

      leftarm.setTextureSize(64, 32);

      leftarm.mirror = true;

      setRotation(leftarm, 0.3316126F, 0F, 0F);

      rightleg = new ModelRenderer(this, 0, 16);

      rightleg.addBox(-2F, 0F, -2F, 4, 12, 4);

      rightleg.setRotationPoint(-2F, 12F, 4F);

      rightleg.setTextureSize(64, 32);

      rightleg.mirror = true;

      setRotation(rightleg, 0F, 0F, 0F);

      leftleg = new ModelRenderer(this, 0, 16);

      leftleg.addBox(-2F, 0F, -2F, 4, 12, 4);

      leftleg.setRotationPoint(2F, 12F, 4F);

      leftleg.setTextureSize(64, 32);

      leftleg.mirror = true;

      setRotation(leftleg, 0F, 0F, 0F);

  }

  @Override

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

 

    head.render(f5);

    body.render(f5);

    rightarm.render(f5);

    leftarm.render(f5);

    rightleg.render(f5);

    leftleg.render(f5);

  }

 

  private void setRotation(ModelRenderer model, float x, float y, float z)

  {

    model.rotateAngleX = x;

    model.rotateAngleY = y;

    model.rotateAngleZ = z;

  }

  @Override

  public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)

  {

      super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);

      boolean flag = entityIn instanceof EntityZombie && ((EntityZombie)entityIn).isArmsRaised();

      float f = MathHelper.sin(this.swingProgress * (float)Math.PI);

      float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float)Math.PI);

      this.rightarm.rotateAngleZ = 0.0F;

      this.leftarm.rotateAngleZ = 0.0F;

      this.rightarm.rotateAngleY = -(0.1F - f * 0.6F);

      this.leftarm.rotateAngleY = 0.1F - f * 0.6F;

      float f2 = -(float)Math.PI / (flag ? 1.5F : 2.25F);

      this.rightarm.rotateAngleX = f2;

      this.leftarm.rotateAngleX = f2;

      this.rightarm.rotateAngleX += f * 1.2F - f1 * 0.4F;

      this.leftarm.rotateAngleX += f * 1.2F - f1 * 0.4F;

      this.rightarm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;

      this.leftarm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;

      this.rightarm.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F;

      this.leftarm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F;

  }

 

}

 

 

 

CaveManRender

package mymod.entity.CaveMan;

 

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.renderer.entity.RenderLiving;

import net.minecraft.client.renderer.entity.RenderManager;

import net.minecraft.entity.Entity;

import net.minecraft.util.ResourceLocation;

 

public class MyRenderCaveMan extends RenderLiving {

 

public MyRenderCaveMan(RenderManager renderManagerIn, ModelBase modelBaseIn, float shadowSizeIn)

    {

        super(renderManagerIn, modelBaseIn, shadowSizeIn);

    }

 

   

    protected ResourceLocation getEntityTexture(MyEntityCaveMan entity) {

        return new ResourceLocation("mymod:textures/entity/CaveMan.png");

 

    }

    @Override

    protected ResourceLocation getEntityTexture(Entity entity) {

        return this.getEntityTexture((MyEntityCaveMan)entity);

 

    }

 

}

 

 

 

my custom Creeper render

package mymod.CorruptedCreeper;

 

import mymod.entity.CaveMan.MyEntityCaveMan;

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelCreeper;

import net.minecraft.client.renderer.GlStateManager;

import net.minecraft.client.renderer.entity.RenderLiving;

import net.minecraft.client.renderer.entity.RenderManager;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.monster.EntitySlime;

import net.minecraft.util.ResourceLocation;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

 

import org.lwjgl.opengl.GL11;

 

public class CorruptedCreeperRender extends RenderLiving

{

    private static final ResourceLocation CreeperTextures = new ResourceLocation("mymod:textures/entity/CorruptedCreeper.png");

 

 

    public CorruptedCreeperRender(RenderManager renderManagerIn, ModelBase modelBaseIn, float shadowSizeIn)

    {

        super(renderManagerIn, modelBaseIn, shadowSizeIn);

       

    }

 

    protected ResourceLocation getEntityTexture(CorruptedCreeperEntity entity) {

        return CreeperTextures;

 

    }

    @Override

    protected ResourceLocation getEntityTexture(Entity entity) {

        return this.getEntityTexture((CorruptedCreeperEntity)entity);

 

    }

 

 

   

}

 

 

 

and the model

package mymod.CorruptedCreeper;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

import net.minecraft.util.math.MathHelper;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

 

public class CorruptedCreeperModel extends ModelBase

{

    public ModelRenderer head;

    public ModelRenderer field_78133_b;

    public ModelRenderer body;

    public ModelRenderer leg1;

    public ModelRenderer leg2;

    public ModelRenderer leg3;

    public ModelRenderer leg4;

 

    public CorruptedCreeperModel()

    {

        this(0.0F);

    }

 

    public CorruptedCreeperModel(float par1)

    {

        byte b0 = 4;

        this.head = new ModelRenderer(this, 0, 0);

        this.head.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1);

        this.head.setRotationPoint(0.0F, (float)b0, 0.0F);

        this.field_78133_b = new ModelRenderer(this, 32, 0);

        this.field_78133_b.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1 + 0.5F);

        this.field_78133_b.setRotationPoint(0.0F, (float)b0, 0.0F);

        this.body = new ModelRenderer(this, 16, 16);

        this.body.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1);

        this.body.setRotationPoint(0.0F, (float)b0, 0.0F);

        this.leg1 = new ModelRenderer(this, 0, 16);

        this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, par1);

        this.leg1.setRotationPoint(-2.0F, (float)(12 + b0), 4.0F);

        this.leg2 = new ModelRenderer(this, 0, 16);

        this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, par1);

        this.leg2.setRotationPoint(2.0F, (float)(12 + b0), 4.0F);

        this.leg3 = new ModelRenderer(this, 0, 16);

        this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, par1);

        this.leg3.setRotationPoint(-2.0F, (float)(12 + b0), -4.0F);

        this.leg4 = new ModelRenderer(this, 0, 16);

        this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, par1);

        this.leg4.setRotationPoint(2.0F, (float)(12 + b0), -4.0F);

    }

 

    /**

    * Sets the models various rotation angles then renders the model.

    */

    public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)

    {

        this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);

        this.head.render(par7);

        this.body.render(par7);

        this.leg1.render(par7);

        this.leg2.render(par7);

        this.leg3.render(par7);

        this.leg4.render(par7);

    }

 

    /**

    * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms

    * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how

    * "far" arms and legs can swing at most.

    */

    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)

    {

        this.head.rotateAngleY = par4 / (180F / (float)Math.PI);

        this.head.rotateAngleX = par5 / (180F / (float)Math.PI);

        this.leg1.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;

        this.leg2.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2;

        this.leg3.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2;

        this.leg4.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;

    }

}

 

 

 

ClientProxy

package mymod.proxies;

 

import mymod.CorruptedCreeper.CorruptedCreeperEntity;

import mymod.CorruptedCreeper.CorruptedCreeperModel;

import mymod.CorruptedCreeper.CorruptedCreeperRender;

import mymod.entity.CaveMan.MyEntityCaveMan;

import mymod.entity.CryoZombie.EntityCryZombie;

import mymod.entity.CryoZombie.RenderCryZombie;

import mymod.inti.ModBlocks;

import mymod.inti.ModEntities;

import mymod.inti.ModItems;

import mymod.model.ModelCorruptedCreeper;

import mymod.model.ModelEntityCaveMan;

import mymod.render.RenderEntityCaveMan;

import net.minecraft.client.Minecraft;

import net.minecraftforge.fml.client.registry.RenderingRegistry;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

 

public class ClientProxy extends CommonProxy

{

  @Override

public  void preInit( FMLPreInitializationEvent event )

{

  super.preInit(event);

  ModEntities.RegisterEntity();

}

 

  @Override

public  void init( FMLInitializationEvent event )

{

 

ModItems.registerRenders();

ModBlocks.registerRenders();

 

RenderingRegistry.registerEntityRenderingHandler(MyEntityCaveMan.class, new RenderEntityCaveMan(Minecraft.getMinecraft().getRenderManager(), new ModelEntityCaveMan(), 0));

RenderingRegistry.registerEntityRenderingHandler(CorruptedCreeperEntity.class, new CorruptedCreeperRender(Minecraft.getMinecraft().getRenderManager(), new ModelCorruptedCreeper(),0));

 

}

 

  @Override

public  void postInit( FMLPostInitializationEvent event )

{

super.postInit(event);

}

 

 

}

 

 

 

and finally where i register my entitys

package mymod.inti;

 

import java.util.BitSet;

 

import mymod.Main;

import mymod.CorruptedCreeper.CorruptedCreeperEntity;

import mymod.entity.CaveMan.MyEntityCaveMan;

import mymod.entity.CryoZombie.EntityCryZombie;

import net.minecraft.entity.EntityList;

import net.minecraftforge.fml.common.registry.EntityRegistry;

 

public class ModEntities {

 

public static final ModEntities INSTANCE = new ModEntities();

private BitSet avilbleIndicies;

 

private static ModEntities instance()

{

return INSTANCE;

 

 

}

 

private ModEntities()

{

avilbleIndicies = new BitSet(256);

avilbleIndicies.set(1,255);

for(Object id : EntityList.ID_TO_CLASS.keySet())

{

avilbleIndicies.clear((Integer)id);

 

}

 

}

 

public static int findGlobalUniqueEntityId()

{

int res = instance().avilbleIndicies.nextSetBit(0);

if(res < 0)

{

throw new RuntimeException("No entity indicies left");

 

}

return res;

 

}

 

public static void RegisterEntity()

{

CreateEntity(MyEntityCaveMan.class, "CaveMan",0x00f,0xd587f);

CreateEntity(CorruptedCreeperEntity.class,"CorruptedCreeper",0x05f,0xd787f);

 

}

 

public static void CreateEntity(Class entityClass, String entityName, int solidColor, int spotColor)

{

int randomid = findGlobalUniqueEntityId();

EntityRegistry.registerModEntity(entityClass, entityName, randomid, Main.modInstance, 64, 1, true, solidColor, spotColor);

}

 

}

 

 

also it seems since my creeper render doesn't work the game likes to render the creeper as the CaveMan.

 

if anyone could help, that would be great.

Posted

  • What the heck is that ID finding thing supposed to do? Just start at 0 and increase by one for every new entity.
  • The version of
    registerEntityRenderingHandler

    you are using is deprecated.

  • Are there any errors in the console? Are you sure it's the
    CorruptedCreeperEntity

    being spawned?

 

if I did it right the ID thing should make my entities compatible with other mods, so you don't get an error because matching ids

 

there are no errors in the console

 

yes my entity is being spawned

Posted

if I did it right the ID thing should make my entities compatible with other mods, so you don't get an error because matching ids

 

You don't have to. Every ID is unique to the mod, and every mod has their own set of unqiue IDs that will NEVER clash.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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