I've looked this over about a thousand times now and I just don't understand what's wrong. Basically, my mob is spawning as a Biped and not the custom model that I made in Techne. If anyone can help I'd really appreciate it.
Here's my code. (and yes, I am using addRender)
mod_ File
package net.minecraft.src;
import java.util.Map;
public class mod_boxmob extends BaseMod
{
@Override
public String getVersion() {
return "Tets";
}
public void addRenderer(Map map)
{
map.put(TRBLST_BoxEntity.class, new TRBLST_BoxRender(new TRBLST_BoxModel(), 0.5F));
}
ya the same thing is happening to me. My first custom monster uses its new model just fine, however the 2nd one iv made uses a biped model instead of the custom model. I copied what i did with my first monster but i still get a biped model.
I hope someone helps you because in turn they will help me too. I also have been working on this for hours and still its a biped model.
I too am having the same issue. I first tried creating an oversized custom mob, and it came out as a biped and of course screwed up the texture. I then created a smaller mob which fit inside the bipedal shape (just in case it was having trouble with such a large mob) and I've got the same behavior. In both instances the mobs render and behave as programmed, with the proper textures, but they all look like bipeds and not the custom models that I've designed.
The code below was for a 'test' mob I created after several failures. I mostly copied the creeper code.
Entity
package net.minecraft.src;
import java.util.Random;
public class EntityTowelie extends EntityMob
{
/**
* The amount of time since the creeper was close enough to the player to ignite
*/
int timeSinceIgnited;
/**
* Time when this creeper was last in an active state (Messed up code here, probably causes creeper animation to go
* weird)
*/
int lastActiveTime;
public EntityTowelie(World par1World)
{
super(par1World);
texture = "/mob/towelie.png";
tasks.addTask(1, new EntityAISwimming(this));
tasks.addTask(2, new EntityAIAvoidEntity(this, net.minecraft.src.EntityOcelot.class, 6F, 0.25F, 0.3F));
tasks.addTask(3, new EntityAIAttackOnCollide(this, 0.25F, false));
tasks.addTask(4, new EntityAIWander(this, 0.2F));
tasks.addTask(5, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 8F));
tasks.addTask(5, new EntityAILookIdle(this));
targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityPlayer.class, 16F, 0, true));
targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
if (dataWatcher.getWatchableObjectByte(17) == 1)
{
par1NBTTagCompound.setBoolean("powered", true);
}
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
dataWatcher.updateObject(17, Byte.valueOf((byte)(par1NBTTagCompound.getBoolean("powered") ? 1 : 0)));
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
if (isEntityAlive())
{
lastActiveTime = timeSinceIgnited;
int i = getTowelieState();
if (i > 0 && timeSinceIgnited == 0)
{
worldObj.playSoundAtEntity(this, "random.fuse", 1.0F, 0.5F);
}
timeSinceIgnited += i;
if (timeSinceIgnited < 0)
{
timeSinceIgnited = 0;
}
if (timeSinceIgnited >= 30)
{
timeSinceIgnited = 30;
if (!worldObj.isRemote)
{
if (getPowered())
{
worldObj.createExplosion(this, posX, posY, posZ, 6F);
}
else
{
worldObj.createExplosion(this, posX, posY, posZ, 3F);
}
setDead();
}
}
}
super.onUpdate();
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.creeper";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.creeperdeath";
}
/**
* Called when the mob's health reaches 0.
*/
public void onDeath(DamageSource par1DamageSource)
{
super.onDeath(par1DamageSource);
public boolean attackEntityAsMob(Entity par1Entity)
{
return true;
}
/**
* Returns true if the creeper is powered by a lightning bolt.
*/
public boolean getPowered()
{
return dataWatcher.getWatchableObjectByte(17) == 1;
}
/**
* Connects the the creeper flashes to the creeper's color multiplier
*/
public float setTowelieFlashTime(float par1)
{
return ((float)lastActiveTime + (float)(timeSinceIgnited - lastActiveTime) * par1) / 28F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return Item.gunpowder.shiftedIndex;
}
/**
* Returns the current state of creeper, -1 is idle, 1 is 'in fuse'
*/
public int getTowelieState()
{
return dataWatcher.getWatchableObjectByte(16);
}
/**
* Sets the state of creeper, -1 to idle and 1 to be 'in fuse'
*/
public void setTowelieState(int par1)
{
dataWatcher.updateObject(16, Byte.valueOf((byte)par1));
}
}
Model
package net.minecraft.src;
public class ModelTowelie extends ModelBase
{
//fields
ModelRenderer Shape1;
ModelRenderer Shape2;
ModelRenderer Shape3;
ModelRenderer Shape4;
ModelRenderer Shape5;
public ModelTowelie()
{
textureWidth = 64;
textureHeight = 32;
public class RenderTowelie extends RenderLiving
{
//The three numbers below change the size of your model (you'll need to change the hitbox size too though)
protected void preRenderScale(EntityTowelie entity, float f)
{
GL11.glScalef(1.5F, 1.5F, 1.5F);
}
public RenderTowelie(ModelTowelie modelbase, float f)
{
super(modelbase, f);
}
I'm having the creature spawn in the world by editing the BiomeGenBase and not by calling ModLoader. This is for a forge-based client/server so ModLoader isn't a valid call for me.
Here's my code. (and yes, I am using addRender)
mod_ File
package net.minecraft.src;
import java.util.Map;
public class mod_boxmob extends BaseMod
{
@Override
public String getVersion() {
return "Tets";
}
public void addRenderer(Map map)
{
map.put(TRBLST_BoxEntity.class, new TRBLST_BoxRender(new TRBLST_BoxModel(), 0.5F));
}
@Override
public void load() {
ModLoader.registerEntityID(TRBLST_BoxEntity.class, "Boxlol",
ModLoader.getUniqueEntityId());
ModLoader.addSpawn(TRBLST_BoxEntity.class, 12, 4, 4, EnumCreatureType.creature);
}
}
package net.minecraft.src;
public class TRBLST_BoxModel extends ModelBase
{
//fields
ModelRenderer Body;
ModelRenderer RLEG;
ModelRenderer LLEG;
public TRBLST_BoxModel()
{
textureWidth = 512;
textureHeight = 512;
Body = new ModelRenderer(this, 0, 0);
Body.addBox(0F, 0F, 0F, 10, 10, 10);
Body.setRotationPoint(-5F, 7F, -5F);
Body.setTextureSize(512, 512);
Body.mirror = true;
setRotation(Body, 0F, 0F, 0F);
RLEG = new ModelRenderer(this, 0, 0);
RLEG.addBox(0F, 0F, 0F, 3, 7, 3);
RLEG.setRotationPoint(-4F, 17F, -2F);
RLEG.setTextureSize(512, 512);
RLEG.mirror = true;
setRotation(RLEG, 0F, 0F, 0F);
LLEG = new ModelRenderer(this, 0, 0);
LLEG.addBox(0F, 0F, 0F, 3, 7, 3);
LLEG.setRotationPoint(1F, 17F, -2F);
LLEG.setTextureSize(512, 512);
LLEG.mirror = true;
setRotation(LLEG, 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);
Body.render(f5);
RLEG.render(f5);
LLEG.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)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5);
}
}
package net.minecraft.src;
import java.util.Random;
public class TRBLST_BoxEntity extends EntityAnimal
{
public TRBLST_BoxEntity(World par1World)
{
super(par1World);
texture = "/mob/cow.png";
setSize(0.9F, 1.3F);
}
public boolean isAIEnabled()
{
return false;
}
public int getMaxHealth()
{
return 1;
}
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
}
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
}
protected String getLivingSound()
{
return "mob.cow";
}
protected String getHurtSound()
{
return "mob.cowhurt";
}
protected String getDeathSound()
{
return "mob.cowhurt";
}
protected float getSoundVolume()
{
return 0.4F;
}
protected int getDropItemId()
{
return Item.diamond.shiftedIndex;
}
protected void dropFewItems(boolean par1, int par2)
{
}
public EntityAnimal spawnBabyAnimal(EntityAnimal par1EntityAnimal)
{
return new TRBLST_BoxEntity(worldObj);
}
}
package net.minecraft.src;
import org.lwjgl.opengl.GL11;
public class TRBLST_BoxRender extends RenderLiving
{
public TRBLST_BoxRender(ModelBase par1ModelBase, float par2)
{
super(par1ModelBase, par2);
}
public void renderBox(TRBLST_BoxEntity par1TRBLST_BoxEntity, double par2, double par4, double par6, float par8, float par9)
{
super.doRenderLiving(par1TRBLST_BoxEntity, par2, par4, par6, par8, par9);
}
public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
{
renderBox((TRBLST_BoxEntity)par1EntityLiving, par2, par4, par6, par8, par9);
}
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
renderBox((TRBLST_BoxEntity)par1Entity, par2, par4, par6, par8, par9);
}
}
I appreciate any help that anyone can give. This has stopped my mod cold and I can't do anything until I know what's wrong.
I hope someone helps you because in turn they will help me too. I also have been working on this for hours and still its a biped model.
Hopefully we can get an answer from someone!
Could you post your BaseMod class and your Entity class as well please.
The code below was for a 'test' mob I created after several failures. I mostly copied the creeper code.
Entity
import java.util.Random;
public class EntityTowelie extends EntityMob
{
/**
* The amount of time since the creeper was close enough to the player to ignite
*/
int timeSinceIgnited;
/**
* Time when this creeper was last in an active state (Messed up code here, probably causes creeper animation to go
* weird)
*/
int lastActiveTime;
public EntityTowelie(World par1World)
{
super(par1World);
texture = "/mob/towelie.png";
tasks.addTask(1, new EntityAISwimming(this));
tasks.addTask(2, new EntityAIAvoidEntity(this, net.minecraft.src.EntityOcelot.class, 6F, 0.25F, 0.3F));
tasks.addTask(3, new EntityAIAttackOnCollide(this, 0.25F, false));
tasks.addTask(4, new EntityAIWander(this, 0.2F));
tasks.addTask(5, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 8F));
tasks.addTask(5, new EntityAILookIdle(this));
targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityPlayer.class, 16F, 0, true));
targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
public int getMaxHealth()
{
return 20;
}
protected void entityInit()
{
super.entityInit();
dataWatcher.addObject(16, Byte.valueOf((byte) - 1));
dataWatcher.addObject(17, Byte.valueOf((byte)0));
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
if (dataWatcher.getWatchableObjectByte(17) == 1)
{
par1NBTTagCompound.setBoolean("powered", true);
}
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
dataWatcher.updateObject(17, Byte.valueOf((byte)(par1NBTTagCompound.getBoolean("powered") ? 1 : 0)));
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
if (isEntityAlive())
{
lastActiveTime = timeSinceIgnited;
int i = getTowelieState();
if (i > 0 && timeSinceIgnited == 0)
{
worldObj.playSoundAtEntity(this, "random.fuse", 1.0F, 0.5F);
}
timeSinceIgnited += i;
if (timeSinceIgnited < 0)
{
timeSinceIgnited = 0;
}
if (timeSinceIgnited >= 30)
{
timeSinceIgnited = 30;
if (!worldObj.isRemote)
{
if (getPowered())
{
worldObj.createExplosion(this, posX, posY, posZ, 6F);
}
else
{
worldObj.createExplosion(this, posX, posY, posZ, 3F);
}
setDead();
}
}
}
super.onUpdate();
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.creeper";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.creeperdeath";
}
/**
* Called when the mob's health reaches 0.
*/
public void onDeath(DamageSource par1DamageSource)
{
super.onDeath(par1DamageSource);
if (par1DamageSource.getEntity() instanceof EntitySkeleton)
{
dropItem(Item.record13.shiftedIndex + rand.nextInt(10), 1);
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
return true;
}
/**
* Returns true if the creeper is powered by a lightning bolt.
*/
public boolean getPowered()
{
return dataWatcher.getWatchableObjectByte(17) == 1;
}
/**
* Connects the the creeper flashes to the creeper's color multiplier
*/
public float setTowelieFlashTime(float par1)
{
return ((float)lastActiveTime + (float)(timeSinceIgnited - lastActiveTime) * par1) / 28F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return Item.gunpowder.shiftedIndex;
}
/**
* Returns the current state of creeper, -1 is idle, 1 is 'in fuse'
*/
public int getTowelieState()
{
return dataWatcher.getWatchableObjectByte(16);
}
/**
* Sets the state of creeper, -1 to idle and 1 to be 'in fuse'
*/
public void setTowelieState(int par1)
{
dataWatcher.updateObject(16, Byte.valueOf((byte)par1));
}
}
Model
package net.minecraft.src;
public class ModelTowelie extends ModelBase
{
//fields
ModelRenderer Shape1;
ModelRenderer Shape2;
ModelRenderer Shape3;
ModelRenderer Shape4;
ModelRenderer Shape5;
public ModelTowelie()
{
textureWidth = 64;
textureHeight = 32;
Shape1 = new ModelRenderer(this, 0, 0);
Shape1.addBox(0F, 0F, 0F, 10, 17, 1);
Shape1.setRotationPoint(-5F, 0F, 0F);
Shape1.setTextureSize(64, 32);
Shape1.mirror = true;
setRotation(Shape1, 0F, 0F, 0F);
Shape2 = new ModelRenderer(this, 26, 0);
Shape2.addBox(0F, 0F, 0F, 1, 7, 1);
Shape2.setRotationPoint(2F, 17F, 0F);
Shape2.setTextureSize(64, 32);
Shape2.mirror = true;
setRotation(Shape2, 0F, 0F, 0F);
Shape3 = new ModelRenderer(this, 22, 0);
Shape3.addBox(0F, 0F, 0F, 1, 7, 1);
Shape3.setRotationPoint(-3F, 17F, 0F);
Shape3.setTextureSize(64, 32);
Shape3.mirror = true;
setRotation(Shape3, 0F, 0F, 0F);
Shape4 = new ModelRenderer(this, 4, 18);
Shape4.addBox(0F, 0F, 0F, 1, 9, 1);
Shape4.setRotationPoint(-6F, 8F, 0F);
Shape4.setTextureSize(64, 32);
Shape4.mirror = true;
setRotation(Shape4, 0F, 0F, 0F);
Shape5 = new ModelRenderer(this, 0, 18);
Shape5.addBox(0F, 0F, 0F, 1, 9, 1);
Shape5.setRotationPoint(5F, 8F, 0F);
Shape5.setTextureSize(64, 32);
Shape5.mirror = true;
setRotation(Shape5, 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);
Shape1.render(f5);
Shape2.render(f5);
Shape3.render(f5);
Shape4.render(f5);
Shape5.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)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5);
}
}
Render
package net.minecraft.src;
import org.lwjgl.opengl.GL11;
public class RenderTowelie extends RenderLiving
{
//The three numbers below change the size of your model (you'll need to change the hitbox size too though)
protected void preRenderScale(EntityTowelie entity, float f)
{
GL11.glScalef(1.5F, 1.5F, 1.5F);
}
public RenderTowelie(ModelTowelie modelbase, float f)
{
super(modelbase, f);
}
public void func_177_a(EntityTowelie entity, double d, double d1, double d2,
float f, float f1)
{
super.doRenderLiving(entity, d, d1, d2, f, f1);
}
public void doRenderLiving(EntityLiving entityliving, double d, double d1, double d2,
float f, float f1)
{
super.doRenderLiving((EntityTowelie) entityliving, d, d1, d2, f, f1);
}
public void doRender(Entity entity, double d, double d1, double d2,
float f, float f1)
{
doRenderLiving((EntityTowelie)entity, d, d1, d2, f, f1);
}
protected void preRenderCallback(EntityLiving entityliving, float f)
{
preRenderScale((EntityTowelie)entityliving, f);
}
}
I'm having the creature spawn in the world by editing the BiomeGenBase and not by calling ModLoader. This is for a forge-based client/server so ModLoader isn't a valid call for me.
Oh... and this is for a 1.2.5 client/server
--------------------------------------------------------------------------------------------------------
ModLoader.registerEntityID(EntityWHATEVS.class, "WHATEVS", -128, 0xHexnumberhere, 0xHexnumberhere(For spawn egg));
ModLoader.addSpawn(EntityWHATEVS.class, 20, 10, 20, EnumCreatureType.creature);
ModLoader.addEntityTracker(this, EntityWHATEVS.class, -128, 20, 5, true);
}
public void generateSurface(World var1, Random var2, int var3, int var4) {}
public void generateNether(World var1, Random var2, int var3, int var4) {}
public void addRenderer(Map var1)
{
var1.put(EntityWHATEVS.class, new RenderLiving(new ModelWHATEVS(), 1.0F));
}
public Entity spawnEntity(int var1, World var2, double var3, double var5, double var7)
{
switch (var1)
{
case -128:
return new EntityWHATEVS(var2);
default:
return null;
}
}
public Packet23VehicleSpawn getSpawnPacket(Entity var1, int var2)
{
return var1 instanceof EntityWHATEVS ? new Packet23VehicleSpawn(var1, var2) : null;
}
This way always works.