Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?

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.

  • Author

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.

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.

  • Author

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.

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.

  • Author

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?

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.

  • Author

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?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.