[SPIGOT-3983] World.setBiome() and World.getBiome() only work in loaded chunks Created: 01/Jul/18  Updated: 02/Jul/18

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Reg Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: biomes, chunkgen
Environment:

Windows 7.

Java 1.8.0 171


Version: 1.12.2-R0.1Snapshot

 Description   

World.setBiome() and World.getBiome() only perform the expected function on locations in loaded chunks.

 

Call setBiome() on a column in an unloaded chunk and nothing happens.

 

Call getBiome() on a column in an unloaded chunk and the function returns the original biome of that column. 

For example, the original biome of a column as generated in a fresh world is PLAINS.  I change the biome to FOREST manually and verify that the biome has changed and been saved in the region file.  I restart the server so the column is no longer loaded (it's far from spawn).  I call getBiome() on the column and receive PLAINS.  I log back into the server, stand next to the column and call getBiome() and receive FOREST.  Presumably getBiome() is regenerating the chunk if it's not loaded, and returning the biome information from that regenerated chunk (instead of loading it).

 

N.B. World.loadChunk() on the chunk containing the column in question before calling get/setBiome() also results in correct behaviour.



 Comments   
Comment by Reg [ 02/Jul/18 ]

Based on how the rest of the API works, I had assumed that it would load the chunk and return the current biome. 

If you set/getType on a block that isn't loaded it does just that, so it would seem logical to me if get/setBiome did that too.

Edit:  Perhaps a boolean argument to 'load chunk if not loaded' like loadChunk()'s 'generate if chunk doesn't exist' boolean would be the answer?  Just as long as the Javadocs specify what happens in both cases, that'd be fine.

Edit 2:  Obviously the fallback behaviour if you try to getBiome() on a block that hasn't been generated yet is the current behaviour, i.e. the game generates the chunk, gets the biome info and then discards the chunk.  I'm not sure about calling setBiome() on a non-existing chunk though.

Comment by Black Hole [ 02/Jul/18 ]

Throwing exceptions will break the API contract for existing plugins. So I think loading the chunk and updating the JavaDoc to reflect that would be better. Maybe adding getOriginalBiome() could be useful, too.

Comment by md_5 [ 01/Jul/18 ]

Do you expect it to work or throw an exception?
I probably expect the latter.

Comment by Reg [ 01/Jul/18 ]

Apparently I derped and put this in the wrong section :S

Generated at Tue Apr 15 09:10:45 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.