Jump to content

Mob spawns as biped instead of custom model


Greenman284
 Share

Recommended Posts

Hey all,

 

So I've been trying to figure this out for about 3 days now, but I can't for the life of me fix it.  I've basically created a new mob (the Nutcracker), and I've created the model in Techne and exported it.  I've also created all of the necessary programs (EntityNutcracker, RenderNutcracker, and ModelNutcracker).  I've gotten to the point were I can have the mob spawn in the world naturally, but it spawns as a generic "steve" biped.  Below is the code for all of the different classes:

 

tutorial.generic:

 

package tutorial.generic;

 

import tutorial.generic.entity.EntityNutcracker;

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

import net.minecraft.entity.EntityEggInfo;

import net.minecraft.entity.EntityList;

import net.minecraft.entity.EnumCreatureType;

import net.minecraft.world.biome.BiomeGenBase;

import cpw.mods.fml.client.registry.RenderingRegistry;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.Mod.PostInit;

import cpw.mods.fml.common.Mod.PreInit;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.EntityRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

@Mod(modid="Generic", name="Generic", version="0.0.0")

@NetworkMod(clientSideRequired=true, serverSideRequired=false)

public class Generic {

 

        // The instance of your mod that Forge uses.

        @Instance("Generic")

        public static Generic instance;

 

       

       

        // Says where the client and server 'proxy' code is loaded.

        @SidedProxy(clientSide="tutorial.generic.client.ClientProxy", serverSide="tutorial.generic.CommonProxy")

        public static CommonProxy proxy;

       

        @PreInit

        public void preInit(FMLPreInitializationEvent event) {

                // Stub Method

        }

       

        @Init

        public void load(FMLInitializationEvent event) {

                proxy.registerRenderers();

                EntityRegistry.registerModEntity(EntityNutcracker.class, "Nutcracker", 32, this, 25, 3, true);

                EntityRegistry.addSpawn(EntityNutcracker.class, 100, 15, 24, EnumCreatureType.monster, new BiomeGenBase[]{BiomeGenBase.plains, BiomeGenBase.forest});

           

        }

@PostInit

        public void postInit(FMLPostInitializationEvent event) {

                // Stub Method

        }

}

 

 

ModelNutcracker:

 

// Date: 04/06/2013 8:42:38 PM

// Template version 1.1

// Java generated by Techne

// Keep in mind that you still need to fill in some blanks

// - ZeuX

 

package tutorial.generic;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

 

public class ModelNutcracker extends ModelBase

{

  //fields

    ModelRenderer head;

    ModelRenderer body;

    ModelRenderer rightarm;

    ModelRenderer leftarm;

    ModelRenderer rightleg;

    ModelRenderer leftleg;

    ModelRenderer Hat;

 

  public ModelNutcracker()

  {

    textureWidth = 64;

    textureHeight = 32;

   

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

      head.addBox(-4F, -6F, -4F, 7, 11, 7);

      head.setRotationPoint(0.5F, 1F, 0.5F);

      head.setTextureSize(64, 32);

      head.mirror = true;

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

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

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

      body.setRotationPoint(0F, 2F, -2F);

      body.setTextureSize(64, 32);

      body.mirror = true;

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

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

      rightarm.addBox(-3F, -2F, -2F, 1, 7, 2);

      rightarm.setRotationPoint(-2F, 5F, 1F);

      rightarm.setTextureSize(64, 32);

      rightarm.mirror = true;

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

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

      leftarm.addBox(-1F, -2F, -2F, 1, 7, 2);

      leftarm.setRotationPoint(5F, 5F, 1F);

      leftarm.setTextureSize(64, 32);

      leftarm.mirror = true;

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

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

      rightleg.addBox(-2F, 0F, -2F, 1, 6, 2);

      rightleg.setRotationPoint(0F, 9F, 1F);

      rightleg.setTextureSize(64, 32);

      rightleg.mirror = true;

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

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

      leftleg.addBox(-2F, 0F, -2F, 1, 6, 2);

      leftleg.setRotationPoint(3F, 9F, 1F);

      leftleg.setTextureSize(64, 32);

      leftleg.mirror = true;

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

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

      Hat.addBox(0F, 0F, 0F, 8, 8, 8);

      Hat.setRotationPoint(-4F, -9F, -4F);

      Hat.setTextureSize(64, 32);

      Hat.mirror = true;

      setRotation(Hat, 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);

    head.render(f5);

    body.render(f5);

    rightarm.render(f5);

    leftarm.render(f5);

    rightleg.render(f5);

    leftleg.render(f5);

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

  }

 

}

 

 

 

