I hate asking questions here because I like figuring things out on my own, but I've been trying to figure this out for 3 days. I tried to make a new mob that looks sort of like a pig, but hostile and weird looking. For the most part it worked, except it's third leg rotates really weirdly.
public EntityWobble(World world)
{
super(world);
texture = "/ocomo/wobble.png";
moveSpeed = 0.35F;
attackStrength = 2;
setSize(0.9F, 0.9F);
tasks.addTask(1, new EntityAISwimming(this));
tasks.addTask(2, new EntityAIAttackOnCollide(this, net.minecraft.src.EntityPlayer.class, moveSpeed, false));
tasks.addTask(5, new EntityAIWander(this, moveSpeed));
targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityPlayer.class, 16F, 0, true));
targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityGolem.class, 16F, 0, true));
}
public int getMaxHealth()
{
return 20;
}
public String getHurtSound()
{
return "mob.irongolem.hit";
}
public String getDeathSound()
{
return "mob.irongolem.death";
}
public String getLivingSound()
{
return "mob.silverfish.say";
}
public boolean isAIEnabled()
{
return true;
}
public EnumCreatureAttribute getCreatureAttribute()
{
return EnumCreatureAttribute.UNDEFINED;
}
protected int getDropItemId()
{
return Item.ingotIron.shiftedIndex;
}
protected void dropFewItems(boolean par1, int par2)
{
int i = rand.nextInt(3 + par2);
That would make it so it doesn't fly back and forth, but it still doesn't act the same as a normal leg. It just reduces how much the leg flies back and forth, making it look like a broken leg. Here's a video of what I mean:
If you still have problems with the leg, try moving the rotation point of the first leg to the position of the second one and the second one to the position of the first one if the problem is that the legs of the sides move in the same direction and if it's even possible. (I can't watch the video's because I'm posting this from my 3ds.)
Wow, why didn't I ever think of that? I don't see why that shouldn't work, I'll try it right now.
EDIT: Wow, you're a genius. That worked perfectly O_o thank you! That basically solves any problems I'll ever have with rotation points and stuff.
Here's a video:
Files:
ModelWobble
package net.minecraft.src;
public class ModelWobble extends ModelBase
{
ModelRenderer tail;
ModelRenderer head;
ModelRenderer body;
ModelRenderer leg1;
ModelRenderer leg2;
ModelRenderer leg3;
ModelRenderer leg4;
ModelRenderer snout;
ModelRenderer Shape1;
ModelRenderer Shape2;
public ModelWobble()
{
textureWidth = 128;
textureHeight = 64;
tail = new ModelRenderer(this, 4, 42);
tail.addBox(0F, 0F, 0F, 2, 1, 4);
tail.setRotationPoint(-1F, 14F, 8.8F);
tail.setTextureSize(64, 32);
tail.mirror = true;
setRotation(tail, -1.473891F, 0F, 0F);
head = new ModelRenderer(this, 0, 48);
head.addBox(-4F, -4F, -8F, 8, 8, 8);
head.setRotationPoint(0F, 12F, -6F);
head.setTextureSize(64, 32);
head.mirror = true;
setRotation(head, 0F, 0F, 0F);
body = new ModelRenderer(this, 32, 40);
body.addBox(-5F, -10F, -7F, 10, 16, 8);
body.setRotationPoint(0F, 11F, 3F);
body.setTextureSize(64, 32);
body.mirror = true;
setRotation(body, 1.361357F, 0F, 0F);
leg1 = new ModelRenderer(this, 84, 53);
leg1.addBox(-2F, 0F, -2F, 4, 7, 4);
leg1.setRotationPoint(-7F, 17F, 6F);
leg1.setTextureSize(64, 32);
leg1.mirror = true;
setRotation(leg1, 0F, 0F, 0F);
leg2 = new ModelRenderer(this, 84, 42);
leg2.addBox(2F, 0F, -2F, 4, 7, 4);
leg2.setRotationPoint(3F, 17F, 6F);
leg2.setTextureSize(64, 32);
leg2.mirror = true;
setRotation(leg2, 0F, 0F, 0F);
leg3 = new ModelRenderer(this, 68, 50);
leg3.addBox(-6F, 18F, -2F, 4, 10, 4);
leg3.setRotationPoint(-3F, -4F, -5F);
leg3.setTextureSize(64, 32);
setRotation(leg3, 0F, 0F, 0F);
leg4 = new ModelRenderer(this, 100, 50);
leg4.addBox(2F, 0F, -2F, 4, 10, 4);
leg4.setRotationPoint(3F, 14F, -5F);
leg4.setTextureSize(64, 32);
leg4.mirror = true;
setRotation(leg4, 0F, 0F, 0F);
snout = new ModelRenderer(this, 22, 44);
snout.addBox(0F, 0F, 0F, 4, 3, 1);
snout.setRotationPoint(-2F, 12F, -15F);
snout.setTextureSize(64, 32);
snout.mirror = true;
setRotation(snout, 0F, 0F, 0F);
Shape1 = new ModelRenderer(this, 0, 0);
Shape1.addBox(0F, 0F, 0F, 3, 3, 1);
Shape1.setRotationPoint(-6F, 6F, -12F);
Shape1.setTextureSize(64, 32);
Shape1.mirror = true;
setRotation(Shape1, 0F, 0F, 0F);
Shape2 = new ModelRenderer(this, 0, 4);
Shape2.addBox(0F, 0F, 0F, 3, 3, 1);
Shape2.setRotationPoint(3F, 6F, -12F);
Shape2.setTextureSize(64, 32);
Shape2.mirror = true;
setRotation(Shape2, 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);
tail.render(f5);
head.render(f5);
body.render(f5);
leg1.render(f5);
leg2.render(f5);
leg3.render(f5);
leg4.render(f5);
snout.render(f5);
Shape1.render(f5);
Shape2.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)
{
leg1.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
leg2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
leg1.rotateAngleY = 0.0F;
leg2.rotateAngleY = 0.0F;
leg3.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
leg4.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F;
leg3.rotateAngleZ = 0.0F;
leg4.rotateAngleZ = 0.0F;
}
}
RenderWobble
package net.minecraft.src;
public class RenderWobble extends RenderLiving{
protected ModelWobble modelWobbleMain;
protected float field_40296_d;
public RenderWobble(ModelWobble par1ModelWobble, float par2)
{
this(par1ModelWobble, par2, 1.0F);
modelWobbleMain = par1ModelWobble;
}
public RenderWobble(ModelWobble par1ModelWobble, float par2, float par3)
{
super(par1ModelWobble, par2);
modelWobbleMain = par1ModelWobble;
field_40296_d = par3;
}
}
EntityWobble
package net.minecraft.src;
public class EntityWobble extends EntityMob{
public EntityWobble(World world)
{
super(world);
texture = "/ocomo/wobble.png";
moveSpeed = 0.35F;
attackStrength = 2;
setSize(0.9F, 0.9F);
tasks.addTask(1, new EntityAISwimming(this));
tasks.addTask(2, new EntityAIAttackOnCollide(this, net.minecraft.src.EntityPlayer.class, moveSpeed, false));
tasks.addTask(5, new EntityAIWander(this, moveSpeed));
targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityPlayer.class, 16F, 0, true));
targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, net.minecraft.src.EntityGolem.class, 16F, 0, true));
}
public int getMaxHealth()
{
return 20;
}
public String getHurtSound()
{
return "mob.irongolem.hit";
}
public String getDeathSound()
{
return "mob.irongolem.death";
}
public String getLivingSound()
{
return "mob.silverfish.say";
}
public boolean isAIEnabled()
{
return true;
}
public EnumCreatureAttribute getCreatureAttribute()
{
return EnumCreatureAttribute.UNDEFINED;
}
protected int getDropItemId()
{
return Item.ingotIron.shiftedIndex;
}
protected void dropFewItems(boolean par1, int par2)
{
int i = rand.nextInt(3 + par2);
for (int j = 0; j < i; j++)
{
dropItem(Item.ingotIron.shiftedIndex, 1);
}
for (int l = 0; l < i; l++)
{
dropItem(Item.ingotGold.shiftedIndex, 1);
}
for (int o = 0; o < i; o++)
{
dropItem(Item.diamond.shiftedIndex, 1);
}
for (int o = 0; o < i; o++)
{
dropItem(Item.redstone.shiftedIndex, 1);
}
}
}
mod_Wobble
package net.minecraft.src;
import java.util.Map;
public class mod_Wobble extends BaseMod{
public static Item wobbleSpawner = (new ItemWobbleSpawner(682)).setItemName("testSpawner2");
public mod_Wobble()
{
}
public void addRenderer(Map map)
{
map.put(EntityWobble.class, new RenderWobble(new ModelWobble(), 0.5F));
}
public void load()
{
ModLoader.addSpawn(EntityWobble.class, 5, 1, 4, EnumCreatureType.monster);
ModLoader.registerEntityID(EntityWobble.class, "DeathPig", 86);
ModLoader.addName(wobbleSpawner, "Spawn Death Pig");
wobbleSpawner.iconIndex = ModLoader.addOverride("/gui/items.png", "/ocomo/wobbleegg.png");
}
public String getVersion()
{
return "1.2.5";
}
}
To fix the leg flying around, all I have to do is change this:
To this:
That would make it so it doesn't fly back and forth, but it still doesn't act the same as a normal leg. It just reduces how much the leg flies back and forth, making it look like a broken leg. Here's a video of what I mean:
Any help would be appreciated.
I don't think it has anything to do with setRotationPoint and addBox. My guess is that there's a problem with this code somehow:
leg3.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
It was funny at first but now it's driving my insane
EDIT: I just created a new model from scratch and everything seems to work. Now I just have to fix the texture
EDIT: Wow, you're a genius. That worked perfectly O_o thank you! That basically solves any problems I'll ever have with rotation points and stuff.