Ok. Here, we want to craft a kind of Ore Storage Block with our new custom item. If you want to use your custom item, you will have to refer it to your mod_*** class, not Item or Block. If you want to use a new block, don't refer it to the Block class. Refer it to your mod_*** class, like your custom item.
I hope it helped!
Edit:
It's not obligate to put spaces around the symbols.
You were right for refering your custom item. You can choose to refer it to the mod_*** class and you can choose not to. Personally, I refer it to the mod_*** class. Around the "#"s, you've put a '{' and a '}'. You must put a '{' to the first one only and you must not put a '}'. You put it only at the end of the line with the ')' and the ';'.
Thanks!!!
Thats Works!!!
You Are A Best Guy Who Help Me Make a Mod!!
You Really Help Me THANKS!
You're welcome!
If it helped you (I'm talking to everyone, here), feel free to click on the green button on the bottom right of my previous post (because in this one, I just said 'You're welcome').
You're welcome!
If it helped you (I'm talking to everyone, here), feel free to click on the green button on the bottom right of my previous post (because in this one, I just said 'You're welcome').
Now, I'm asking for help from anyone who can help me.
I have a(nother) problem:
I can't hear my music! I get no error while recompiling, no crash in-game, I have installed AudioMod, ModLoader and Minecraft Forge, I've put my .ogg music file in both the original streaming folder and in the mod/streaming folder, the file has the same name as the music name of the disc and the music disc fits in the jukebox. It doesn't even show 'Now playing: Namehere.ogg'.
Here is the music disc line of code in mod_***:
public static final Item musicDisc = new ItemDatModNamehereDisc(2030, "Namehere").setIconIndex(48).setItemName("musicdisc");
Here's the ItemDatModNamehereDisc class. It's pretty much the same as the ItemRecord class:
package net.minecraft.src;
import java.util.List;
import net.minecraft.src.forge.*;
import net.minecraft.src.forge.ITextureProvider;
public class ItemDatModNamehereDisc extends Item implements ITextureProvider
{
/** The name of the record. */
public final String recordName;
protected ItemDatModNamehereDisc(int par1, String par2Str)
{
super(par1);
this.recordName = par2Str;
this.maxStackSize = 1;
}
public String getTextureFile()
{
return "/DatMod/itemsOther.png";
}
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS !
*/
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
{
if (par3World.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0)
{
if (par3World.isRemote)
{
return true;
}
else
{
((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, this.shiftedIndex);
par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.shiftedIndex);
--par1ItemStack.stackSize;
return true;
}
}
else
{
return false;
}
}
/**
* allows items to add custom lines of information to the mouseover description
*/
public void addInformation(ItemStack par1ItemStack, List par2List)
{
par2List.add("Namehere - " + this.recordName);
}
/**
* Return an item rarity from EnumRarity
*/
public EnumRarity getRarity(ItemStack par1ItemStack)
{
return EnumRarity.rare;
}
}
EDIT:
It works when I replace 'new ItemDatModNamehereDisc' by 'new ItemRecord'. When I use the ItemRecord class, the Composer is C418 and I can't use the disc's image. Later, I want to use the disc for something... special. It's personal, but I want my disc to work successfully with ItemDatModNamehereDisc.
Now, I'm asking for help from anyone who can help me.
I have a(nother) problem:
I can't hear my music! I get no error while recompiling, no crash in-game, I have installed AudioMod, ModLoader and Minecraft Forge, I've put my .ogg music file in both the original streaming folder and in the mod/streaming folder, the file has the same name as the music name of the disc and the music disc fits in the jukebox. It doesn't even show 'Now playing: Namehere.ogg'.
Here is the music disc line of code in mod_***:
public static final Item musicDisc = new ItemDatModNamehereDisc(2030, "Namehere").setIconIndex(48).setItemName("musicdisc");
Here's the ItemDatModNamehereDisc class. It's pretty much the same as the ItemRecord class:
package net.minecraft.src;
import java.util.List;
import net.minecraft.src.forge.*;
import net.minecraft.src.forge.ITextureProvider;
public class ItemDatModNamehereDisc extends Item implements ITextureProvider
{
/** The name of the record. */
public final String recordName;
protected ItemDatModNamehereDisc(int par1, String par2Str)
{
super(par1);
this.recordName = par2Str;
this.maxStackSize = 1;
}
public String getTextureFile()
{
return "/DatMod/itemsOther.png";
}
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS !
*/
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
{
if (par3World.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0)
{
if (par3World.isRemote)
{
return true;
}
else
{
((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, this.shiftedIndex);
par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.shiftedIndex);
--par1ItemStack.stackSize;
return true;
}
}
else
{
return false;
}
}
/**
* allows items to add custom lines of information to the mouseover description
*/
public void addInformation(ItemStack par1ItemStack, List par2List)
{
par2List.add("Namehere - " + this.recordName);
}
/**
* Return an item rarity from EnumRarity
*/
public EnumRarity getRarity(ItemStack par1ItemStack)
{
return EnumRarity.rare;
}
}
EDIT:
It works when I replace 'new ItemDatModNamehereDisc' by 'new ItemRecord'. When I use the ItemRecord class, the Composer is C418 and I can't use the disc's image. Later, I want to use the disc for something... special. It's personal, but I want my disc to work successfully with ItemDatModNamehereDisc.
Firstly: Spoilers
[spoiler]text here[/spoiler]
Secondly: You should look at lockNload147's tutorial: http://www.minecraft...thout-audiomod/ for how to add sounds
Thirdly: I have no idea how to fix the problem you are having... Sorry
So I've been making my mod, and I got a couple of questions and errors
first here is my code:
mod_* class:
package net.minecraft.src;
import java.util.Map;
public class mod_MinecraftTotalWar extends BaseMod
{
public void load()
{
//Human Villager
//Entity Human Villager Child
ModLoader.registerEntityID(EntityHumanVillagerChild.class, "Child", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityHumanVillagerChild.class, 12, 14, 18, EnumCreatureType.creature);
//Entity Human Villager Male
ModLoader.registerEntityID(EntityHumanVillagerMale.class, "Man", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityHumanVillagerMale.class, 12, 14, 18, EnumCreatureType.creature);
//Entity Human Villager Female
ModLoader.registerEntityID(EntityHumanVillagerFemale.class, "Woman", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityHumanVillagerFemale.class, 12, 14, 18, EnumCreatureType.creature);
//Human Noble
//Entity Human Noble Child
//Entity Human Noble Male
//Entity Human Noble Female
//Entity Human Noble Knight
//Military
//Mercenary Swordsman
ModLoader.registerEntityID(EntityMercenarySwordsman.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityMercenarySwordsman.class, 12, 14, 24, EnumCreatureType.monster);
//Mercenary Archer
ModLoader.registerEntityID(EntityMercenaryArcher.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityMercenaryArcher.class, 12, 14, 24, EnumCreatureType.monster);
//Militia
//Militia Archers
//Hostile mobs
//Bandit
ModLoader.registerEntityID(EntityBandit.class, "Bandit", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityBandit.class, 12, 14, 24, EnumCreatureType.monster);
//Brigand
ModLoader.registerEntityID(EntityBrigand.class, "Brigand", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityBrigand.class, 11, 14, 20, EnumCreatureType.monster);
//Rebel leader
ModLoader.registerEntityID(EntityRebelLeader.class, "Rebel Leader", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityRebelLeader.class, 8, 14, 16, EnumCreatureType.monster);
}
//spawn list
public void addRenderer(Map map)
{
//Hostile Mobs
map.put(EntityBandit.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityBrigand.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityRebelLeader.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityMercenarySwordsman.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityMercenaryArcher.class, new RenderBiped(new ModelBiped(), 0.5F));
}
public String getVersion()
{
return "1.2.5";
}
}
EntityHumanVillagerMale class:
package net.minecraft.src;
import java.util.Random;
public class EntityHumanVillagerMale extends EntityCreature
{
private int randomTickDivider;
private boolean isMatingFlag;
private boolean isPlayingFlag;
Village villageObj; public EntityHumanVillagerMale(World par1World)
{
this(par1World, 0);
}
public EntityHumanVillagerMale(World par1World, int par2)
{
super(par1World);
randomTickDivider = 0;
isMatingFlag = false;
isPlayingFlag = false;
villageObj = null;
setProfession(par2);
texture = "/mods/VillagerMale.png";
moveSpeed = 0.5F;
getNavigator().setBreakDoors(true);
getNavigator().setAvoidsWater(true);
tasks.addTask(0, new EntityAISwimming(this));
tasks.addTask(1, new EntityAIAvoidEntity(this, net.minecraft.src.EntityZombie.class, 8F, 0.3F, 0.35F));
tasks.addTask(2, new EntityAIMoveIndoors(this));
tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
tasks.addTask(4, new EntityAIOpenDoor(this, true));
tasks.addTask(5, new EntityAIMoveTwardsRestriction(this, 0.3F));
tasks.addTask(6, new EntityAIVillagerMate(this));
tasks.addTask(7, new EntityAIPlay(this, 0.32F));
tasks.addTask(8, new EntityAIWatchClosest2(this, net.minecraft.src.EntityPlayer.class, 3F, 1.0F));
tasks.addTask(8, new EntityAIWatchClosest2(this, net.minecraft.src.EntityVillager.class, 5F, 0.02F));
tasks.addTask(8, new EntityAIWander(this, 0.3F));
tasks.addTask(9, new EntityAIWatchClosest(this, net.minecraft.src.EntityLiving.class, 8F));
} /**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
if (--randomTickDivider <= 0)
{
worldObj.villageCollectionObj.addVillagerPosition(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ));
randomTickDivider = 70 + rand.nextInt(50);
villageObj = worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ), 32); if (villageObj == null)
{
detachHome();
}
else
{
ChunkCoordinates chunkcoordinates = villageObj.getCenter();
setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, villageObj.getVillageRadius());
}
}
super.updateAITick();
} protected void entityInit()
{
super.entityInit();
dataWatcher.addObject(16, Integer.valueOf(0));
}
public int getMaxHealth()
{
return 20;
} /**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("Profession", getProfession());
} /**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
setProfession(par1NBTTagCompound.getInteger("Profession"));
}
/**
* Returns the texture's file path as a String.
*/
public String getTexture()
{
switch (getProfession())
{
case 0:
return "/mods/VillagerMale.png"; case 1:
return "/mods/Villager/librarian.png";
case 2:
return "/mods/Villager/priest.png"; case 3:
return "/mods/VillagerMaleSmith.png";
case 4:
return "/mods/VillagerMaleButcher.png";
} return super.getTexture();
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
} /**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "mob.villager.default";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.villager.defaulthurt";
} /**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.villager.defaultdeath";
}
public void setProfession(int par1)
{
dataWatcher.updateObject(16, Integer.valueOf(par1));
} public int getProfession()
{
return dataWatcher.getWatchableObjectInt(16);
}
public boolean getIsMatingFlag()
{
return isMatingFlag;
} public void setIsMatingFlag(boolean par1)
{
isMatingFlag = par1;
}
public void setIsPlayingFlag(boolean par1)
{
isPlayingFlag = par1;
} public boolean getIsPlayingFlag()
{
return isPlayingFlag;
}
public void setRevengeTarget(EntityLiving par1EntityLiving)
{
super.setRevengeTarget(par1EntityLiving); if (villageObj != null && par1EntityLiving != null)
{
villageObj.addOrRenewAgressor(par1EntityLiving);
}
}
}
EntityMercenarySwordsman class:
package net.minecraft.src;
public class EntityMercenarySwordsman extends EntityTameable
{
public EntityMercenarySwordsman(World world)
{
super(world);
texture = "/image.png";
moveSpeed = 0.5F;
getNavigator().setBreakDoors(true);
tasks.addTask(1, new EntityAISwimming(this));
tasks.addTask(2, aiSit);
tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
tasks.addTask(4, new EntityAIAttackOnCollide(this, moveSpeed, true));
tasks.addTask(5, new EntityAIFollowOwner(this, moveSpeed, 10F, 2.0F));
tasks.addTask(6, new EntityAISwimming(this));
tasks.addTask(7, new EntityAIWander(this, moveSpeed));
tasks.addTask(8, new EntityAIBreakDoor(this));
tasks.addTask(9, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 8F));
tasks.addTask(9, new EntityAILookIdle(this));
targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
targetTasks.addTask(4, new EntityAITargetNonTamed(this, net.minecraft.src.EntitySheep.class, 16F, 200, false));
}
public boolean isAIEnabled()
{
return true;
}
//Sets the active target the Task system uses for tracking
public void setAttackTarget(EntityLiving par1EntityLiving)
{
super.setAttackTarget(par1EntityLiving); if (par1EntityLiving instanceof EntityPlayer)
{
setAngry(true);
}
}
//Returns the texture's file path as a String.
public String getTexture()
{
if (isTamed())
{
return "/mob/wolf_tame.png";
}
if (isAngry())
{
return "/mob/wolf_angry.png";
}
else
{
return super.getTexture();
}
}
//(abstract) Protected helper method to write subclass entity data to NBT.
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", isAngry());
}
//(abstract) Protected helper method to read subclass entity data from NBT.
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
setAngry(par1NBTTagCompound.getBoolean("Angry"));
}
//Sets whether this badass is angry or not.
public boolean isAngry()
{
return (dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
public void setAngry(boolean par1)
{
byte byte0 = dataWatcher.getWatchableObjectByte(16); if (par1)
{
dataWatcher.updateObject(16, Byte.valueOf((byte)(byte0 | 2)));
}
else
{
dataWatcher.updateObject(16, Byte.valueOf((byte)(byte0 & -3)));
}
}
//Called when the entity is attacked.
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
{
Entity entity = par1DamageSource.getEntity();
aiSit.setIsSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1) / 2;
} return super.attackEntityFrom(par1DamageSource, par2);
}
public boolean attackEntityAsMob(Entity par1Entity)
{
byte byte0 = ((byte)(isTamed() ? 4 : 2));
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), byte0);
}
//anti-crop trampler
protected boolean canTriggerWalking()
{
return false;
} public int getMaxHealth()
{
return 20;
}
public int getTotalArmorValue()
{
return 2;
}
//Mob's weapon held
private static final ItemStack defaultHeldItem;
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
static
{
defaultHeldItem = new ItemStack(Item.swordSteel, 1);
}
//mob sounds
protected String getLivingSound()
{
return "mob.villager.default";
} protected String getHurtSound()
{
return "mob.villager.defaulthurt";
}
protected String getDeathSound()
{
return "mob.villager.defaultdeath";
} protected int getDropItemId()
{
return Item.ingotIron.shiftedIndex;
}
protected boolean canDespawn()
{
return false;
}
//Called when a player interacts with a mob. e.g. giving gold ingots to "tame" mercenary
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (!isTamed())
{
if (itemstack != null && itemstack.itemID == Item.ingotGold.shiftedIndex && !isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
itemstack.stackSize--;
} if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!worldObj.isRemote)
{
if (rand.nextInt(3) == 0)
{
setTamed(true);
setPathToEntity(null);
setAttackTarget(null);
aiSit.setIsSitting(true);
setEntityHealth(20);
setOwner(par1EntityPlayer.username);
playTameEffect(true);
worldObj.setEntityState(this, (byte)7);
}
else
{
playTameEffect(false);
worldObj.setEntityState(this, (byte)6);
}
} return true;
}
}
else
{
if (itemstack != null && (Item.itemsList[itemstack.itemID] instanceof ItemFood))
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && dataWatcher.getWatchableObjectInt(18) < 20)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
itemstack.stackSize--;
} heal(itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
} return true;
}
}
if (par1EntityPlayer.username.equalsIgnoreCase(getOwnerName()) && !worldObj.isRemote && !isWheat(itemstack))
{
aiSit.setIsSitting(!isSitting());
isJumping = false;
setPathToEntity(null);
}
} return super.interact(par1EntityPlayer);
}
}
now the errors:
on the EntityHumanVillager.class, there is an error with task 6 and 7, both constructors are undefined, dont know how to fix that problem. What im trying to do is (and I need help with how to do this):
-basically change all testificates to human models
-give testificates genders and depending on their profession, give them special abilities
-have it so that only male and female testificates can mate together and have children
I understand that there is a mod called, minecraft comes alive that does this, but I plan on expanding what im doing.
the second error, is the EntityMercenarySwordsman.class (and mercenary archer too, but they're both the same)
The type EntityMercenarySwordsman must implement the inherited abstract method EntityAnimal.spawnBabyAnimal(EntityAnimal)
tried to do the same as with the wolf, except have it so you give the mercenary gold ingots to "tame" them. basically do everything the wolf does, except for mating. but it seems I did something wrong :/
If anyone could help me with this, it would be appreciated, thanks
edit: don't worry about me getting the textures wrong, im still working on the art
also, one question, I forgot to ask, am I doing the human villager right so far? I mean, should I do them the same as the human_npc tutorial? or do something different, since they will be replacing testificates and be spawning in villages. I know there is a line of code to add that will make it replace EntityVillager.class, but I forgot :/
So I've been making my mod, and I got a couple of questions and errors
first here is my code: *snip*
now the errors:
on the EntityHumanVillager.class, there is an error with task 6 and 7, both constructors are undefined, dont know how to fix that problem. What im trying to do is (and I need help with how to do this):
-basically change all testificates to human models
-give testificates genders and depending on their profession, give them special abilities
-have it so that only male and female testificates can mate together and have children
I understand that there is a mod called, minecraft comes alive that does this, but I plan on expanding what im doing.
the second error, is the EntityMercenarySwordsman.class (and mercenary archer too, but they're both the same)
The type EntityMercenarySwordsman must implement the inherited abstract method EntityAnimal.spawnBabyAnimal(EntityAnimal)
tried to do the same as with the wolf, except have it so you give the mercenary gold ingots to "tame" them. basically do everything the wolf does, except for mating. but it seems I did something wrong :/
If anyone could help me with this, it would be appreciated, thanks
edit: don't worry about me getting the textures wrong, im still working on the art
also, one question, I forgot to ask, am I doing the human villager right so far? I mean, should I do them the same as the human_npc tutorial? or do something different, since they will be replacing testificates and be spawning in villages. I know there is a line of code to add that will make it replace EntityVillager.class, but I forgot :/
I think for now, you should make better separation for your code. Not the actual code, it's just that it's very difficult to tell where one ends, and the other begins. That being said, it's difficult to help. So, for now, either edit your previous post or re-post your question. You can put spoilers within spoilers, which makes things much easier. Here's your code, just separated:
mod_* class:
package net.minecraft.src;
import java.util.Map;
public class mod_MinecraftTotalWar extends BaseMod
{
public void load()
{
//Human Villager
//Entity Human Villager Child
ModLoader.registerEntityID(EntityHumanVillagerChild.class, "Child", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityHumanVillagerChild.class, 12, 14, 18, EnumCreatureType.creature);
//Entity Human Villager Male
ModLoader.registerEntityID(EntityHumanVillagerMale.class, "Man", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityHumanVillagerMale.class, 12, 14, 18, EnumCreatureType.creature);
//Entity Human Villager Female
ModLoader.registerEntityID(EntityHumanVillagerFemale.class, "Woman", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityHumanVillagerFemale.class, 12, 14, 18, EnumCreatureType.creature);
//Human Noble
//Entity Human Noble Child
//Entity Human Noble Male
//Entity Human Noble Female
//Entity Human Noble Knight
//Military
//Mercenary Swordsman
ModLoader.registerEntityID(EntityMercenarySwordsman.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityMercenarySwordsman.class, 12, 14, 24, EnumCreatureType.monster);
//Mercenary Archer
ModLoader.registerEntityID(EntityMercenaryArcher.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityMercenaryArcher.class, 12, 14, 24, EnumCreatureType.monster);
//Militia
//Militia Archers
//Hostile mobs
//Bandit
ModLoader.registerEntityID(EntityBandit.class, "Bandit", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityBandit.class, 12, 14, 24, EnumCreatureType.monster);
//Brigand
ModLoader.registerEntityID(EntityBrigand.class, "Brigand", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityBrigand.class, 11, 14, 20, EnumCreatureType.monster);
//Rebel leader
ModLoader.registerEntityID(EntityRebelLeader.class, "Rebel Leader", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityRebelLeader.class, 8, 14, 16, EnumCreatureType.monster);
}
//spawn list
public void addRenderer(Map map)
{
//Hostile Mobs
map.put(EntityBandit.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityBrigand.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityRebelLeader.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityMercenarySwordsman.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityMercenaryArcher.class, new RenderBiped(new ModelBiped(), 0.5F));
}
public String getVersion()
{
return "1.2.5";
}
}
EntityHumanVillagerMale class:
package net.minecraft.src;
import java.util.Random;
public class EntityHumanVillagerMale extends EntityCreature
{
private int randomTickDivider;
private boolean isMatingFlag;
private boolean isPlayingFlag;
Village villageObj; public EntityHumanVillagerMale(World par1World)
{
this(par1World, 0);
}
public EntityHumanVillagerMale(World par1World, int par2)
{
super(par1World);
randomTickDivider = 0;
isMatingFlag = false;
isPlayingFlag = false;
villageObj = null;
setProfession(par2);
texture = "/mods/VillagerMale.png";
moveSpeed = 0.5F;
getNavigator().setBreakDoors(true);
getNavigator().setAvoidsWater(true);
tasks.addTask(0, new EntityAISwimming(this));
tasks.addTask(1, new EntityAIAvoidEntity(this, net.minecraft.src.EntityZombie.class, 8F, 0.3F, 0.35F));
tasks.addTask(2, new EntityAIMoveIndoors(this));
tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
tasks.addTask(4, new EntityAIOpenDoor(this, true));
tasks.addTask(5, new EntityAIMoveTwardsRestriction(this, 0.3F));
tasks.addTask(6, new EntityAIVillagerMate(this));
tasks.addTask(7, new EntityAIPlay(this, 0.32F));
tasks.addTask(8, new EntityAIWatchClosest2(this, net.minecraft.src.EntityPlayer.class, 3F, 1.0F));
tasks.addTask(8, new EntityAIWatchClosest2(this, net.minecraft.src.EntityVillager.class, 5F, 0.02F));
tasks.addTask(8, new EntityAIWander(this, 0.3F));
tasks.addTask(9, new EntityAIWatchClosest(this, net.minecraft.src.EntityLiving.class, 8F));
} /**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
if (--randomTickDivider <= 0)
{
worldObj.villageCollectionObj.addVillagerPosition(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ));
randomTickDivider = 70 + rand.nextInt(50);
villageObj = worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ), 32); if (villageObj == null)
{
detachHome();
}
else
{
ChunkCoordinates chunkcoordinates = villageObj.getCenter();
setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, villageObj.getVillageRadius());
}
}
super.updateAITick();
} protected void entityInit()
{
super.entityInit();
dataWatcher.addObject(16, Integer.valueOf(0));
}
public int getMaxHealth()
{
return 20;
} /**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("Profession", getProfession());
} /**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
setProfession(par1NBTTagCompound.getInteger("Profession"));
}
/**
* Returns the texture's file path as a String.
*/
public String getTexture()
{
switch (getProfession())
{
case 0:
return "/mods/VillagerMale.png"; case 1:
return "/mods/Villager/librarian.png";
case 2:
return "/mods/Villager/priest.png"; case 3:
return "/mods/VillagerMaleSmith.png";
case 4:
return "/mods/VillagerMaleButcher.png";
} return super.getTexture();
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
} /**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "mob.villager.default";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.villager.defaulthurt";
} /**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.villager.defaultdeath";
}
public void setProfession(int par1)
{
dataWatcher.updateObject(16, Integer.valueOf(par1));
} public int getProfession()
{
return dataWatcher.getWatchableObjectInt(16);
}
public boolean getIsMatingFlag()
{
return isMatingFlag;
} public void setIsMatingFlag(boolean par1)
{
isMatingFlag = par1;
}
public void setIsPlayingFlag(boolean par1)
{
isPlayingFlag = par1;
} public boolean getIsPlayingFlag()
{
return isPlayingFlag;
}
public void setRevengeTarget(EntityLiving par1EntityLiving)
{
super.setRevengeTarget(par1EntityLiving); if (villageObj != null && par1EntityLiving != null)
{
villageObj.addOrRenewAgressor(par1EntityLiving);
}
}
}
EntityMercenarySwordsman class:
package net.minecraft.src;
public class EntityMercenarySwordsman extends EntityTameable
{
public EntityMercenarySwordsman(World world)
{
super(world);
texture = "/image.png";
moveSpeed = 0.5F;
getNavigator().setBreakDoors(true);
tasks.addTask(1, new EntityAISwimming(this));
tasks.addTask(2, aiSit);
tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
tasks.addTask(4, new EntityAIAttackOnCollide(this, moveSpeed, true));
tasks.addTask(5, new EntityAIFollowOwner(this, moveSpeed, 10F, 2.0F));
tasks.addTask(6, new EntityAISwimming(this));
tasks.addTask(7, new EntityAIWander(this, moveSpeed));
tasks.addTask(8, new EntityAIBreakDoor(this));
tasks.addTask(9, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 8F));
tasks.addTask(9, new EntityAILookIdle(this));
targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
targetTasks.addTask(4, new EntityAITargetNonTamed(this, net.minecraft.src.EntitySheep.class, 16F, 200, false));
}
public boolean isAIEnabled()
{
return true;
}
//Sets the active target the Task system uses for tracking
public void setAttackTarget(EntityLiving par1EntityLiving)
{
super.setAttackTarget(par1EntityLiving); if (par1EntityLiving instanceof EntityPlayer)
{
setAngry(true);
}
}
//Returns the texture's file path as a String.
public String getTexture()
{
if (isTamed())
{
return "/mob/wolf_tame.png";
}
if (isAngry())
{
return "/mob/wolf_angry.png";
}
else
{
return super.getTexture();
}
}
//(abstract) Protected helper method to write subclass entity data to NBT.
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", isAngry());
}
//(abstract) Protected helper method to read subclass entity data from NBT.
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
setAngry(par1NBTTagCompound.getBoolean("Angry"));
}
//Sets whether this badass is angry or not.
public boolean isAngry()
{
return (dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
public void setAngry(boolean par1)
{
byte byte0 = dataWatcher.getWatchableObjectByte(16); if (par1)
{
dataWatcher.updateObject(16, Byte.valueOf((byte)(byte0 | 2)));
}
else
{
dataWatcher.updateObject(16, Byte.valueOf((byte)(byte0 & -3)));
}
}
//Called when the entity is attacked.
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
{
Entity entity = par1DamageSource.getEntity();
aiSit.setIsSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1) / 2;
} return super.attackEntityFrom(par1DamageSource, par2);
}
public boolean attackEntityAsMob(Entity par1Entity)
{
byte byte0 = ((byte)(isTamed() ? 4 : 2));
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), byte0);
}
//anti-crop trampler
protected boolean canTriggerWalking()
{
return false;
} public int getMaxHealth()
{
return 20;
}
public int getTotalArmorValue()
{
return 2;
}
//Mob's weapon held
private static final ItemStack defaultHeldItem;
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
static
{
defaultHeldItem = new ItemStack(Item.swordSteel, 1);
}
//mob sounds
protected String getLivingSound()
{
return "mob.villager.default";
} protected String getHurtSound()
{
return "mob.villager.defaulthurt";
}
protected String getDeathSound()
{
return "mob.villager.defaultdeath";
} protected int getDropItemId()
{
return Item.ingotIron.shiftedIndex;
}
protected boolean canDespawn()
{
return false;
}
//Called when a player interacts with a mob. e.g. giving gold ingots to "tame" mercenary
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (!isTamed())
{
if (itemstack != null && itemstack.itemID == Item.ingotGold.shiftedIndex && !isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
itemstack.stackSize--;
} if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!worldObj.isRemote)
{
if (rand.nextInt(3) == 0)
{
setTamed(true);
setPathToEntity(null);
setAttackTarget(null);
aiSit.setIsSitting(true);
setEntityHealth(20);
setOwner(par1EntityPlayer.username);
playTameEffect(true);
worldObj.setEntityState(this, (byte)7);
}
else
{
playTameEffect(false);
worldObj.setEntityState(this, (byte)6);
}
} return true;
}
}
else
{
if (itemstack != null && (Item.itemsList[itemstack.itemID] instanceof ItemFood))
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && dataWatcher.getWatchableObjectInt(18) < 20)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
itemstack.stackSize--;
} heal(itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
} return true;
}
}
if (par1EntityPlayer.username.equalsIgnoreCase(getOwnerName()) && !worldObj.isRemote && !isWheat(itemstack))
{
aiSit.setIsSitting(!isSitting());
isJumping = false;
setPathToEntity(null);
}
} return super.interact(par1EntityPlayer);
}
}
Or better yet, if Techguy looks here for your problem instead, that'd make it easier. So... Oi, Techguy. I've organized the guy above me's code into separate spoilers to make it easier to read for you. I can't help him myself. I've never made entities before.
Does anyone know what 3 last parameters define here:
EntityAINearestAttackableTarget(EntityLiving AIowner, Class target2, float par3, int par4, boolean par5)
I think for now, you should make better separation for your code. Not the actual code, it's just that it's very difficult to tell where one ends, and the other begins. That being said, it's difficult to help. So, for now, either edit your previous post or re-post your question. You can put spoilers within spoilers, which makes things much easier. Here's your code, just separated:
mod_* class:
package net.minecraft.src;
import java.util.Map;
public class mod_MinecraftTotalWar extends BaseMod
{
public void load()
{
//Human Villager
//Entity Human Villager Child
ModLoader.registerEntityID(EntityHumanVillagerChild.class, "Child", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityHumanVillagerChild.class, 12, 14, 18, EnumCreatureType.creature);
//Entity Human Villager Male
ModLoader.registerEntityID(EntityHumanVillagerMale.class, "Man", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityHumanVillagerMale.class, 12, 14, 18, EnumCreatureType.creature);
//Entity Human Villager Female
ModLoader.registerEntityID(EntityHumanVillagerFemale.class, "Woman", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityHumanVillagerFemale.class, 12, 14, 18, EnumCreatureType.creature);
//Human Noble
//Entity Human Noble Child
//Entity Human Noble Male
//Entity Human Noble Female
//Entity Human Noble Knight
//Military
//Mercenary Swordsman
ModLoader.registerEntityID(EntityMercenarySwordsman.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityMercenarySwordsman.class, 12, 14, 24, EnumCreatureType.monster);
//Mercenary Archer
ModLoader.registerEntityID(EntityMercenaryArcher.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityMercenaryArcher.class, 12, 14, 24, EnumCreatureType.monster);
//Militia
//Militia Archers
//Hostile mobs
//Bandit
ModLoader.registerEntityID(EntityBandit.class, "Bandit", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityBandit.class, 12, 14, 24, EnumCreatureType.monster);
//Brigand
ModLoader.registerEntityID(EntityBrigand.class, "Brigand", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityBrigand.class, 11, 14, 20, EnumCreatureType.monster);
//Rebel leader
ModLoader.registerEntityID(EntityRebelLeader.class, "Rebel Leader", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityRebelLeader.class, 8, 14, 16, EnumCreatureType.monster);
}
//spawn list
public void addRenderer(Map map)
{
//Hostile Mobs
map.put(EntityBandit.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityBrigand.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityRebelLeader.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityMercenarySwordsman.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityMercenaryArcher.class, new RenderBiped(new ModelBiped(), 0.5F));
}
public String getVersion()
{
return "1.2.5";
}
}
EntityHumanVillagerMale class:
package net.minecraft.src;
import java.util.Random;
public class EntityHumanVillagerMale extends EntityCreature
{
private int randomTickDivider;
private boolean isMatingFlag;
private boolean isPlayingFlag;
Village villageObj; public EntityHumanVillagerMale(World par1World)
{
this(par1World, 0);
}
public EntityHumanVillagerMale(World par1World, int par2)
{
super(par1World);
randomTickDivider = 0;
isMatingFlag = false;
isPlayingFlag = false;
villageObj = null;
setProfession(par2);
texture = "/mods/VillagerMale.png";
moveSpeed = 0.5F;
getNavigator().setBreakDoors(true);
getNavigator().setAvoidsWater(true);
tasks.addTask(0, new EntityAISwimming(this));
tasks.addTask(1, new EntityAIAvoidEntity(this, net.minecraft.src.EntityZombie.class, 8F, 0.3F, 0.35F));
tasks.addTask(2, new EntityAIMoveIndoors(this));
tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
tasks.addTask(4, new EntityAIOpenDoor(this, true));
tasks.addTask(5, new EntityAIMoveTwardsRestriction(this, 0.3F));
tasks.addTask(6, new EntityAIVillagerMate(this));
tasks.addTask(7, new EntityAIPlay(this, 0.32F));
tasks.addTask(8, new EntityAIWatchClosest2(this, net.minecraft.src.EntityPlayer.class, 3F, 1.0F));
tasks.addTask(8, new EntityAIWatchClosest2(this, net.minecraft.src.EntityVillager.class, 5F, 0.02F));
tasks.addTask(8, new EntityAIWander(this, 0.3F));
tasks.addTask(9, new EntityAIWatchClosest(this, net.minecraft.src.EntityLiving.class, 8F));
} /**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
/**
* main AI tick function, replaces updateEntityActionState
*/
protected void updateAITick()
{
if (--randomTickDivider <= 0)
{
worldObj.villageCollectionObj.addVillagerPosition(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ));
randomTickDivider = 70 + rand.nextInt(50);
villageObj = worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ), 32); if (villageObj == null)
{
detachHome();
}
else
{
ChunkCoordinates chunkcoordinates = villageObj.getCenter();
setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, villageObj.getVillageRadius());
}
}
super.updateAITick();
} protected void entityInit()
{
super.entityInit();
dataWatcher.addObject(16, Integer.valueOf(0));
}
public int getMaxHealth()
{
return 20;
} /**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("Profession", getProfession());
} /**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
setProfession(par1NBTTagCompound.getInteger("Profession"));
}
/**
* Returns the texture's file path as a String.
*/
public String getTexture()
{
switch (getProfession())
{
case 0:
return "/mods/VillagerMale.png"; case 1:
return "/mods/Villager/librarian.png";
case 2:
return "/mods/Villager/priest.png"; case 3:
return "/mods/VillagerMaleSmith.png";
case 4:
return "/mods/VillagerMaleButcher.png";
} return super.getTexture();
}
/**
* Determines if an entity can be despawned, used on idle far away entities
*/
protected boolean canDespawn()
{
return false;
} /**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "mob.villager.default";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.villager.defaulthurt";
} /**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.villager.defaultdeath";
}
public void setProfession(int par1)
{
dataWatcher.updateObject(16, Integer.valueOf(par1));
} public int getProfession()
{
return dataWatcher.getWatchableObjectInt(16);
}
public boolean getIsMatingFlag()
{
return isMatingFlag;
} public void setIsMatingFlag(boolean par1)
{
isMatingFlag = par1;
}
public void setIsPlayingFlag(boolean par1)
{
isPlayingFlag = par1;
} public boolean getIsPlayingFlag()
{
return isPlayingFlag;
}
public void setRevengeTarget(EntityLiving par1EntityLiving)
{
super.setRevengeTarget(par1EntityLiving); if (villageObj != null && par1EntityLiving != null)
{
villageObj.addOrRenewAgressor(par1EntityLiving);
}
}
}
EntityMercenarySwordsman class:
package net.minecraft.src;
public class EntityMercenarySwordsman extends EntityTameable
{
public EntityMercenarySwordsman(World world)
{
super(world);
texture = "/image.png";
moveSpeed = 0.5F;
getNavigator().setBreakDoors(true);
tasks.addTask(1, new EntityAISwimming(this));
tasks.addTask(2, aiSit);
tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
tasks.addTask(4, new EntityAIAttackOnCollide(this, moveSpeed, true));
tasks.addTask(5, new EntityAIFollowOwner(this, moveSpeed, 10F, 2.0F));
tasks.addTask(6, new EntityAISwimming(this));
tasks.addTask(7, new EntityAIWander(this, moveSpeed));
tasks.addTask(8, new EntityAIBreakDoor(this));
tasks.addTask(9, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 8F));
tasks.addTask(9, new EntityAILookIdle(this));
targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
targetTasks.addTask(4, new EntityAITargetNonTamed(this, net.minecraft.src.EntitySheep.class, 16F, 200, false));
}
public boolean isAIEnabled()
{
return true;
}
//Sets the active target the Task system uses for tracking
public void setAttackTarget(EntityLiving par1EntityLiving)
{
super.setAttackTarget(par1EntityLiving); if (par1EntityLiving instanceof EntityPlayer)
{
setAngry(true);
}
}
//Returns the texture's file path as a String.
public String getTexture()
{
if (isTamed())
{
return "/mob/wolf_tame.png";
}
if (isAngry())
{
return "/mob/wolf_angry.png";
}
else
{
return super.getTexture();
}
}
//(abstract) Protected helper method to write subclass entity data to NBT.
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setBoolean("Angry", isAngry());
}
//(abstract) Protected helper method to read subclass entity data from NBT.
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
setAngry(par1NBTTagCompound.getBoolean("Angry"));
}
//Sets whether this badass is angry or not.
public boolean isAngry()
{
return (dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}
public void setAngry(boolean par1)
{
byte byte0 = dataWatcher.getWatchableObjectByte(16); if (par1)
{
dataWatcher.updateObject(16, Byte.valueOf((byte)(byte0 | 2)));
}
else
{
dataWatcher.updateObject(16, Byte.valueOf((byte)(byte0 & -3)));
}
}
//Called when the entity is attacked.
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
{
Entity entity = par1DamageSource.getEntity();
aiSit.setIsSitting(false);
if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
{
par2 = (par2 + 1) / 2;
} return super.attackEntityFrom(par1DamageSource, par2);
}
public boolean attackEntityAsMob(Entity par1Entity)
{
byte byte0 = ((byte)(isTamed() ? 4 : 2));
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), byte0);
}
//anti-crop trampler
protected boolean canTriggerWalking()
{
return false;
} public int getMaxHealth()
{
return 20;
}
public int getTotalArmorValue()
{
return 2;
}
//Mob's weapon held
private static final ItemStack defaultHeldItem;
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
static
{
defaultHeldItem = new ItemStack(Item.swordSteel, 1);
}
//mob sounds
protected String getLivingSound()
{
return "mob.villager.default";
} protected String getHurtSound()
{
return "mob.villager.defaulthurt";
}
protected String getDeathSound()
{
return "mob.villager.defaultdeath";
} protected int getDropItemId()
{
return Item.ingotIron.shiftedIndex;
}
protected boolean canDespawn()
{
return false;
}
//Called when a player interacts with a mob. e.g. giving gold ingots to "tame" mercenary
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (!isTamed())
{
if (itemstack != null && itemstack.itemID == Item.ingotGold.shiftedIndex && !isAngry())
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
itemstack.stackSize--;
} if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
}
if (!worldObj.isRemote)
{
if (rand.nextInt(3) == 0)
{
setTamed(true);
setPathToEntity(null);
setAttackTarget(null);
aiSit.setIsSitting(true);
setEntityHealth(20);
setOwner(par1EntityPlayer.username);
playTameEffect(true);
worldObj.setEntityState(this, (byte)7);
}
else
{
playTameEffect(false);
worldObj.setEntityState(this, (byte)6);
}
} return true;
}
}
else
{
if (itemstack != null && (Item.itemsList[itemstack.itemID] instanceof ItemFood))
{
ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID];
if (itemfood.isWolfsFavoriteMeat() && dataWatcher.getWatchableObjectInt(18) < 20)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
itemstack.stackSize--;
} heal(itemfood.getHealAmount());
if (itemstack.stackSize <= 0)
{
par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null);
} return true;
}
}
if (par1EntityPlayer.username.equalsIgnoreCase(getOwnerName()) && !worldObj.isRemote && !isWheat(itemstack))
{
aiSit.setIsSitting(!isSitting());
isJumping = false;
setPathToEntity(null);
}
} return super.interact(par1EntityPlayer);
}
}
Or better yet, if Techguy looks here for your problem instead, that'd make it easier. So... Oi, Techguy. I've organized the guy above me's code into separate spoilers to make it easier to read for you. I can't help him myself. I've never made entities before.
many thanks, mate I also organized my original post too
Does anyone know what 3 last parameters define here:
EntityAINearestAttackableTarget(EntityLiving AIowner, Class target2, float par3, int par4, boolean par5)
I was never sure what par1, 2, 3, etc. meant
boolean means a true or false statement, I'm 99% sure about that
a float is a type of not-so-precise-but-more-precise-than-an-integer(goes into decimals, but doesn't support a long line of decimals like a double) number, not sure what it means in the context of minecraft :/
Modloader.addrecipe(new Itemstack(pencil, 5), new object [] {'' # ''}, {'' # ''}, {'' @ ''}, Characther.valueof('#'), Item.stick, Characther.valueof('@'), Eraser});
Eraser: my other custom item
Oh, I'm sorry! I thought you were getting errors!
I'll do an example.
ModLoader.addRecipe(new ItemStack(myblock, 1), new Object [] {"###", "###", "###", Character.valueOf('#'), mod_***.customItem});Ok. Here, we want to craft a kind of Ore Storage Block with our new custom item. If you want to use your custom item, you will have to refer it to your mod_*** class, not Item or Block. If you want to use a new block, don't refer it to the Block class. Refer it to your mod_*** class, like your custom item.
I hope it helped!
Edit:
It's not obligate to put spaces around the symbols.
You were right for refering your custom item. You can choose to refer it to the mod_*** class and you can choose not to. Personally, I refer it to the mod_*** class. Around the "#"s, you've put a '{' and a '}'. You must put a '{' to the first one only and you must not put a '}'. You put it only at the end of the line with the ')' and the ';'.
Thats Works!!!
You Are A Best Guy Who Help Me Make a Mod!!
You Really Help Me THANKS!
You're welcome!
If it helped you (I'm talking to everyone, here), feel free to click on the green button on the bottom right of my previous post (because in this one, I just said 'You're welcome').
Sorry D:
My ****in opera mini cant Press that button but this my gift for you
http://www.minecraftforum.net/topic/499266-creating-mods-making-a-new-music-disc-with-modloader-24711/
this for 1 minute searching
Thank you!
I clicked on the green button.
Now, I'm asking for help from anyone who can help me.
I have a(nother) problem:
I can't hear my music! I get no error while recompiling, no crash in-game, I have installed AudioMod, ModLoader and Minecraft Forge, I've put my .ogg music file in both the original streaming folder and in the mod/streaming folder, the file has the same name as the music name of the disc and the music disc fits in the jukebox. It doesn't even show 'Now playing: Namehere.ogg'.
Here is the music disc line of code in mod_***:
public static final Item musicDisc = new ItemDatModNamehereDisc(2030, "Namehere").setIconIndex(48).setItemName("musicdisc");Here's the ItemDatModNamehereDisc class. It's pretty much the same as the ItemRecord class:
package net.minecraft.src; import java.util.List; import net.minecraft.src.forge.*; import net.minecraft.src.forge.ITextureProvider; public class ItemDatModNamehereDisc extends Item implements ITextureProvider { /** The name of the record. */ public final String recordName; protected ItemDatModNamehereDisc(int par1, String par2Str) { super(par1); this.recordName = par2Str; this.maxStackSize = 1; } public String getTextureFile() { return "/DatMod/itemsOther.png"; } /** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS ! */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7) { if (par3World.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0) { if (par3World.isRemote) { return true; } else { ((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, this.shiftedIndex); par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.shiftedIndex); --par1ItemStack.stackSize; return true; } } else { return false; } } /** * allows items to add custom lines of information to the mouseover description */ public void addInformation(ItemStack par1ItemStack, List par2List) { par2List.add("Namehere - " + this.recordName); } /** * Return an item rarity from EnumRarity */ public EnumRarity getRarity(ItemStack par1ItemStack) { return EnumRarity.rare; } }EDIT:
It works when I replace 'new ItemDatModNamehereDisc' by 'new ItemRecord'. When I use the ItemRecord class, the Composer is C418 and I can't use the disc's image. Later, I want to use the disc for something... special. It's personal, but I want my disc to work successfully with ItemDatModNamehereDisc.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumFirstly: Spoilers
Secondly: You should look at lockNload147's tutorial: http://www.minecraft...thout-audiomod/ for how to add sounds
Thirdly: I have no idea how to fix the problem you are having... Sorry
first here is my code:
mod_* class:
package net.minecraft.src; import java.util.Map; public class mod_MinecraftTotalWar extends BaseMod { public void load() { //Human Villager //Entity Human Villager Child ModLoader.registerEntityID(EntityHumanVillagerChild.class, "Child", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityHumanVillagerChild.class, 12, 14, 18, EnumCreatureType.creature); //Entity Human Villager Male ModLoader.registerEntityID(EntityHumanVillagerMale.class, "Man", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityHumanVillagerMale.class, 12, 14, 18, EnumCreatureType.creature); //Entity Human Villager Female ModLoader.registerEntityID(EntityHumanVillagerFemale.class, "Woman", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityHumanVillagerFemale.class, 12, 14, 18, EnumCreatureType.creature); //Human Noble //Entity Human Noble Child //Entity Human Noble Male //Entity Human Noble Female //Entity Human Noble Knight //Military //Mercenary Swordsman ModLoader.registerEntityID(EntityMercenarySwordsman.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityMercenarySwordsman.class, 12, 14, 24, EnumCreatureType.monster); //Mercenary Archer ModLoader.registerEntityID(EntityMercenaryArcher.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityMercenaryArcher.class, 12, 14, 24, EnumCreatureType.monster); //Militia //Militia Archers //Hostile mobs //Bandit ModLoader.registerEntityID(EntityBandit.class, "Bandit", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityBandit.class, 12, 14, 24, EnumCreatureType.monster); //Brigand ModLoader.registerEntityID(EntityBrigand.class, "Brigand", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityBrigand.class, 11, 14, 20, EnumCreatureType.monster); //Rebel leader ModLoader.registerEntityID(EntityRebelLeader.class, "Rebel Leader", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityRebelLeader.class, 8, 14, 16, EnumCreatureType.monster); } //spawn list public void addRenderer(Map map) { //Hostile Mobs map.put(EntityBandit.class, new RenderBiped(new ModelBiped(), 0.5F)); map.put(EntityBrigand.class, new RenderBiped(new ModelBiped(), 0.5F)); map.put(EntityRebelLeader.class, new RenderBiped(new ModelBiped(), 0.5F)); map.put(EntityMercenarySwordsman.class, new RenderBiped(new ModelBiped(), 0.5F)); map.put(EntityMercenaryArcher.class, new RenderBiped(new ModelBiped(), 0.5F)); } public String getVersion() { return "1.2.5"; } }EntityHumanVillagerMale class:
package net.minecraft.src; import java.util.Random; public class EntityHumanVillagerMale extends EntityCreature { private int randomTickDivider; private boolean isMatingFlag; private boolean isPlayingFlag; Village villageObj; public EntityHumanVillagerMale(World par1World) { this(par1World, 0); } public EntityHumanVillagerMale(World par1World, int par2) { super(par1World); randomTickDivider = 0; isMatingFlag = false; isPlayingFlag = false; villageObj = null; setProfession(par2); texture = "/mods/VillagerMale.png"; moveSpeed = 0.5F; getNavigator().setBreakDoors(true); getNavigator().setAvoidsWater(true); tasks.addTask(0, new EntityAISwimming(this)); tasks.addTask(1, new EntityAIAvoidEntity(this, net.minecraft.src.EntityZombie.class, 8F, 0.3F, 0.35F)); tasks.addTask(2, new EntityAIMoveIndoors(this)); tasks.addTask(3, new EntityAIRestrictOpenDoor(this)); tasks.addTask(4, new EntityAIOpenDoor(this, true)); tasks.addTask(5, new EntityAIMoveTwardsRestriction(this, 0.3F)); tasks.addTask(6, new EntityAIVillagerMate(this)); tasks.addTask(7, new EntityAIPlay(this, 0.32F)); tasks.addTask(8, new EntityAIWatchClosest2(this, net.minecraft.src.EntityPlayer.class, 3F, 1.0F)); tasks.addTask(8, new EntityAIWatchClosest2(this, net.minecraft.src.EntityVillager.class, 5F, 0.02F)); tasks.addTask(8, new EntityAIWander(this, 0.3F)); tasks.addTask(9, new EntityAIWatchClosest(this, net.minecraft.src.EntityLiving.class, 8F)); } /** * Returns true if the newer Entity AI code should be run */ public boolean isAIEnabled() { return true; } /** * main AI tick function, replaces updateEntityActionState */ protected void updateAITick() { if (--randomTickDivider <= 0) { worldObj.villageCollectionObj.addVillagerPosition(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)); randomTickDivider = 70 + rand.nextInt(50); villageObj = worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ), 32); if (villageObj == null) { detachHome(); } else { ChunkCoordinates chunkcoordinates = villageObj.getCenter(); setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, villageObj.getVillageRadius()); } } super.updateAITick(); } protected void entityInit() { super.entityInit(); dataWatcher.addObject(16, Integer.valueOf(0)); } public int getMaxHealth() { return 20; } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void onLivingUpdate() { super.onLivingUpdate(); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { super.writeEntityToNBT(par1NBTTagCompound); par1NBTTagCompound.setInteger("Profession", getProfession()); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { super.readEntityFromNBT(par1NBTTagCompound); setProfession(par1NBTTagCompound.getInteger("Profession")); } /** * Returns the texture's file path as a String. */ public String getTexture() { switch (getProfession()) { case 0: return "/mods/VillagerMale.png"; case 1: return "/mods/Villager/librarian.png"; case 2: return "/mods/Villager/priest.png"; case 3: return "/mods/VillagerMaleSmith.png"; case 4: return "/mods/VillagerMaleButcher.png"; } return super.getTexture(); } /** * Determines if an entity can be despawned, used on idle far away entities */ protected boolean canDespawn() { return false; } /** * Returns the sound this mob makes while it's alive. */ protected String getLivingSound() { return "mob.villager.default"; } /** * Returns the sound this mob makes when it is hurt. */ protected String getHurtSound() { return "mob.villager.defaulthurt"; } /** * Returns the sound this mob makes on death. */ protected String getDeathSound() { return "mob.villager.defaultdeath"; } public void setProfession(int par1) { dataWatcher.updateObject(16, Integer.valueOf(par1)); } public int getProfession() { return dataWatcher.getWatchableObjectInt(16); } public boolean getIsMatingFlag() { return isMatingFlag; } public void setIsMatingFlag(boolean par1) { isMatingFlag = par1; } public void setIsPlayingFlag(boolean par1) { isPlayingFlag = par1; } public boolean getIsPlayingFlag() { return isPlayingFlag; } public void setRevengeTarget(EntityLiving par1EntityLiving) { super.setRevengeTarget(par1EntityLiving); if (villageObj != null && par1EntityLiving != null) { villageObj.addOrRenewAgressor(par1EntityLiving); } } }EntityMercenarySwordsman class:
package net.minecraft.src; public class EntityMercenarySwordsman extends EntityTameable { public EntityMercenarySwordsman(World world) { super(world); texture = "/image.png"; moveSpeed = 0.5F; getNavigator().setBreakDoors(true); tasks.addTask(1, new EntityAISwimming(this)); tasks.addTask(2, aiSit); tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); tasks.addTask(4, new EntityAIAttackOnCollide(this, moveSpeed, true)); tasks.addTask(5, new EntityAIFollowOwner(this, moveSpeed, 10F, 2.0F)); tasks.addTask(6, new EntityAISwimming(this)); tasks.addTask(7, new EntityAIWander(this, moveSpeed)); tasks.addTask(8, new EntityAIBreakDoor(this)); tasks.addTask(9, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 8F)); tasks.addTask(9, new EntityAILookIdle(this)); targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); targetTasks.addTask(4, new EntityAITargetNonTamed(this, net.minecraft.src.EntitySheep.class, 16F, 200, false)); } public boolean isAIEnabled() { return true; } //Sets the active target the Task system uses for tracking public void setAttackTarget(EntityLiving par1EntityLiving) { super.setAttackTarget(par1EntityLiving); if (par1EntityLiving instanceof EntityPlayer) { setAngry(true); } } //Returns the texture's file path as a String. public String getTexture() { if (isTamed()) { return "/mob/wolf_tame.png"; } if (isAngry()) { return "/mob/wolf_angry.png"; } else { return super.getTexture(); } } //(abstract) Protected helper method to write subclass entity data to NBT. public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { super.writeEntityToNBT(par1NBTTagCompound); par1NBTTagCompound.setBoolean("Angry", isAngry()); } //(abstract) Protected helper method to read subclass entity data from NBT. public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { super.readEntityFromNBT(par1NBTTagCompound); setAngry(par1NBTTagCompound.getBoolean("Angry")); } //Sets whether this badass is angry or not. public boolean isAngry() { return (dataWatcher.getWatchableObjectByte(16) & 2) != 0; } public void setAngry(boolean par1) { byte byte0 = dataWatcher.getWatchableObjectByte(16); if (par1) { dataWatcher.updateObject(16, Byte.valueOf((byte)(byte0 | 2))); } else { dataWatcher.updateObject(16, Byte.valueOf((byte)(byte0 & -3))); } } //Called when the entity is attacked. public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) { Entity entity = par1DamageSource.getEntity(); aiSit.setIsSitting(false); if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { par2 = (par2 + 1) / 2; } return super.attackEntityFrom(par1DamageSource, par2); } public boolean attackEntityAsMob(Entity par1Entity) { byte byte0 = ((byte)(isTamed() ? 4 : 2)); return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), byte0); } //anti-crop trampler protected boolean canTriggerWalking() { return false; } public int getMaxHealth() { return 20; } public int getTotalArmorValue() { return 2; } //Mob's weapon held private static final ItemStack defaultHeldItem; public ItemStack getHeldItem() { return defaultHeldItem; } static { defaultHeldItem = new ItemStack(Item.swordSteel, 1); } //mob sounds protected String getLivingSound() { return "mob.villager.default"; } protected String getHurtSound() { return "mob.villager.defaulthurt"; } protected String getDeathSound() { return "mob.villager.defaultdeath"; } protected int getDropItemId() { return Item.ingotIron.shiftedIndex; } protected boolean canDespawn() { return false; } //Called when a player interacts with a mob. e.g. giving gold ingots to "tame" mercenary public boolean interact(EntityPlayer par1EntityPlayer) { ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); if (!isTamed()) { if (itemstack != null && itemstack.itemID == Item.ingotGold.shiftedIndex && !isAngry()) { if (!par1EntityPlayer.capabilities.isCreativeMode) { itemstack.stackSize--; } if (itemstack.stackSize <= 0) { par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); } if (!worldObj.isRemote) { if (rand.nextInt(3) == 0) { setTamed(true); setPathToEntity(null); setAttackTarget(null); aiSit.setIsSitting(true); setEntityHealth(20); setOwner(par1EntityPlayer.username); playTameEffect(true); worldObj.setEntityState(this, (byte)7); } else { playTameEffect(false); worldObj.setEntityState(this, (byte)6); } } return true; } } else { if (itemstack != null && (Item.itemsList[itemstack.itemID] instanceof ItemFood)) { ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID]; if (itemfood.isWolfsFavoriteMeat() && dataWatcher.getWatchableObjectInt(18) < 20) { if (!par1EntityPlayer.capabilities.isCreativeMode) { itemstack.stackSize--; } heal(itemfood.getHealAmount()); if (itemstack.stackSize <= 0) { par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); } return true; } } if (par1EntityPlayer.username.equalsIgnoreCase(getOwnerName()) && !worldObj.isRemote && !isWheat(itemstack)) { aiSit.setIsSitting(!isSitting()); isJumping = false; setPathToEntity(null); } } return super.interact(par1EntityPlayer); } }now the errors:
on the EntityHumanVillager.class, there is an error with task 6 and 7, both constructors are undefined, dont know how to fix that problem. What im trying to do is (and I need help with how to do this):
-basically change all testificates to human models
-give testificates genders and depending on their profession, give them special abilities
-have it so that only male and female testificates can mate together and have children
I understand that there is a mod called, minecraft comes alive that does this, but I plan on expanding what im doing.
the second error, is the EntityMercenarySwordsman.class (and mercenary archer too, but they're both the same)
The type EntityMercenarySwordsman must implement the inherited abstract method EntityAnimal.spawnBabyAnimal(EntityAnimal)
tried to do the same as with the wolf, except have it so you give the mercenary gold ingots to "tame" them. basically do everything the wolf does, except for mating. but it seems I did something wrong :/
If anyone could help me with this, it would be appreciated, thanks
edit: don't worry about me getting the textures wrong, im still working on the art
also, one question, I forgot to ask, am I doing the human villager right so far? I mean, should I do them the same as the human_npc tutorial? or do something different, since they will be replacing testificates and be spawning in villages. I know there is a line of code to add that will make it replace EntityVillager.class, but I forgot :/
-
View User Profile
-
View Posts
-
Send Message
Retired StaffI think for now, you should make better separation for your code. Not the actual code, it's just that it's very difficult to tell where one ends, and the other begins. That being said, it's difficult to help. So, for now, either edit your previous post or re-post your question. You can put spoilers within spoilers, which makes things much easier. Here's your code, just separated:
mod_* class:
package net.minecraft.src; import java.util.Map; public class mod_MinecraftTotalWar extends BaseMod { public void load() { //Human Villager //Entity Human Villager Child ModLoader.registerEntityID(EntityHumanVillagerChild.class, "Child", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityHumanVillagerChild.class, 12, 14, 18, EnumCreatureType.creature); //Entity Human Villager Male ModLoader.registerEntityID(EntityHumanVillagerMale.class, "Man", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityHumanVillagerMale.class, 12, 14, 18, EnumCreatureType.creature); //Entity Human Villager Female ModLoader.registerEntityID(EntityHumanVillagerFemale.class, "Woman", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityHumanVillagerFemale.class, 12, 14, 18, EnumCreatureType.creature); //Human Noble //Entity Human Noble Child //Entity Human Noble Male //Entity Human Noble Female //Entity Human Noble Knight //Military //Mercenary Swordsman ModLoader.registerEntityID(EntityMercenarySwordsman.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityMercenarySwordsman.class, 12, 14, 24, EnumCreatureType.monster); //Mercenary Archer ModLoader.registerEntityID(EntityMercenaryArcher.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityMercenaryArcher.class, 12, 14, 24, EnumCreatureType.monster); //Militia //Militia Archers //Hostile mobs //Bandit ModLoader.registerEntityID(EntityBandit.class, "Bandit", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityBandit.class, 12, 14, 24, EnumCreatureType.monster); //Brigand ModLoader.registerEntityID(EntityBrigand.class, "Brigand", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityBrigand.class, 11, 14, 20, EnumCreatureType.monster); //Rebel leader ModLoader.registerEntityID(EntityRebelLeader.class, "Rebel Leader", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityRebelLeader.class, 8, 14, 16, EnumCreatureType.monster); } //spawn list public void addRenderer(Map map) { //Hostile Mobs map.put(EntityBandit.class, new RenderBiped(new ModelBiped(), 0.5F)); map.put(EntityBrigand.class, new RenderBiped(new ModelBiped(), 0.5F)); map.put(EntityRebelLeader.class, new RenderBiped(new ModelBiped(), 0.5F)); map.put(EntityMercenarySwordsman.class, new RenderBiped(new ModelBiped(), 0.5F)); map.put(EntityMercenaryArcher.class, new RenderBiped(new ModelBiped(), 0.5F)); } public String getVersion() { return "1.2.5"; } }EntityHumanVillagerMale class:
package net.minecraft.src; import java.util.Random; public class EntityHumanVillagerMale extends EntityCreature { private int randomTickDivider; private boolean isMatingFlag; private boolean isPlayingFlag; Village villageObj; public EntityHumanVillagerMale(World par1World) { this(par1World, 0); } public EntityHumanVillagerMale(World par1World, int par2) { super(par1World); randomTickDivider = 0; isMatingFlag = false; isPlayingFlag = false; villageObj = null; setProfession(par2); texture = "/mods/VillagerMale.png"; moveSpeed = 0.5F; getNavigator().setBreakDoors(true); getNavigator().setAvoidsWater(true); tasks.addTask(0, new EntityAISwimming(this)); tasks.addTask(1, new EntityAIAvoidEntity(this, net.minecraft.src.EntityZombie.class, 8F, 0.3F, 0.35F)); tasks.addTask(2, new EntityAIMoveIndoors(this)); tasks.addTask(3, new EntityAIRestrictOpenDoor(this)); tasks.addTask(4, new EntityAIOpenDoor(this, true)); tasks.addTask(5, new EntityAIMoveTwardsRestriction(this, 0.3F)); tasks.addTask(6, new EntityAIVillagerMate(this)); tasks.addTask(7, new EntityAIPlay(this, 0.32F)); tasks.addTask(8, new EntityAIWatchClosest2(this, net.minecraft.src.EntityPlayer.class, 3F, 1.0F)); tasks.addTask(8, new EntityAIWatchClosest2(this, net.minecraft.src.EntityVillager.class, 5F, 0.02F)); tasks.addTask(8, new EntityAIWander(this, 0.3F)); tasks.addTask(9, new EntityAIWatchClosest(this, net.minecraft.src.EntityLiving.class, 8F)); } /** * Returns true if the newer Entity AI code should be run */ public boolean isAIEnabled() { return true; } /** * main AI tick function, replaces updateEntityActionState */ protected void updateAITick() { if (--randomTickDivider <= 0) { worldObj.villageCollectionObj.addVillagerPosition(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)); randomTickDivider = 70 + rand.nextInt(50); villageObj = worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ), 32); if (villageObj == null) { detachHome(); } else { ChunkCoordinates chunkcoordinates = villageObj.getCenter(); setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, villageObj.getVillageRadius()); } } super.updateAITick(); } protected void entityInit() { super.entityInit(); dataWatcher.addObject(16, Integer.valueOf(0)); } public int getMaxHealth() { return 20; } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void onLivingUpdate() { super.onLivingUpdate(); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { super.writeEntityToNBT(par1NBTTagCompound); par1NBTTagCompound.setInteger("Profession", getProfession()); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { super.readEntityFromNBT(par1NBTTagCompound); setProfession(par1NBTTagCompound.getInteger("Profession")); } /** * Returns the texture's file path as a String. */ public String getTexture() { switch (getProfession()) { case 0: return "/mods/VillagerMale.png"; case 1: return "/mods/Villager/librarian.png"; case 2: return "/mods/Villager/priest.png"; case 3: return "/mods/VillagerMaleSmith.png"; case 4: return "/mods/VillagerMaleButcher.png"; } return super.getTexture(); } /** * Determines if an entity can be despawned, used on idle far away entities */ protected boolean canDespawn() { return false; } /** * Returns the sound this mob makes while it's alive. */ protected String getLivingSound() { return "mob.villager.default"; } /** * Returns the sound this mob makes when it is hurt. */ protected String getHurtSound() { return "mob.villager.defaulthurt"; } /** * Returns the sound this mob makes on death. */ protected String getDeathSound() { return "mob.villager.defaultdeath"; } public void setProfession(int par1) { dataWatcher.updateObject(16, Integer.valueOf(par1)); } public int getProfession() { return dataWatcher.getWatchableObjectInt(16); } public boolean getIsMatingFlag() { return isMatingFlag; } public void setIsMatingFlag(boolean par1) { isMatingFlag = par1; } public void setIsPlayingFlag(boolean par1) { isPlayingFlag = par1; } public boolean getIsPlayingFlag() { return isPlayingFlag; } public void setRevengeTarget(EntityLiving par1EntityLiving) { super.setRevengeTarget(par1EntityLiving); if (villageObj != null && par1EntityLiving != null) { villageObj.addOrRenewAgressor(par1EntityLiving); } } }EntityMercenarySwordsman class:
package net.minecraft.src; public class EntityMercenarySwordsman extends EntityTameable { public EntityMercenarySwordsman(World world) { super(world); texture = "/image.png"; moveSpeed = 0.5F; getNavigator().setBreakDoors(true); tasks.addTask(1, new EntityAISwimming(this)); tasks.addTask(2, aiSit); tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); tasks.addTask(4, new EntityAIAttackOnCollide(this, moveSpeed, true)); tasks.addTask(5, new EntityAIFollowOwner(this, moveSpeed, 10F, 2.0F)); tasks.addTask(6, new EntityAISwimming(this)); tasks.addTask(7, new EntityAIWander(this, moveSpeed)); tasks.addTask(8, new EntityAIBreakDoor(this)); tasks.addTask(9, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 8F)); tasks.addTask(9, new EntityAILookIdle(this)); targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); targetTasks.addTask(4, new EntityAITargetNonTamed(this, net.minecraft.src.EntitySheep.class, 16F, 200, false)); } public boolean isAIEnabled() { return true; } //Sets the active target the Task system uses for tracking public void setAttackTarget(EntityLiving par1EntityLiving) { super.setAttackTarget(par1EntityLiving); if (par1EntityLiving instanceof EntityPlayer) { setAngry(true); } } //Returns the texture's file path as a String. public String getTexture() { if (isTamed()) { return "/mob/wolf_tame.png"; } if (isAngry()) { return "/mob/wolf_angry.png"; } else { return super.getTexture(); } } //(abstract) Protected helper method to write subclass entity data to NBT. public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { super.writeEntityToNBT(par1NBTTagCompound); par1NBTTagCompound.setBoolean("Angry", isAngry()); } //(abstract) Protected helper method to read subclass entity data from NBT. public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { super.readEntityFromNBT(par1NBTTagCompound); setAngry(par1NBTTagCompound.getBoolean("Angry")); } //Sets whether this badass is angry or not. public boolean isAngry() { return (dataWatcher.getWatchableObjectByte(16) & 2) != 0; } public void setAngry(boolean par1) { byte byte0 = dataWatcher.getWatchableObjectByte(16); if (par1) { dataWatcher.updateObject(16, Byte.valueOf((byte)(byte0 | 2))); } else { dataWatcher.updateObject(16, Byte.valueOf((byte)(byte0 & -3))); } } //Called when the entity is attacked. public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) { Entity entity = par1DamageSource.getEntity(); aiSit.setIsSitting(false); if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { par2 = (par2 + 1) / 2; } return super.attackEntityFrom(par1DamageSource, par2); } public boolean attackEntityAsMob(Entity par1Entity) { byte byte0 = ((byte)(isTamed() ? 4 : 2)); return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), byte0); } //anti-crop trampler protected boolean canTriggerWalking() { return false; } public int getMaxHealth() { return 20; } public int getTotalArmorValue() { return 2; } //Mob's weapon held private static final ItemStack defaultHeldItem; public ItemStack getHeldItem() { return defaultHeldItem; } static { defaultHeldItem = new ItemStack(Item.swordSteel, 1); } //mob sounds protected String getLivingSound() { return "mob.villager.default"; } protected String getHurtSound() { return "mob.villager.defaulthurt"; } protected String getDeathSound() { return "mob.villager.defaultdeath"; } protected int getDropItemId() { return Item.ingotIron.shiftedIndex; } protected boolean canDespawn() { return false; } //Called when a player interacts with a mob. e.g. giving gold ingots to "tame" mercenary public boolean interact(EntityPlayer par1EntityPlayer) { ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); if (!isTamed()) { if (itemstack != null && itemstack.itemID == Item.ingotGold.shiftedIndex && !isAngry()) { if (!par1EntityPlayer.capabilities.isCreativeMode) { itemstack.stackSize--; } if (itemstack.stackSize <= 0) { par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); } if (!worldObj.isRemote) { if (rand.nextInt(3) == 0) { setTamed(true); setPathToEntity(null); setAttackTarget(null); aiSit.setIsSitting(true); setEntityHealth(20); setOwner(par1EntityPlayer.username); playTameEffect(true); worldObj.setEntityState(this, (byte)7); } else { playTameEffect(false); worldObj.setEntityState(this, (byte)6); } } return true; } } else { if (itemstack != null && (Item.itemsList[itemstack.itemID] instanceof ItemFood)) { ItemFood itemfood = (ItemFood)Item.itemsList[itemstack.itemID]; if (itemfood.isWolfsFavoriteMeat() && dataWatcher.getWatchableObjectInt(18) < 20) { if (!par1EntityPlayer.capabilities.isCreativeMode) { itemstack.stackSize--; } heal(itemfood.getHealAmount()); if (itemstack.stackSize <= 0) { par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); } return true; } } if (par1EntityPlayer.username.equalsIgnoreCase(getOwnerName()) && !worldObj.isRemote && !isWheat(itemstack)) { aiSit.setIsSitting(!isSitting()); isJumping = false; setPathToEntity(null); } } return super.interact(par1EntityPlayer); } }Or better yet, if Techguy looks here for your problem instead, that'd make it easier. So... Oi, Techguy.
EntityAINearestAttackableTarget(EntityLiving AIowner, Class target2, float par3, int par4, boolean par5)
many thanks, mate
I was never sure what par1, 2, 3, etc. meant
boolean means a true or false statement, I'm 99% sure about that
a float is a type of not-so-precise-but-more-precise-than-an-integer(goes into decimals, but doesn't support a long line of decimals like a double) number, not sure what it means in the context of minecraft :/
1.Where is it the code to make the entity walk towards you?
2.How do you make it go away from you?
P.S.
thanks for your tutorials
package net.minecraft.src; import java.util.Map; public class mod_MinecraftTotalWar extends BaseMod { public void load() { //Mercenary Swordsman ModLoader.registerEntityID(EntityMercenarySwordsman.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityMercenarySwordsman.class, 12, 14, 24, EnumCreatureType.monster); //Mercenary Archer ModLoader.registerEntityID(EntityMercenaryArcher.class, "Mercenary Swordsman", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityMercenaryArcher.class, 12, 14, 24, EnumCreatureType.monster); } public void addRenderer(Map map) { map.put(EntityMercenarySwordsman.class, new RenderBiped(new ModelBiped(), 0.5F)); map.put(EntityMercenaryArcher.class, new RenderBiped(new ModelBiped(), 0.5F)); } public String getVersion() { return "1.2.5"; } }here you go
thanx