EntityNutcracker:

 

package tutorial.generic.entity;

 

import net.minecraft.entity.EntityAgeable;

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.world.World;

 

 

 

//Your declaration. If your mob swims, change EntityAnimal to EntityWaterMob.

public class EntityNutcracker extends EntityAnimal {

       

        public EntityNutcracker(World par1World) {

                super(par1World);

                this.texture = "tutorial/generic/blanktexture/png";

                //The below means if possible, it wont walk into water

                this.getNavigator().setAvoidsWater(true);

                //This is the hitbox size. I believe it starts in the center and grows outwards

                this.setSize(1.5F, 0.9F);

                //Pretty self-explanatory.

                this.isImmuneToFire = false;

                float var2 = 0.25F;

 

                //Now, we have the AI. Each number in the addTask is a priority. 0 is the highest, the largest is lowest.

                //They should be set in the order which the mob should focus, because it can only do one thing at a time. I'll explain my choice for order below.

                //There are tonnes of tasks you can add. Look in the JavaDocs or other mob classes to find some more!

 

                //Swimming should ALWAYS be first. Otherwise if your mob falls in water, but it's running away from you or something it'll drown.

                this.tasks.addTask(0, new EntityAISwimming(this));

 

                //This makes the mob run away when you punch it

                this.tasks.addTask(1, new EntityAIPanic(this, 0.38F));

 

                //If you have mating code, this allows it to mate.

                this.tasks.addTask(2, new EntityAIMate(this, var2));

 

                //This code is used to get the mob to follow you (like cows with wheat). Here it's set to a custom fruit

                this.tasks.addTask(3, new EntityAITempt(this, 0.3F, Item.coal.itemID, false));

 

                //If the mob is a child, it will follow it's parent.

                this.tasks.addTask(4, new EntityAIFollowParent(this, 0.28F));

 

                //This makes the mob walk around. Without it, it'd just stand still.

                this.tasks.addTask(5, new EntityAIWander(this, var2));

 

                //This makes the mob watch the nearest player, within a range set by the float.

                this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));

 

                //Finally, this makes it look around when it's not looking at a player or wandering.

                this.tasks.addTask(7, new EntityAILookIdle(this));

        }

 

        //This is required. If it's false, none of the above takes effect.

        public boolean isAIEnabled() {

                return true;

        }

       

        //Pretty obvious, set it's health!

        public int getMaxHealth() {

                return 10;

        }

       

        //The sound effect played when it's just living, like a cow mooing.

        protected String getLivingSound() {

                return "mob.enderman.say";

        }

       

        //The sound made when it's attacked. Often it's the same as the normal say sound, but sometimes different (such as in the ender dragon)

        protected String getHurtSound() {

                return "mob.enderman.hit";

        }

       

        //The sound made when it actually dies.

        protected String getDeathSound() {

                return "mob.enderman.death";

        }

 

        //The sound the mob plays when walking around. 

        protected void playStepSound(int par1, int par2, int par3, int par4) {

                this.worldObj.playSoundAtEntity(this, "mob.enderman.step", 0.15F,  1.0F);

        }

       

        //A basic example of what a mob should drop on death. For more advanced examples, look at code for chicken or squid.

        protected int getDropItemId() {

                return Item.coal.itemID;

        }

       

        //This is required regardless of if your animal can breed or not. Set to null if it can't breed - I wont cover breeding here.

        public EntityAgeable createChild1(EntityAgeable var1) {

                return null;

        }

 

@Override

public EntityAgeable createChild(EntityAgeable entityageable) {

// TODO Auto-generated method stub

return null;

}

protected boolean isValidLightLevel()

{

    return true; //lets it spawn during the day

}

}

 

 

RenderNutcracker:

 

package tutorial.generic;

 

import tutorial.generic.entity.EntityNutcracker;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelEnderman;

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

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLiving;

 

@SideOnly(Side.CLIENT)

