Hello, I have been having a problem with the code which allows mobs to hold items, swords, etc. I have done research of this but all the codes I have tried seem to be pointless. I am not sure if Mojang has been changing this code with the latest updates, so my question is, which is the piece of code working for 1.4.7 that will get my mob to hold an item?
My mob is using RenderBiped. Here is the code my Entity is using.
package net.minecraft.src;
public class EntityEdraWarrior extends EntityMob
{
public EntityEdraWarrior(World par1World)
{
super(par1World);
this.texture = "/mob/EdraWarrior.png";¡
this.moveSpeed = 0.9f;¡
isImmuneToFire = true;
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, false));
this.tasks.addTask(2, new EntityAIMoveTwardsRestriction(this, this.moveSpeed));
this.tasks.addTask(3, new EntityAIWander(this, this.moveSpeed));
this.tasks.addTask(4, new EntityAILookIdle(this));
this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 25.0F, 0, true));
}
public int func_82193_c(Entity par1Entity) //the amount of damage
{
return 20;
}
protected void fall(float par1) {}
public int getMaxHealth() // Mob health
{
return 50;
}
protected String getLivingSound()
{
return "mob.zombie.say";
}
protected String getHurtSound()
{
return "mob.zombie.say";
}
protected String getDeathSound()
{
return "mob.zombie.death";
}
protected int getDropItemId()
{
return Item.diamond.itemID;
}
protected boolean canDespawn()
{
return false;
}
public ItemStack getHeldItem()
{
return heldItem;
}
public static ItemStack heldItem = new ItemStack(Item.appleGold);
protected boolean isAIEnabled()//Allow your AI task to work?
{
return true;
}
}
As you can see in the code, I have added a code I found to make it held an item, it didnt worked though, I also tried the code in the zombie pigmen as well as the skeleton, but still not working.
I will leave as well my mod_
package net.minecraft.src;
import java.awt.Color;
import java.util.Map;
public class mod_edramobs extends BaseMod
{
public String getVersion()
{
return "1.4.7";
}
public void load()
{
ModLoader.registerEntityID(EntityEdraWarrior.class, "EdraWarrior", 30);//registers the mobs name and id
ModLoader.addSpawn("EdraWarrior", 15, -5, 1, EnumCreatureType.creature);//makes the mob spawn in game
ModLoader.addLocalization("entity.EdraWarrior.name", "EdraWarrior");//adds Mob name on the spawn egg
EntityList.entityEggs.put(Integer.valueOf(30), new EntityEggInfo(30, 894731, (new Color(21, 15, 6)).getRGB()));//creates the spawn egg, and chnages color of egg
}
public void addRenderer(Map var1)
{
var1.put(EntityEdraWarrior.class, new RenderLiving(new ModelBiped(),.5f));
}
}
If you could help me with this I would me more than grateful. Thanks for your help.
It doesn't matter if it is static or not. Try adding a quantity after the Item.
private static final ItemStack heldItem = new ItemStack(Item.appleGold, 1);
I made a few other edits to that line as to how I have mine working.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I had the problem but I was using forge. There Is nothing in render living that allows it to hold an Item or in your model
The renderEquippedItems method in RenderBiped is where it is rendered.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
Umm, I switched to Forge and it seems to don't be working again. Any clue what I must add or change?
Anyone?
Forge handles entity rendering differently. You must register the entity in your client proxy. There are dozens of tutorials on it.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
Are you calling the registerRenderInformation method?
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
My mob is using RenderBiped.
Here is the code my Entity is using.
As you can see in the code, I have added a code I found to make it held an item, it didnt worked though, I also tried the code in the zombie pigmen as well as the skeleton, but still not working.
I will leave as well my mod_
If you could help me with this I would me more than grateful.
Thanks for your help.
I tried what you told me and it didn't worked.
I made a few other edits to that line as to how I have mine working.
together they are powerful beyond imagination."
The renderEquippedItems method in RenderBiped is where it is rendered.
together they are powerful beyond imagination."
He is using RenderLiving though
Thanks you very much! This problem has been annoying me a lot!
Anyone?
Forge handles entity rendering differently. You must register the entity in your client proxy. There are dozens of tutorials on it.
together they are powerful beyond imagination."
Hmm, I added the following method in my ClientProxy
But it doesn't seems effective... help?
together they are powerful beyond imagination."