The Meaning of Life, the Universe, and Everything.
Location:
Somewhere
Join Date:
11/29/2012
Posts:
619
Location:
Australia
Minecraft:
The_SlayerMC
Member Details
im using minecraft forge 1.5.1 and im just wondering: how do i get my mob to add a chat message when its near me? so if it was around 10 blocks near me i want it to say something like "im coming for you" or something like that!
Don't use Minecraft.getMinecraft().thePlayer unless you're on the client; it will crash on the server. Instead, set up a collision box and check the entities. If one of them is a player, send out a chat message:
//This goes in the onupdate method
AxisAlignedBB var3 = this.boundingBox.expand(10.0D, 10.0D, 10.0D);
List var4 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, var3);
if (var4 != null && !var4.isEmpty()) {
Iterator var5 = var4.iterator();
while (var5.hasNext()) {
EntityPlayer var6 = (EntityPlayer)var5.next();
double var7 = this.getDistanceSqToEntity(var6);
if (var7 < 10.0D)
{
//Add chat message
}
}
}
Goes with onUpdate method.
Sincerely, if you can't figure that out, I highly recommend learning basic java.
No
He is refering to the method used in on entities such as zombies and skeletons to make them burn in daylight.
So, why don't you take a bit of your time to figure out how this:
Goes with onUpdate method.
Sincerely, if you can't figure that out, I highly recommend learning basic java.
okay so i set it up and im still getting errors!