public class RenderNutcracker extends RenderLiving

{

        public RenderNutcracker(ModelNutcracker ModelNutcracker_Test, float f)

        {

                super(new ModelNutcracker(), 0.5F);

        }

        public RenderNutcracker(ModelBase par1ModelBase, float par2)

        {

                super(par1ModelBase, par2);

        }

        public void RenderNutcracker(EntityNutcracker par1EntityNutcracker, double par2, double par4, double par6, float par8, float par9)

        {

                super.doRenderLiving(par1EntityNutcracker, par2, par4, par6, par8, par9);

        }

        public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)

        {

                this.RenderNutcracker((EntityNutcracker)par1EntityLiving, par2, par4, par6, par8, par9);

        }

        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)

        {

                this.RenderNutcracker((EntityNutcracker)par1Entity, par2, par4, par6, par8, par9);

        }

}

 

 

ClientProxy:

 

package tutorial.generic.client;

 

import cpw.mods.fml.client.registry.RenderingRegistry;

import cpw.mods.fml.common.registry.EntityRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

import net.minecraftforge.client.MinecraftForgeClient;

import tutorial.generic.CommonProxy;

import tutorial.generic.ModelNutcracker;

import tutorial.generic.RenderNutcracker;

import tutorial.generic.entity.EntityNutcracker;

import net.minecraft.entity.EnumCreatureType;

import net.minecraft.world.biome.BiomeGenBase;

 

 

public class ClientProxy extends CommonProxy {

 

 

        @Override

        public void registerRenderThings() {

        RenderingRegistry.instance().registerEntityRenderingHandler(EntityNutcracker.class, new RenderNutcracker(new ModelNutcracker(), 0));

            EntityRegistry.registerGlobalEntityID(EntityNutcracker.class, "Nutcracker", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102);

                MinecraftForgeClient.preloadTexture(TEXTURE_NUTCRACKER);

        }

}

       

 

 

 

Any feedback on this would be greatly appreciated.

 

Greenman

Link to comment
Share on other sites

Bump, am I the only person with this problem? :\

 

Your ModelNutcracker class is outdated (I see it's generated through Techne), it doesn't override any method from the super class, namely the render(...) method. You should look at it, that's most likely your problem!

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Bump, am I the only person with this problem? :\

 

Your ModelNutcracker class is outdated (I see it's generated through Techne), it doesn't override any method from the super class, namely the render(...) method. You should look at it, that's most likely your problem!

 

I seem to be confused...do you mean the super.render method that is in the ModelNutcracker class?

Link to comment
Share on other sites

Bump, am I the only person with this problem? :\

 

Your ModelNutcracker class is outdated (I see it's generated through Techne), it doesn't override any method from the super class, namely the render(...) method. You should look at it, that's most likely your problem!

 

I seem to be confused...do you mean the super.render method that is in the ModelNutcracker class?

 

No I meant your own render method. It should override the super classes' render method. Look at this model file from one of my mods and look at your class in comparison (especially the render method):

https://github.com/SanAndreasP/TurretModv3/blob/master/sanandreasp/mods/TurretMod3/client/model/Model_MobileBase.java#L130-L152

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

No I meant your own render method. It should override the super classes' render method. Look at this model file from one of my mods and look at your class in comparison (especially the render method):

https://github.com/SanAndreasP/TurretModv3/blob/master/sanandreasp/mods/TurretMod3/client/model/Model_MobileBase.java#L130-L152

 

Strange, I can't see any difference in our code (other than you have additional parts for your model).

Link to comment
Share on other sites

Oh yeah, it's not different there. What i noticed though is you don't actually call the right method for registering your renderers:

tutorial.generic:

proxy.registerRenderers();

 

ClientProxy:

public void registerRenderThings() {

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Oh yeah, it's not different there. What i noticed though is you don't actually call the right method for registering your renderers:

tutorial.generic:

proxy.registerRenderers();

 

ClientProxy:

public void registerRenderThings() {

 

I see!  I just had to change the registerRenderThings to registerRenderers, and it used the model.  Now I just need to have it actually touching the ground :P (the model is smaller than a normal human, so it's just floating in the air)

 

Thank you very much for the help.

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
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.

 Share



×
×
  • Create New...

Important Information

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