Skip to content

Commit

Permalink
Re-implemented ChunkData method, cleaned up cache world creation
Browse files Browse the repository at this point in the history
  • Loading branch information
sh0inx committed May 13, 2024
1 parent 587f133 commit 0bfba52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ public class VoidGenerator extends ChunkGenerator {

public byte[][] blockSections;

@Override
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biomeGrid) {
final ChunkData chunkData = createChunkData(world);
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
biomeGrid.setBiome(x, z, Objects.requireNonNull(getSkyblockGenerator(world.getEnvironment()).biome.getBiome()));
}
}
return chunkData;
}

public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomeGrid) {
if (blockSections == null) {
blockSections = new byte[world.getMaxHeight() / 16][];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void createWorld(World.Environment environment, String name) {
WorldCreator worldCreator = new WorldCreator(name)
.generator(IridiumSkyblock.getInstance().getDefaultWorldGenerator(name, null))
.environment(environment);

World world = Bukkit.createWorld(worldCreator);

createCacheWorld(world);
Expand Down Expand Up @@ -111,14 +112,8 @@ public void createCacheWorld(World world) {

if(!IridiumSkyblock.getInstance().getConfiguration().generatorType.isTerrainGenerator()) return;


if (Bukkit.getWorld(getCacheWorldName(world)) == null) {

WorldCreator worldCreator = new WorldCreator(getCacheWorldName(world))
.generator(IridiumSkyblock.getInstance().getDefaultWorldGenerator(world.getName(), null))
.environment(world.getEnvironment())
.seed(world.getSeed());

WorldCreator worldCreator = new WorldCreator(getCacheWorldName(world)).copy(world);
worldCreator.createWorld();
}

Expand Down Expand Up @@ -403,8 +398,7 @@ public void regenerateTerrain (Island island, World world, int y, CompletableFut
for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) {
Block blockA = regenWorld.getBlockAt(x, y, z);
Block blockB = world.getBlockAt(x, y, z);

blockB.setType(blockA.getType(), false);
blockB.setBlockData(blockA.getBlockData(), false);
}
}

Expand Down

0 comments on commit 0bfba52

Please sign in to comment.