Jump to content

Incorrect Biome data passed to IWorldGenerator


Karuberu

Recommended Posts

I have a world generator (implementing IWorldGenerator, of course) that checks for cold biomes and replaces some dirt with a new block. However, it seems that the biome data obtained by using "world.getBiomeGenForCoords(chunkX, chunkZ)" in my generate function is either offset or simply wrong. In some worlds, it seems to work just fine (namely flatland worlds with a single biome or worlds with large biomes), but in others, it's way off.

 

I did some testing: I added a line to log the chunk coordinates/biome in the generate function and then traveled to those chunk coordinates in the game and checked the biome with F3. In the world I tested, I was in a Plains biome according to the game, but my log said it was an Ocean chunk.

 

To verify that I hadn't screwed something up in my test, I had my world generator execute in Ocean biomes and recreated the world. My new block had replaced the dirt in the plains biome, even though I had just set it to work in ocean biomes. (And no, the chunk wasn't partially in an ocean biome or anything like that.)

 

Am I doing something wrong or is this a genuine bug?

 

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
float temperature = world.getBiomeGenForCoords(chunkX, chunkZ).getFloatTemperature();
System.out.println("[" + chunkX + "," + chunkZ + "] " + world.getBiomeGenForCoords(chunkX, chunkZ).biomeName + ": " + temperature);
if (temperature <= 0.15F) {
	// do stuff (the code here works fine if it's ever reached, so I've omitted it for brevity's sake)
}
}

Link to comment
Share on other sites

That's because you're reading it wrong...

 

chunkX and chunkZ are in chunk coordinates.

getBiomeGenForCoords is in block coordinates.

Try:

 

int x = chunkX * 16;
int z = chunkZ * 16;
System.out.println("[" + x + "," + z+ "] " + world.getBiomeGenForCoords(x, z).biomeName + ": " + temperature);

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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.