By more than one mob do you mean at a time? Because that's not possible. Separately, yes. I'm currently using Mr Okushama's code to do so, but I have his permission to distribute my mod with his targeting system. I'll upload the mod probably tonight. I'll pm you explaining how everything in my mod works, and what parts you will need to use the same targeting system, if you'd like to do so.(I recommend you do because if you use the Mo' Creatures mod you might have a problem with your mobs killing horses.)
Well if later on you would like to do some sort of collab I wrote a mod that I never released based off of most of the code I helped you with, for Chaos Knights in the nether. If you're interested in merging that with your mod just let me know(don't feel pressured it's just an idea lol).
that'd be awesome! but i think this post died lol but heck why not. ps im still testing on the new mobs that attack each other
Sweet. I'll do some tweaking on my code, and some work on the textures. My mobs are split into three passive aggressive groups, each group aggressive towards the other two. Since all three are found in the nether, Idk what you want to set up as far as allegiance goes towards your mobs.
Well if later on you would like to do some sort of collab I wrote a mod that I never released based off of most of the code I helped you with, for Chaos Knights in the nether. If you're interested in merging that with your mod just let me know(don't feel pressured it's just an idea lol).
i figured out how to make them attack other mobs
heres the code
protected Entity findPlayerToAttack()
{
double d1 = -1D;
EntityRedLeader RedLeader = null;
//check each entity that is in the world
for(int i = 0; i < worldObj.loadedEntityList.size(); i++)
{
Entity entity1 = (Entity)worldObj.loadedEntityList.get(i);
//if entity is not a sheep, check next entity on entityList
if(!(entity1 instanceof EntityRedLeader))
{
continue;
}
//if sheep, check how far it is from goat.
//The closest "seen" sheep within a distance of 16 will be identified by the sheep variable.
double d2 = entity1.getDistance(posX, posY, posZ);
if((d2 < 16) && (d1 == -1D || d2 < d1) && ((EntityRedLeader)entity1).canEntityBeSeen(this))
{
d1 = d2;
RedLeader = (EntityRedLeader)entity1;
}
}
return RedLeader; //returns the closest sheep to the goat
}
makes them kill the redleader
Brilliant. Where did you find that code, I use one very similar to that but I can't release it due to the fact that i pretty much stole it from the humans+ code. Where did you find that one? Or did you write it yourself?
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
Is there a way to add multiple mobs to the same mod_name file? I was going to copy the same mob code in the file, but looking at sources of other mods(such as mo creatures) it didn't seem like the thing to do, so thought i'd ask here, also, great tutorial, works perfectly :biggrin.gif:
<Snip>
Thanks! Worked perfectly :biggrin.gif: However, at night, the mobs which are like the pigs, sheep and so on seem to mass spawn, (I need to add the limit code yet) however, is there a way to stop this from happening? They literally roam the place frightening creepers :tongue.gif:
Adding the limit code is the only way I can think to do this. Also if you would like limit their spawns AND spread them out a bit, add this code somewhere too
public int getMaxSpawnedInChunk()
{
return 1;
}
that can go anywhere(not under the getCanSpawnHere code) and it's pretty self explanatory what that does.
Put this bit of code somewhere in Entitygman above the last } in your code.
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);
worldObj.checkIfAABBIsClear(boundingBox);
return worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0 && !worldObj.getIsAnyLiquid(boundingBox);
}
change that 1 to however many of that mob you want to exist at any given time. There's also a method to make them spawn on certain blocks if you'd like that. As for protecting you, I can't tell you how to make them follow and guard you because I'm still working on that myself. I will see if I can get them only attacking certain mobs, I will get back to you if I do.
I laughed quite a lot reading through this thread. Kudos to the king for still modding despite this jerk, and kudos to the OP for still trying to get someone to mod this after the last 11 pages. Bravo.
Fantastic guide! I've been having trouble with the older guide and this is exactly what I needed! Would there be any way of giving me a hint on how to create custom behaviours for the NPC?
Thanks for the guide and all your help!
- PROWNE
Honestly the best way to do it is trial and error, try looking at the codes of all the other mobs that are already in the game, and figuring out what code makes each one do something unique. Other than that no I can't really help you, I'm actually not even close to pro at this lol. I just remember how to do things I've already done quite well. Lol.
Yay, got everything of mine working, only problem is I'm not sure what Entity attributes work or not. EntityZombie has attackStrength but the compiler says there's no such string when I put it in my mob. I also don't know how to make the mob passive aggressive rather than passive OR aggressive.
This also isn't working right.
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);
}
I have it set to 1, I've run into a group of 4-5.
Where are you putting that code, maybe post your source so I can better help you, because I know without a doubt that that code works. The attackStrength thing is most likely due to what your mob extends. If it extends EntityCreature attackStrength will not work, you will need to find a way to replicate it(I would look at EntityMobs and see how attackStrength is declared, and implemented.) As for passive agressive, once you get the attackStrength worked out have a look at zombie pigman's code, and perhaps the spiders code(during daytime) for some hints. I copied a lot of the code for my mob from other mods, so I can't release that code to you with a clear conscience lol.
Thats how it works. You pay, you play. No money? Save until you do have a measly $20. If you won't pay this for such an awesome game because you think it should be free, then GTFO. By the way, you are breaking the law by pirating this game. To miztakay, you might wanna look at this. http://www.minecraft.net/haspaid.jsp?user=miztakay
Yeah my minecraft name is Backwave, says so where it should... I'm actually kind of insulted you checked me out without any reason to do so...
0
0
Sweet. I'll do some tweaking on my code, and some work on the textures. My mobs are split into three passive aggressive groups, each group aggressive towards the other two. Since all three are found in the nether, Idk what you want to set up as far as allegiance goes towards your mobs.
0
0
0
0
Brilliant. Where did you find that code, I use one very similar to that but I can't release it due to the fact that i pretty much stole it from the humans+ code. Where did you find that one? Or did you write it yourself?
0
0
with this
to make your mob only attack if attacked. But I'm not 100% on that.
0
Adding the limit code is the only way I can think to do this. Also if you would like limit their spawns AND spread them out a bit, add this code somewhere too
that can go anywhere(not under the getCanSpawnHere code) and it's pretty self explanatory what that does.
0
change that 1 to however many of that mob you want to exist at any given time. There's also a method to make them spawn on certain blocks if you'd like that. As for protecting you, I can't tell you how to make them follow and guard you because I'm still working on that myself. I will see if I can get them only attacking certain mobs, I will get back to you if I do.
0
0
Honestly the best way to do it is trial and error, try looking at the codes of all the other mobs that are already in the game, and figuring out what code makes each one do something unique. Other than that no I can't really help you, I'm actually not even close to pro at this lol. I just remember how to do things I've already done quite well. Lol.
0
Where are you putting that code, maybe post your source so I can better help you, because I know without a doubt that that code works. The attackStrength thing is most likely due to what your mob extends. If it extends EntityCreature attackStrength will not work, you will need to find a way to replicate it(I would look at EntityMobs and see how attackStrength is declared, and implemented.) As for passive agressive, once you get the attackStrength worked out have a look at zombie pigman's code, and perhaps the spiders code(during daytime) for some hints. I copied a lot of the code for my mob from other mods, so I can't release that code to you with a clear conscience lol.
0
Yeah my minecraft name is Backwave, says so where it should... I'm actually kind of insulted you checked me out without any reason to do so...
0
I've been following this thread for a while and I'm curious, what mod have you downloaded that came with a .jar file?