Jump to content

Where is the mushroom island?


Zacomat

Recommended Posts

I'm trying to find the mushroom island.

In the FMLServerStartedEvent I make some init and subscribe to WorldTickEvent.

In the WorldTickEvent I make a loop where i generate some BlockPos and call world.getBiome to see if I found it.

The loop is broken after 1 millis to reduce the work per tick.

If I find the BiomeMushroomIsland I unsubscribe to WorldTickEvent.

This works but is there a faster and easier solution?

 

Edited by Zacomat
Link to comment
Share on other sites

6 hours ago, Lhykos said:

BiomesOPlenty did that for the BiomeFinder: BiomesOPlenty Github

On line 72:


public static BlockPos spiralOutwardsLookingForBiome(World world, Biome biomeToFind, double startX, double startZ)

 

I think it is an easy solution. :)

This function contains a loop where the sample of the world occur. If you call it from FMLServerStartedEvent the server seems to freeze during the loading phase until the island is found, and that could take many seconds... So i break the search and call a piece of it from WorldTickEvent.

Maybe there is a way to execute it from other thread?  Without crashing the server :)

 

Link to comment
Share on other sites

1 hour ago, TheSunCat said:

You are trying to find a biome on world generation? Check the seed algorithm. It defines where biomes would be. 

I need it work even with other mods that could modify the world generation...

How could it be done? Can you give an example?

Link to comment
Share on other sites

22 hours ago, Zacomat said:

This function contains a loop where the sample of the world occur. If you call it from FMLServerStartedEvent the server seems to freeze during the loading phase until the island is found, and that could take many seconds... So i break the search and call a piece of it from WorldTickEvent.

Maybe there is a way to execute it from other thread?  Without crashing the server :)

 

You could also work with the BiomeProvider. It has similar methods to get a biome.

And if you worry about the time to find that biome you could also spread the search over ticks.

Link to comment
Share on other sites

On 2/21/2017 at 0:00 PM, Zacomat said:

If you call it from FMLServerStartedEvent the server seems to freeze during the loading phase until the island is found, and that could take many seconds...

 
 
 

Mushroom islands are pretty rare, so if you manually scan each chunk it is probably going to take a while. I suggest looking at how MC generates the biome map to see if you can utilize the world seed to your advantage like TheSunCat suggested. Instead of manually scanning, you might be able to use the seed to determine exactly which chunk would be a mushroom island. That way you would only need to check once (probably).

 

Another issue you may be facing is how you are checking if a certain chunk is/isn't a mushroom island. I'm not at my IDE to check right now, but I'm fairly certain all (or basically all) the methods in World and Chunk that request the biome type load the chunk you are checking. That means that for each position you are checking, the game is generating and decorating the chunk that position is in, which is a huge waste of time and resources. (and probably causes that huge delay you notice when loading the world). Instead, look at BiomeProvider as Lhykos suggested. There is a specific method, not sure what it is called, that can really quickly find a biome in a certain area as it just searches through an array of integers.

Edited by TheMasterGabriel
Link to comment
Share on other sites

In FMLServerStartingEvent  i get the BiomeProvider with event.getServer().getEntityWorld().getBiomeProvider().

Then in a separate thread i call biomeProvider.getBiomes(null, x, z, 1, 1, false);

The server don't crash and it seems to work except for strange behaviours: the world generation is broken in some areas.

It seems that i go to interfere with world generation...

When is it safe to call biomeProvider.getBiomes? Or is there an other way to get biomes at a certain position?

Edited by Zacomat
if i run the search loop in the FMLServerStartingEvent all works ok but it takes a long time the server to start: about 10 sec
Link to comment
Share on other sites

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.