Jump to content

Recommended Posts

Posted

Right now I have a custom mob that spawns during the night and doesn't despawn during the day, which is the way I want it. Problem is, more of the same mob continually spawn and soon take over an area. I'm using the method of Limiting spawns per Chunk to 1 and it only spawns in one at a time, but I'm still having this problem. How does vanilla minecraft keep mobs like cows and such from continually spawning in an area over time AND keeping the cows from despawning?

Posted

Override getCanSpawnHere()

You can access the world with the entity's worldObj, posX, posY, and posZ (even though it hasn't spawned yet) and check to see if any more of your mob are in the area, and if so, return false.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Alright....I have no idea how to do this. I know to check for Instance of ..., but I do not know how to check the area at all. I looked into the mob spawner code to see how it checks for mob count but I can't figure it out.

Posted

Alright....I have no idea how to do this. I know to check for Instance of ..., but I do not know how to check the area at all. I looked into the mob spawner code to see how it checks for mob count but I can't figure it out.

 

this.worldObj

 

You can access the world with the entity's worldObj, posX, posY, and posZ

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Right, but do I need to check a block range? I see that one can check a block location and see what block it is for a spawn, but I'm assuming you need to broaden that range to check for other entities in the chunk or something.

Posted

Right, but do I need to check a block range? I see that one can check a block location and see what block it is for a spawn, but I'm assuming you need to broaden that range to check for other entities in the chunk or something.

 

The world class can do all of that.  world.getEntitiesInAABB() for instance.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Alright so this is what I have so far, although I know it's probably wrong and I am missing the Pos X, Y, Z.

 

@Override
public boolean getCanSpawnHere()
    {
	float f = 8.0F;
        List list;
        int i;
        

            list = this.worldObj.getEntitiesWithinAABB(EntityForestWalker.class, this.boundingBox.expand((double)f, (double)f, (double)f));

            if (list.size() > 0){
            	return false;
            }
            else
            {
            	return true;
            }

    } 

 

I'm assuming it is something close to this?

Posted

You mean like this.posX?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Yes. I am honestly at the boundaries of my knowledge in how to do things like this so I will probably need a little more help in figuring out how this works. The getEntitiesWithinAABB line is correct right? How do I write the other components of this in a workable fashion?

Posted

Well you could clone the mob's own bounding box and then use .expand() instead of creating a new AABB.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.