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

Hello everyone,

 

I'm trying to understand how animals spawn into the world.

I've been trough a lot of reading code, but I cannot see the hierarchy of the code.

 

Could you help me out?

 

This is how far I came to understand:

In 'BiomeGenBase' there is a protected list called: 'spawnableCreatureList' this is a arraylist.

The 4 animals (sheep, cow, chicken and pig) are added to this list with 'SpawnListEntry'.

It defines what the min. and max. spawn amount per group is.

 

Example: But how does it determine that cows don't spawn in deserts?

 

This information is part of something called: 'BiomeDecorator',

So I'm assuming spawning animals is decorating the biome.

All this is information about what and in what amount it should spawn animals.

But what I'm really looking for is the code that actually spawns the animals.

  • Author

Hmm, I had seen this class before, but I thought it was about the block 'spawner'.

This is because the eligibleChunksForSpawning  = a 17*17 area around the player.

 

But, thanks.

This code looks really difficult to understand, but I'll try to make something out of it.

I thought you needed a code example for spawn with conditions, that is all :)

Look into

performWorldGenSpawning

 

About your example :

But how does it determine that cows don't spawn in deserts?

In BiomeGenDesert,

this.spawnableCreatureList.clear();

With an empty creature list, no passive mob spawn ;)

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.