Fixes clean super-flat issue from 1.19 worlds

In 1.19 worlds it was fixed that super-flat worlds are generated at min-height, instead at 0.
This change keeps the previous super-flat chunk generation until 1.18 is dropped.
This commit is contained in:
BONNe 2022-11-01 18:25:39 +02:00 committed by GitHub
parent d50208c0e1
commit 87a6799cd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,17 +116,35 @@ public class CleanSuperFlatListener extends FlagListener {
* @return true if the chunk should not be cleaned
*/
private boolean noClean(World world, ChunkLoadEvent e) {
if (!ready) {
if (!this.ready)
{
return true;
}
return !getIWM().inWorld(world) || !Flags.CLEAN_SUPER_FLAT.isSetForWorld(world) ||
(!(e.getChunk().getBlock(0, 0, 0).getType().equals(Material.BEDROCK)
&& e.getChunk().getBlock(0, 1, 0).getType().equals(Material.DIRT)
&& e.getChunk().getBlock(0, 2, 0).getType().equals(Material.DIRT)
&& e.getChunk().getBlock(0, 3, 0).getType().equals(Material.GRASS_BLOCK))
|| (world.getEnvironment().equals(Environment.NETHER) && (!plugin.getIWM().isNetherGenerate(world)
|| !plugin.getIWM().isNetherIslands(world)))
|| (world.getEnvironment().equals(Environment.THE_END) && (!plugin.getIWM().isEndGenerate(world)
|| !plugin.getIWM().isEndIslands(world))));
// Check if super-flat must even be working.
if (!this.getIWM().inWorld(world) ||
!Flags.CLEAN_SUPER_FLAT.isSetForWorld(world) ||
world.getEnvironment().equals(Environment.NETHER) &&
(!plugin.getIWM().isNetherGenerate(world) || !plugin.getIWM().isNetherIslands(world)) ||
world.getEnvironment().equals(Environment.THE_END) &&
(!plugin.getIWM().isEndGenerate(world) || !plugin.getIWM().isEndIslands(world)))
{
return true;
}
// Check if bottom is a super-flat chunk.
int minHeight = world.getMinHeight();
// Due to flat super flat chunk generation changes in 1.19, they now are generated properly at the world min.
// Extra check for 0-4 can be removed with 1.18 dropping.
return !(e.getChunk().getBlock(0, 0, 0).getType().equals(Material.BEDROCK) &&
e.getChunk().getBlock(0, 1, 0).getType().equals(Material.DIRT) &&
e.getChunk().getBlock(0, 2, 0).getType().equals(Material.DIRT) &&
e.getChunk().getBlock(0, 3, 0).getType().equals(Material.GRASS_BLOCK)) ||
!(e.getChunk().getBlock(0, minHeight, 0).getType().equals(Material.BEDROCK) &&
e.getChunk().getBlock(0, minHeight + 1, 0).getType().equals(Material.DIRT) &&
e.getChunk().getBlock(0, minHeight + 2, 0).getType().equals(Material.DIRT) &&
e.getChunk().getBlock(0, minHeight + 3, 0).getType().equals(Material.GRASS_BLOCK));
}
}