Here's the coding so far, this is the one that still gives me groups of 2 of the mob here and there, which should only be spawning 1.
package net.minecraft.src;
public class EntitySenku extends EntityMobs
{
public EntitySenku(World world)
{
super(world);
//This is the texture for your mob
texture = "/mob/senku.png";
moveSpeed = 1.0F;
attackStrength = 6;
health = 20;
isImmuneToFire = true;
}
protected Entity findPlayerToAttack()
{
float f = getEntityBrightness(15.0F);
if(f < 0.5F)
{
double d = 16D;
return worldObj.getClosestPlayerToEntity(this, d);
} else
{
return null;
}
}
protected int getDropItemId()
{
// Replace with custom sword when it's created
return Item.swordGold.shiftedIndex;
}
public boolean getCanSpawnHere()
{
if(worldObj.countEntities(this.getClass()) > 1)
{
return false;
}
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
int l = worldObj.getBlockId(i, j - 1, k);
return worldObj.checkIfAABBIsClear(boundingBox) && worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0 && worldObj.getBlockLightValue(i, j, k) > 8 && !worldObj.getIsAnyLiquid(boundingBox);
}
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
private static final ItemStack defaultHeldItem;
static // Replace with custom sword when it's created
{
defaultHeldItem = new ItemStack(Item.swordGold, 1);
}
}
I don't fully trust the spider attack code since it goes by lighting, but at least it currently attacks me in sunlight if I smack it, though sometimes it stops attacking me too as well as when I buried it in dirt it attacked me when I unburied it. Still need it to ALWAYS drop 1 of the getDropItem.
You are telling the code not to spawn more if there is already more than 1 in the game, or in other words, if there are 2. Either put an = after the > or change the 1 to a 0. If that doesn't work, please let me know. Also I dont know if it is possible to tell it to ALWAYS drop that item. Also, it looks like you MIGHT be able to change this code
Here is my modified code.Its called EntityDug.java( a random name ). With this code your mob will hold a golden sword which you can change if you want and will act like zombie pigmen. It will basicly attack you when you hit him. Also, like zombie pigmen, if there is another one around they will attack you too. What i did was to basicly add in some code from zombie pigmen and also EntityMobs.java file. They also make Zombiepigmen sounds.Also i have modified the drops, so you can change what they drop.
For the posts above, yes you can change what your mob drops at what quantity.
Just change :
protected int getDropItemId()
{
//This is the item your mob will drop
return Item.porkCooked.shiftedIndex;
}
with ;
public void func_21077_o()
{
dropItem(Item.porkCooked.shiftedIndex, 2);
}
Look below for more information.
Just putting it here so modders take a peek.Also adding options and some hints.Whoever needs help can get this code and paste some parts of it in to , for example, modify what their mob drops.
My mobs name is "Dug" , so change that name with your mobs name in every line.
As you notice, the first move speed is when the mob isn't attacking you. The second one would be when the mob attacks you.So for example ;
moveSpeed = playerToAttack == null ? 0.1F : 0.1F;
This would make the mob attack us at the same speed when he is idle.
Option 4
----> To change in what difficulty the mob can't spawn, or will disappear in, just change this line.
if(worldObj.difficultySetting == 0)
and this line ;
return worldObj.difficultySetting > 0
----> Change the number to anything between 0 and 3. 0 being peacefull and 3 being Hard difficulty.For example :
if(worldObj.difficultySetting == 1)
return worldObj.difficultySetting > 1
Doing so will make the mob disappear when the difficulty is set to Easy and the mob won't also spawn anymore.I believe it also restricts peacefull difficulty because it is below it.
Option 5
----> To change the amount of what the mob drops( and also item) change this.
dropItem(Item.porkCooked.shiftedIndex, 2);
----> To any amount. I don't know if there is a limit to it though.Just try.
dropItem(Item.porkCooked.shiftedIndex, 3);
That will make it drop 3 cooked pork.Cheers!
So thats basicly it.You can look around the code because there are some other couple of things that you can change such as sounds(when the mob is angry etc),angrylevel and attacktime(?).Thanks to this tutorial i was able to make an entity mob and edit it in all means.Thanks to the author/s.
Just wondering, where do the "void func_##_o" things come from? I've seen them a few times but could never find what they originate to in files.
Also is possible to make it so if I hurt the mob or kill it, since there's only one supposed to spawn at a time, that if I see the same one again or a new one spawns and I see it within a length of time after hurting/killing it it'll attack me, otherwise it'll go back to passive aggressive?
Is there also a way I can make it fire a projectile like an arrow or fireball when out of melee range, but not be able to do so if it's in water, but also still be able to hurt the player by bumping into them if they get in melee range?
Just wondering, where do the "void func_##_o" things come from? I've seen them a few times but could never find what they originate to in files.
Also is possible to make it so if I hurt the mob or kill it, since there's only one supposed to spawn at a time, that if I see the same one again or a new one spawns and I see it within a length of time after hurting/killing it it'll attack me, otherwise it'll go back to passive aggressive?
Is there also a way I can make it fire a projectile like an arrow or fireball when out of melee range, but not be able to do so if it's in water, but also still be able to hurt the player by bumping into them if they get in melee range?
the void func things are what I believe to be a result of MCP decompiling custom code. I could be wrong but I think that's what it is. If they turn up in my code it's because my code is based off of others' custom codes at some points. If you kill your mob, it will not attack when it respawns. I don't think it would be possible to make that happen, and if it is, I have no idea how. Also the forgiveness thing, if you can find a way to set a timer, and have them forgive you when the timer is up, that would be the only way I could think of it working. I'll see if I can write that code tomorrow.
Rollback Post to RevisionRollBack
GENERATION 25: The first time you see this, copy it into your sig on any forum and add 1 to the generation.
Ah, i didn't know they could wield blocks with that code.Thats a nice experiment.Anyways i'm wondering if we could make them wield random blocks/items from a specified list when they spawn? That would save us time from making different mobs that wield different items/blocks.
I got this error when I tried to recompile after copying your code and changing it to my settings. Here's my code:
I've just tried your code and i got no error while recompiling it.Please first make sure that you have all required files that the author of the first post indicates.Such as modloader files etc.After that make sure that your Entity is added to the mod_Modname file.Such as mod_Ghoul.java etc.
Here is mod_Ghoul file for your EntityGhoul which should be placed to src.
package net.minecraft.src;
import java.lang.reflect.Method;
import java.util.Map;
public class mod_Ghoul extends BaseMod
{
public String Version()
{
//not sure exactly what this does, but I know that you can write pretty much anything you want in there.
return "mod_Ghoul version 0.3";
}
public mod_Ghoul()
{
ModLoader.RegisterEntityID(EntityGhoul.class, "Ghoul", ModLoader.getUniqueEntityId());
spawnlist.add("Surface biomes", 1, new Object[] {
EntityGhoul.class
});
}
//this part gives your mob a human model. This part is necessary if you want your mob to be able to carry stuff.
public void AddRenderer(Map map)
{
map.put(EntityGhoul.class, new RenderBiped(new ModelBiped(), 0.5F));
}
}
Also make sure that you made no line mistakes.I don't know.
i got this error saying
sources\minecraft\net\src\EntityMiner.java:94: cannot find symbol
symbol : variable entityminer
location: class net.minecraft.src.EntityMiner
entityminer.becomeAngryAt<entity>;
1 error everything else is fine PLEASE HELP id appreciate it
heres my code
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class EntityMiner extends EntityCreature
{
public EntityMiner(World world)
{
super(world);
//This is the texture for your mob
texture = "/mob/Miner.png";
attackStrength = 2;
moveSpeed = 0.5F;
randomSoundDelay = 0;
angerLevel = 0;
}
I got this error when I tried to recompile after copying your code and changing it to my settings. Here's my code:
I've just tried your code and i got no error while recompiling it.Please first make sure that you have all required files that the author of the first post indicates.Such as modloader files etc.After that make sure that your Entity is added to the mod_Modname file.Such as mod_Ghoul.java etc.
Here is mod_Ghoul file for your EntityGhoul which should be placed to src.
package net.minecraft.src;
import java.lang.reflect.Method;
import java.util.Map;
public class mod_Ghoul extends BaseMod
{
public String Version()
{
//not sure exactly what this does, but I know that you can write pretty much anything you want in there.
return "mod_Ghoul version 0.3";
}
public mod_Ghoul()
{
ModLoader.RegisterEntityID(EntityGhoul.class, "Ghoul", ModLoader.getUniqueEntityId());
spawnlist.add("Surface biomes", 1, new Object[] {
EntityGhoul.class
});
}
//this part gives your mob a human model. This part is necessary if you want your mob to be able to carry stuff.
public void AddRenderer(Map map)
{
map.put(EntityGhoul.class, new RenderBiped(new ModelBiped(), 0.5F));
}
}
Also make sure that you made no line mistakes.I don't know.
I figured out my issue and it recompiled fine. But when I started it up, I couldn't find my mob anywhere. Right now, I am using your mod_Ghoul file. I think it was a little different than mine. But I'm still having trouble finding my mob. can you help on the "difficulty" thing? i didn't understand what you said on the previous page.
You can notice in these codes the line "worldObj.difficultySetting" and afterwards a number.This number specifies the difficulty.So 0 is peacefull , 1 is easy, 2 is normal and 3 is hard difficulty.On your lines, you have put one of them 3 and one of them 1. This should conflict.You see, one of them prevents the mobs from spawning while one of them kills the entity when the difficulty is set.
So overall, you should change both of those numbers to the same thing.Like so:
This will make your mob or entity not spawn in easy difficulty or lower.Also the entity will despawn if it is in the chunk.If you set the difficulty to Normal ingame you should be able to see your entity.
Here is the overall modified code of your ghoul . The mob will spawn on normal difficulty or higher.
Ok. I think I did all that. but now I have two questions. Can you check that for how many appear at one time? I wanted it to be 50 but I'm not sure if I did it right. Second question. Where do the mod_Ghoul.class and EntityGhoul.class files go? directly into the minecraft.jar or somewhere else?
Ok. I think I did all that. but now I have two questions. Can you check that for how many appear at one time? I wanted it to be 50 but I'm not sure if I did it right. Second question. Where do the mod_Ghoul.class and EntityGhoul.class files go? directly into the minecraft.jar or somewhere else?
Like the author said.You simply have to add this somewhere in your code.
public int getMaxSpawnedInChunk()
{
return 1;
}
And also you should modify the number here to set the max amount of spawned entity in the chunk.
As for the second question, yes.They go to minecraft.jar like any mod installation.You also have to delete META-INF if you haven't already.Also install modloader and spawnlist into the jar(with all files).
Well the spawn limiting code is working pretty well, except for the fact that I lured my mob from one chunk to another chunk and ran into a second of the mob. D:
with this
to make your mob only attack if attacked. But I'm not 100% on that.
For the posts above, yes you can change what your mob drops at what quantity.
Just change :
with ;
Look below for more information.
Just putting it here so modders take a peek.Also adding options and some hints.Whoever needs help can get this code and paste some parts of it in to , for example, modify what their mob drops.
My mobs name is "Dug" , so change that name with your mobs name in every line.
Option 1
----> So, to change the weapon he is holding you would basicly change
defaultHeldItem = new ItemStack(Item.swordGold, 1);
---->To for example :
defaultHeldItem = new ItemStack(Item.swordStone, 1);
( a list of items are in Items.java file )
Option 2
----> To change the damage the mob deals when it attacks, you would change this line.
attackStrength = 5;
---->To whatever you wish, for example :
attackStrength = 1;
Option 3
----> To change the speed of the mob, when attacking or when not attacking, you would change this line.
moveSpeed = 0.5F;
and also this line:
moveSpeed = playerToAttack == null ? 0.5F : 0.95F;
----> To whatever you wish. For example :
moveSpeed = 0.1F;
moveSpeed = playerToAttack == null ? 0.1F : 0.95F;
As you notice, the first move speed is when the mob isn't attacking you. The second one would be when the mob attacks you.So for example ;
moveSpeed = playerToAttack == null ? 0.1F : 0.1F;
This would make the mob attack us at the same speed when he is idle.
Option 4
----> To change in what difficulty the mob can't spawn, or will disappear in, just change this line.
if(worldObj.difficultySetting == 0)
and this line ;
return worldObj.difficultySetting > 0
----> Change the number to anything between 0 and 3. 0 being peacefull and 3 being Hard difficulty.For example :
if(worldObj.difficultySetting == 1)
return worldObj.difficultySetting > 1
Doing so will make the mob disappear when the difficulty is set to Easy and the mob won't also spawn anymore.I believe it also restricts peacefull difficulty because it is below it.
Option 5
----> To change the amount of what the mob drops( and also item) change this.
dropItem(Item.porkCooked.shiftedIndex, 2);
----> To any amount. I don't know if there is a limit to it though.Just try.
dropItem(Item.porkCooked.shiftedIndex, 3);
That will make it drop 3 cooked pork.Cheers!
So thats basicly it.You can look around the code because there are some other couple of things that you can change such as sounds(when the mob is angry etc),angrylevel and attacktime(?).Thanks to this tutorial i was able to make an entity mob and edit it in all means.Thanks to the author/s.
------------------------------------------------------------------------------------------
Also is possible to make it so if I hurt the mob or kill it, since there's only one supposed to spawn at a time, that if I see the same one again or a new one spawns and I see it within a length of time after hurting/killing it it'll attack me, otherwise it'll go back to passive aggressive?
Is there also a way I can make it fire a projectile like an arrow or fireball when out of melee range, but not be able to do so if it's in water, but also still be able to hurt the player by bumping into them if they get in melee range?
the void func things are what I believe to be a result of MCP decompiling custom code. I could be wrong but I think that's what it is. If they turn up in my code it's because my code is based off of others' custom codes at some points. If you kill your mob, it will not attack when it respawns. I don't think it would be possible to make that happen, and if it is, I have no idea how. Also the forgiveness thing, if you can find a way to set a timer, and have them forgive you when the timer is up, that would be the only way I could think of it working. I'll see if I can write that code tomorrow.
I got this error when I tried to recompile after copying your code and changing it to my settings. Here's my code:
EDIT: I fixed my problem. I think I accidentally deleted a few files. This is a great tutorial!
I've just tried your code and i got no error while recompiling it.Please first make sure that you have all required files that the author of the first post indicates.Such as modloader files etc.After that make sure that your Entity is added to the mod_Modname file.Such as mod_Ghoul.java etc.
Here is mod_Ghoul file for your EntityGhoul which should be placed to src.
Also make sure that you made no line mistakes.I don't know.
sources\minecraft\net\src\EntityMiner.java:94: cannot find symbol
symbol : variable entityminer
location: class net.minecraft.src.EntityMiner
entityminer.becomeAngryAt<entity>;
1 error everything else is fine PLEASE HELP id appreciate it
heres my code
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class EntityMiner extends EntityCreature
{
public EntityMiner(World world)
{
super(world);
//This is the texture for your mob
texture = "/mob/Miner.png";
attackStrength = 2;
moveSpeed = 0.5F;
randomSoundDelay = 0;
angerLevel = 0;
}
protected void attackEntity(Entity entity, float f)
{
if((double)f < 2.5D && entity.boundingBox.maxY > boundingBox.minY && entity.boundingBox.minY < boundingBox.maxY)
{
attackTime = 20;
entity.attackEntityFrom(this, attackStrength);
}
}
public void onUpdate()
{
moveSpeed = playerToAttack == null ? 0.5F : 0.95F;
if(randomSoundDelay > 0 && --randomSoundDelay == 0)
{
worldObj.playSoundAtEntity(this, "mob.zombiepig.zpigangry", getSoundVolume() * 2.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F) * 1.8F);
}
super.onUpdate();
if(worldObj.difficultySetting == 0)
{
setEntityDead();
}
}
public boolean getCanSpawnHere()
{
if(worldObj.countEntities(this.getClass()) >= 15){
return false;
}
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
int l = worldObj.getBlockId(i, j - 1, k);
return worldObj.difficultySetting > 0 && worldObj.checkIfAABBIsClear(boundingBox) && worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0 && !worldObj.getIsAnyLiquid(boundingBox);
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound);
nbttagcompound.setShort("Anger", (short)angerLevel);
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound);
angerLevel = nbttagcompound.getShort("Anger");
}
protected Entity findPlayerToAttack()
{
if(angerLevel == 0)
{
return null;
} else
{
return super.findPlayerToAttack();
}
}
public void onLivingUpdate()
{
super.onLivingUpdate();
}
public boolean attackEntityFrom(Entity entity, int i)
{
if(entity instanceof EntityPlayer)
{
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(32D, 32D, 32D));
for(int j = 0; j < list.size(); j++)
{
Entity entity1 = (Entity)list.get(j);
if(entity1 instanceof EntityMiner)
{
EntityMiner entityMiner = (EntityMiner)entity1;
entityminer.becomeAngryAt(entity);
}
}
becomeAngryAt(entity);
}
return super.attackEntityFrom(entity, i);
}
private void becomeAngryAt(Entity entity)
{
playerToAttack = entity;
angerLevel = 400 + rand.nextInt(400);
randomSoundDelay = rand.nextInt(40);
}
protected String getLivingSound()
{
return "mob.zombiepig.zpig";
}
protected String getHurtSound()
{
return "mob.zombiepig.zpighurt";
}
protected String getDeathSound()
{
return "mob.zombiepig.zpigdeath";
}
public void func_21077_o()
{
dropItem(Item.ingotIron.shiftedIndex, 2);
}
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
private int angerLevel;
private int randomSoundDelay;
private static final ItemStack defaultHeldItem;
static
{
defaultHeldItem = new ItemStack(Item.swordStone, 1);
}
protected int attackStrength;
}
Anyways, seems like i fixed your EntityMiner code.I don't know what the problem was.It was just a bit messed up.
i really appreciate it
Edit 2 :this is my 69'th post LMAO
It's allright just use a better editing program.It makes it easier.
Notepad ++ is what i use.Try it out! ( No , i'm not an advertiser or a bot :tongue.gif:)
Notepad++ is one of the best free text editors, specifically made for writing code.
I figured out my issue and it recompiled fine. But when I started it up, I couldn't find my mob anywhere. Right now, I am using your mod_Ghoul file. I think it was a little different than mine. But I'm still having trouble finding my mob. can you help on the "difficulty" thing? i didn't understand what you said on the previous page.
You can notice in these codes the line "worldObj.difficultySetting" and afterwards a number.This number specifies the difficulty.So 0 is peacefull , 1 is easy, 2 is normal and 3 is hard difficulty.On your lines, you have put one of them 3 and one of them 1. This should conflict.You see, one of them prevents the mobs from spawning while one of them kills the entity when the difficulty is set.
So overall, you should change both of those numbers to the same thing.Like so:
and;
This will make your mob or entity not spawn in easy difficulty or lower.Also the entity will despawn if it is in the chunk.If you set the difficulty to Normal ingame you should be able to see your entity.
Here is the overall modified code of your ghoul . The mob will spawn on normal difficulty or higher.
Like the author said.You simply have to add this somewhere in your code.
And also you should modify the number here to set the max amount of spawned entity in the chunk.
For example 5 to 10 will make max spawns to 10.
As for the second question, yes.They go to minecraft.jar like any mod installation.You also have to delete META-INF if you haven't already.Also install modloader and spawnlist into the jar(with all files).
how do i make a mob wield a bow and shoot arrows?