From 64a3e3db2712e58f4bdd7d8027195ebfea140a3d Mon Sep 17 00:00:00 2001 From: Harrison Date: Wed, 29 Apr 2020 22:53:28 -0500 Subject: [PATCH] Slightly faster. --- .../generation/IslandWorldChunkGenerator.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/IslandWorldChunkGenerator.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/IslandWorldChunkGenerator.java index c4392a8..039e1ed 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/IslandWorldChunkGenerator.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/IslandWorldChunkGenerator.java @@ -24,9 +24,9 @@ import ca.recrown.islandsurvivalcraft.world.IslandWorldMapper; import ca.recrown.islandsurvivalcraft.world.shaders.WorldHeightShader; public class IslandWorldChunkGenerator extends ChunkGenerator implements Listener { - private final Cache blockValueCache = new Cache<>(102400); - private final Cache biomeCache = new Cache<>(102400); - private final Cache chunkExistenceCache = new Cache<>(16384); + private final Cache blockValueCache = new Cache<>(262144); + private final Cache biomeCache = new Cache<>(262144); + private final Cache chunkExistenceCache = new Cache<>(32768); private final BiomeSelector biomeSelector = new BiomeSelector(); private final ExecutorService executor = Utilities.ISC_EXECUTOR; private volatile World currentWorld; @@ -59,25 +59,25 @@ public class IslandWorldChunkGenerator extends ChunkGenerator implements Listene Biome[][] biomes = new Biome[Utilities.CHUNK_SIZE][Utilities.CHUNK_SIZE]; for (int x = 0; x < Utilities.CHUNK_SIZE; x++) { for (int z = 0; z < Utilities.CHUNK_SIZE; z++) { - final int desX = x; - final int desZ = z; - if (biomes[desX][desZ] == null) { - biomeGenerator.generateBiomeColumn(biomes, world, chunkX, chunkZ, desX, desZ, mapper, biomeSelector, + final int localX = x; + final int localZ = z; + if (biomes[localX][localZ] == null) { + biomeGenerator.generateBiomeColumn(biomes, world, chunkX, chunkZ, localX, localZ, mapper, biomeSelector, temperatureMapGenerator, biomeCache, chunkExistenceCache); } - if (biomes[desX][desZ] == null) throw new IllegalStateException("Biome was null."); + if (biomes[localX][localZ] == null) throw new IllegalStateException("Biome was null."); tasks.add(executor.submit(() -> { for (int y = 0; y < maxHeight; y++) { - biomeGrid.setBiome(desX, y, desZ, biomes[desX][desZ]); + biomeGrid.setBiome(localX, y, localZ, biomes[localX][localZ]); } return true; })); - final int worldX = Utilities.CHUNK_SIZE * chunkX + desX; - final int worldZ = Utilities.CHUNK_SIZE * chunkZ + desZ; - int height = heightShader.getAltitude(worldX, worldZ, biomes[desX][desZ]); - chunkData.setRegion(desX, 1, desZ, desX + 1, height, desZ + 1, Material.DIAMOND_BLOCK); + final int worldX = Utilities.CHUNK_SIZE * chunkX + localX; + final int worldZ = Utilities.CHUNK_SIZE * chunkZ + localZ; + int height = heightShader.getAltitude(worldX, worldZ, biomes[localX][localZ]); + chunkData.setRegion(localX, 1, localZ, localX + 1, height, localZ + 1, Material.DIAMOND_BLOCK); } } chunkData.setRegion(0, 0, 0, 16, 1, 16, Material.BEDROCK);