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

Hi,

 

I'm looking for some help on spawning mob if a condition is true. After a short search in the slime class, I found getCanSpawnHere(), which, obviously, I'll need to use. I'm trying to make the mob spawn at a certain Y level and lower. But im not sure how too. Maybe I'd need to get the pos of the chunk or something? Not sure.

Look at the bat instead.

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

Look at the bat instead.

Hm, I dont think I understand. Why does it use the calender along with Minecrafts Time? To make sure its night? But then how does it check if its underground still

Look at the bat instead.

Hm, I dont think I understand. Why does it use the calender along with Minecrafts Time? To make sure its night? But then how does it check if its underground still

 

Ignore that part and look at the REST of the function.

(Oh, and the Calendar is checking to see if the real world date is Halloween)

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.

Mind if I add on here and ask another question? Seemed like a better idea than creating a similar topic!

 

Now I know you can use getCanSpawnHere() to make mobs spawn exclusively on certain blocks, but is there a way to make them spawn on "materials" such as leaves or ice? What about on the air blocks? I tried using worldObj.getBlockId((int)posX,(int) posY-1,(int) posZ) == 0; as a random shot in the dark.

 

Thanks for any insight you may be able to provide.

  • Author

Look at the bat instead.

Hm, I dont think I understand. Why does it use the calender along with Minecrafts Time? To make sure its night? But then how does it check if its underground still

 

Ignore that part and look at the REST of the function.

(Oh, and the Calendar is checking to see if the real world date is Halloween)

 

From what I can tell, it checks if the boundingbox is greater or equal to than 63 and if it is, then no spawn.  Then it goes on to getting the light level and the pos of x and z.  I dont get how that stops it from spawning above ground?

From what I can tell, it checks if the boundingbox is greater or equal to than 63 and if it is, then no spawn.  Then it goes on to getting the light level and the pos of x and z.  I dont get how that stops it from spawning above ground?

 

What's vanilla's ground height?

 

(Hint: it's 63)

 

Also, what else do you have access to?

 

(Hint: the mob's posY)

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

From what I can tell, it checks if the boundingbox is greater or equal to than 63 and if it is, then no spawn.  Then it goes on to getting the light level and the pos of x and z.  I dont get how that stops it from spawning above ground?

 

What's vanilla's ground height?

 

(Hint: it's 63)

 

Also, what else do you have access to?

 

(Hint: the mob's posY)

 

Yes, I saw that, but i is set to the boundingbox? Isn't the boundingbox the hit box?

And?

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

And?

So how does making sure the boundingbox is less than 63 make it spawn underground? Whats the bounding box got to do with if it can spawn underground. How does that work :S

  • Author

Okay, i've added spawning conditions, but they seem to rare, are my numbers wrong for my add spawns? What would a good example be?  Heres one of mine

EntityRegistry.addSpawn(OS_EntityIronSpider.class, 16, 2, 4, EnumCreatureType.monster, BiomeGenBase.desert, BiomeGenBase.desertHills, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.frozenOcean, BiomeGenBase.frozenRiver, BiomeGenBase.iceMountains, BiomeGenBase.icePlains, BiomeGenBase.jungle, BiomeGenBase.jungleHills, BiomeGenBase.plains, BiomeGenBase.swampland, BiomeGenBase.taiga, BiomeGenBase.taigaHills);

 

@Cyan

This is how I check for a block, I bet theres a method to check for a material somewhere in the world class.

@Override
    public boolean getCanSpawnHere()
    {

        for(int x = 0; x < 16; x++)
        {
                for(int y = 0; y < 8; y++)
                {
                        for(int z = 0; z < 16; z++)
                        {
                                int x1 = MathHelper.floor_double(this.posX + x - ;
                                int y1 = MathHelper.floor_double(this.posY + y - 4);
                                int z1 = MathHelper.floor_double(this.posZ + z - ;

                                if(this.worldObj.getBlockId(x1, y1, z1) == Block.obsidian.blockID)
                                {
                                		System.out.println("Spawning Obsidian Spider:" + "X:" + this.posX + " Y:" + this.posY + " Z:" + this.posZ);
                                        return super.getCanSpawnHere();
                                }

                        }
                }
        }
	return false;
    }

And?

So how does making sure the boundingbox is less than 63 make it spawn underground? Whats the bounding box got to do with if it can spawn underground. How does that work :S

 

The bounding box thing is Mojang code.  However, the bounding box minY just so conveniently happens to also bethe mob's posY[/u].  If the mob's posY is less than 63, then it's HIGHLY LIKELY that the mob is underground.  What with ground being 63 and up or covered in water (and thus not a valid spawn location).

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

And?

So how does making sure the boundingbox is less than 63 make it spawn underground? Whats the bounding box got to do with if it can spawn underground. How does that work :S

 

The bounding box thing is Mojang code.  However, the bounding box minY just so conveniently happens to also bethe mob's posY[/u].  If the mob's posY is less than 63, then it's HIGHLY LIKELY that the mob is underground.  What with ground being 63 and up or covered in water (and thus not a valid spawn location).

 

Ah, I understood the logic, but I wasn't aware that you could you use the bounding box Y as the the entities Y. Thanks for clearing that up.

The mobs are kinda rare though, is my weighted probability and mix max group numbers a bad combination or something? The code is in my previous post.

No idea.

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.

@Cyan

This is how I check for a block, I bet theres a method to check for a material somewhere in the world class.

@Override
    public boolean getCanSpawnHere()
    {

        for(int x = 0; x < 16; x++)
        {
                for(int y = 0; y < 8; y++)
                {
                        for(int z = 0; z < 16; z++)
                        {
                                int x1 = MathHelper.floor_double(this.posX + x - ;
                                int y1 = MathHelper.floor_double(this.posY + y - 4);
                                int z1 = MathHelper.floor_double(this.posZ + z - ;

                                if(this.worldObj.getBlockId(x1, y1, z1) == Block.obsidian.blockID)
                                {
                                		System.out.println("Spawning Obsidian Spider:" + "X:" + this.posX + " Y:" + this.posY + " Z:" + this.posZ);
                                        return super.getCanSpawnHere();
                                }

                        }
                }
        }
	return false;
    }

Well obsidian is pretty rare...only appears naturally when water and lava collide.

You may have found the IBlockAccess#getBlockMaterial(int,int,int) method.

  • Author

@Draco18s

Okay, thanks for the other help!

 

@GotoLink

Is my way for checking for obsidian a bad way? I know obsidian is pretty rare, but where else would an obsidian spider spawn :P. My spawn rates for my mobs are pretty high, but they all seem too rare still. Hm

Just from what im seeing in your code, your checking to see if yhe block that it spawn IN is obsidian and if thats the case you also check if the block is air, since it cannot be both it always returns false. I would try decrementing the y value of the block your checking by 1 and see what it does.

  • Author

@Saxon564

I dont understand?

 

EDIT: Nevermind, I've solved the rest of my spawning problems!

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.