From dd89266b4ef2f0363778810fa2e243b98272a716 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 7 May 2020 11:52:23 -0500 Subject: [PATCH] Preliminary new unique biome generator. --- .../utilities/biomes/BiomeInfo.java | 8 + .../utilities/biomes/LandBiomeInfo.java | 12 +- .../utilities/biomes/OceanBiomeInfo.java | 15 +- .../world/IslandWorldMap.java | 9 +- .../generation/biomes/BiomeGenerator.java | 11 +- .../biomes/UniqueBiomeGenerator.java | 179 +-- .../chunks/IslandWorldChunkGenerator.java | 70 +- .../generation/shaders/WorldHeightShader.java | 16 +- .../generation/shaders/WorldLayerShader.java | 4 +- .../world/generation/DummyWorld.java | 1195 ----------------- .../biomes/UniqueBiomeGeneratorTest.java | 16 +- 11 files changed, 145 insertions(+), 1390 deletions(-) create mode 100644 src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/BiomeInfo.java delete mode 100644 src/test/java/ca/recrown/islandsurvivalcraft/world/generation/DummyWorld.java diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/BiomeInfo.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/BiomeInfo.java new file mode 100644 index 0000000..5fe24f6 --- /dev/null +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/BiomeInfo.java @@ -0,0 +1,8 @@ +package ca.recrown.islandsurvivalcraft.utilities.biomes; + +import org.bukkit.block.Biome; + +public interface BiomeInfo { + public Biome getMainBiome(); + public Biome getTransitionBiome(); +} \ No newline at end of file diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/LandBiomeInfo.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/LandBiomeInfo.java index 3d01f43..d18328e 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/LandBiomeInfo.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/LandBiomeInfo.java @@ -4,7 +4,7 @@ import org.bukkit.block.Biome; import ca.recrown.islandsurvivalcraft.utilities.weighting.Weightable; -public class LandBiomeInfo implements Weightable { +public class LandBiomeInfo implements Weightable, BiomeInfo { private final Biome biome; private final float weight; private final Biome hillBiome; @@ -47,14 +47,15 @@ public class LandBiomeInfo implements Weightable { } /** - * @return the hill biome. May be null. + * @return the hill biome. Will return the normal biome if there is no special hill biome for this biome. */ public Biome getHillBiome() { + if (hillBiome == null) return getBiome(); return hillBiome; } /** - * @return the shore biome. + * @return the shore biome. Should not have shore if null is returned. */ public Biome getPreferredShore() { return preferredShore; @@ -66,4 +67,9 @@ public class LandBiomeInfo implements Weightable { public Biome getTransitionBiome() { return transitionBiome; } + + @Override + public Biome getMainBiome() { + return biome; + } } \ No newline at end of file diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/OceanBiomeInfo.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/OceanBiomeInfo.java index e2f5fef..a877a49 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/OceanBiomeInfo.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/biomes/OceanBiomeInfo.java @@ -2,7 +2,7 @@ package ca.recrown.islandsurvivalcraft.utilities.biomes; import org.bukkit.block.Biome; -public class OceanBiomeInfo { +public class OceanBiomeInfo implements BiomeInfo { private final Biome ocean; private final Biome transitionOcean; private final Biome deepAlternative; @@ -22,9 +22,10 @@ public class OceanBiomeInfo { } /** - * @return the transition ocean. May be null. + * @return the transition ocean. Will return the normal biome if no transitional biome is designated. */ public Biome getTransitionOcean() { + if (transitionOcean == null) return getOcean(); return transitionOcean; } @@ -34,4 +35,14 @@ public class OceanBiomeInfo { public Biome getDeepAlternative() { return deepAlternative; } + + @Override + public Biome getMainBiome() { + return getOcean(); + } + + @Override + public Biome getTransitionBiome() { + return getTransitionBiome(); + } } \ No newline at end of file diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/IslandWorldMap.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/IslandWorldMap.java index 29d735a..cd71acf 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/IslandWorldMap.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/IslandWorldMap.java @@ -169,21 +169,20 @@ public class IslandWorldMap { if (!isIsland(worldX, worldZ)) throw new IllegalArgumentException("The given coordinates are not part is an island."); dfs.setStartPosition(worldX, worldZ); final Point2 goal = new Point2(0, 0); - dfs.setEndPosition(goal); - Reference closest = new Reference<>(); dfs.findTarget(new CoordinateTargetValidatable(){ Double closestDistance = null; @Override public boolean isCoordinateTarget(int x, int y) { + if (coordinateTargetValidatable != null && coordinateTargetValidatable.isCoordinateTarget(x, y)) { + closest.value = null; + return true; + } Point2 current = new Point2(x, y); double currentDistance = current.distance(goal); if (closestDistance == null || (currentDistance) < closestDistance) { closestDistance = currentDistance; closest.value = current; - if (coordinateTargetValidatable != null) { - return coordinateTargetValidatable.isCoordinateTarget(x, y); - } } return false; } diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/BiomeGenerator.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/BiomeGenerator.java index 444f53b..7f53873 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/BiomeGenerator.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/BiomeGenerator.java @@ -1,8 +1,6 @@ package ca.recrown.islandsurvivalcraft.world.generation.biomes; -import org.bukkit.World; -import org.bukkit.block.Biome; - +import ca.recrown.islandsurvivalcraft.utilities.biomes.BiomeInfo; import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; import ca.recrown.islandsurvivalcraft.world.BiomeMap; @@ -17,16 +15,15 @@ public interface BiomeGenerator { * It doesn't need to be populated on the first call as this method will be called once for every column in the chunk. * However, if some biomes can be set without repetative calls, doing so will prevent this method from being called for those locals. * - * @param chunkBiomeSets The array of biomes that are to be saturated. First two arrays represent the x and y values, and the third represents the biome set. - * @param world The current world. + * @param localBiomeInfo The array of biomes that are to be saturated. First two arrays represent the x and y values, and the third represents the biome set. * @param chunkX The X coordinate of the chunk. * @param chunkZ The Z coordinate of the chunk. * @param localX The X coordinate of the column within the chunk. * @param localZ The Z coordinate of the column within the chunk. - * @param mapper The island mapper to be used. + * @param islandMap The island mapper to be used. * @param tempGenerator The temperature generator to be used. * @param biomeCache Cache for biomes. * @param chunkGenCache Cache for whether or not the chunk is generated. */ - public void generateBiomeColumn(Biome[][][] chunkBiomeSets, World world, int chunkX, int chunkZ, int localX, int localZ, IslandWorldMap mapper, BiomeMap biomeSelector, TemperatureMap tempGenerator, Cache biomeCache); + public void generateBiomeColumn(BiomeInfo[][] localBiomeInfo, int chunkX, int chunkZ, int localX, int localZ, IslandWorldMap islandMap, BiomeMap biomeSelector, TemperatureMap tempGenerator, Cache biomeCache); } \ No newline at end of file diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGenerator.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGenerator.java index 4014872..ec1cc3c 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGenerator.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGenerator.java @@ -1,157 +1,64 @@ package ca.recrown.islandsurvivalcraft.world.generation.biomes; -import java.util.Arrays; - -import org.bukkit.World; -import org.bukkit.block.Biome; - import ca.recrown.islandsurvivalcraft.utilities.GeneralUtilities; -import ca.recrown.islandsurvivalcraft.utilities.biomes.LandBiomeInfo; -import ca.recrown.islandsurvivalcraft.utilities.biomes.OceanBiomeInfo; +import ca.recrown.islandsurvivalcraft.utilities.biomes.BiomeInfo; import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Reference; import ca.recrown.islandsurvivalcraft.utilities.floodfill.Floodable; import ca.recrown.islandsurvivalcraft.utilities.floodfill.Flooder; import ca.recrown.islandsurvivalcraft.utilities.pathfinding.CoordinateTargetValidatable; -import ca.recrown.islandsurvivalcraft.utilities.pathfinding.CoordinateValidatable; import ca.recrown.islandsurvivalcraft.world.BiomeMap; import ca.recrown.islandsurvivalcraft.world.IslandWorldMap; import ca.recrown.islandsurvivalcraft.world.TemperatureMap; public class UniqueBiomeGenerator implements BiomeGenerator { - private final double DEEP_OCEAN_PORTION = 0.5d; - private final double HILL_PORTION = 0.4; @Override - public void generateBiomeColumn(Biome[][][] chunkBiomeSets, World world, int chunkX, int chunkZ, int localX, int localZ, IslandWorldMap islandMap, BiomeMap biomeSelector, TemperatureMap tempGen, Cache biomeCache) { - int worldX = 16 * chunkX + localX; - int worldZ = 16 * chunkZ + localZ; + public void generateBiomeColumn(BiomeInfo[][] localBiomeInfo, int chunkX, int chunkZ, int localX, int localZ, + IslandWorldMap islandMap, BiomeMap biomeSelector, TemperatureMap tempGenerator, + Cache biomeCache) { + int worldX = 16 * chunkX + localX; + int worldZ = 16 * chunkZ + localZ; + Point2 worldCoords = new Point2(worldX, worldZ); - //Check if we can just give it something in cache. - Biome[] biomeSet = attemptGetBiomeSet(world, worldX, worldZ, biomeCache, null); - if (biomeSet != null) { - chunkBiomeSets[localX][localZ] = biomeSet; - return; - } + localBiomeInfo[localX][localZ] = biomeCache.get(worldCoords); + if (localBiomeInfo[localX][localZ] != null) return; - //Fine, check if it's ocean. - if (!islandMap.isIsland(worldX, worldZ)) { - biomeSet = chunkBiomeSets[localX][localZ]; - OceanBiomeInfo ocean = biomeSelector.getOceanBiome(tempGen.getTemperature(worldX, worldZ)); - biomeSet[0] = islandMap.getWorldValue(worldX, worldZ) >= -DEEP_OCEAN_PORTION ? ocean.getOcean() : ocean.getDeepAlternative(); - setCacheBiome(worldX, worldZ, biomeSet, chunkBiomeSets, biomeCache); - return; - } - - //Shoot, looks like it's actually an island. - IslandInfo islandInfo = new IslandInfo(islandMap, world, biomeCache); - Point2 islandOrigin = islandMap.findIslandOrigin(worldX, worldZ, islandInfo); - if (!islandInfo.isComplete()) { - float temp = tempGen.getTemperature(islandOrigin.x, islandOrigin.y); - LandBiomeInfo biomeInfo = biomeSelector.getLandBiomeInfo(temp, islandOrigin.x, islandOrigin.y); - islandInfo.biomeset = new Biome[5]; - islandInfo.biomeset[1] = biomeInfo.getBiome(); - islandInfo.biomeset[2] = biomeInfo.getPreferredShore() == null ? Biome.BEACH : biomeInfo.getPreferredShore(); - islandInfo.biomeset[4] = biomeInfo.getHillBiome() == null ? islandInfo.biomeset[1] : biomeInfo.getHillBiome(); - islandInfo.biomeset[3] = islandInfo.biomeset[2]; - } - - PropagatorInfo propInfo = new PropagatorInfo(islandInfo.biomeset, chunkBiomeSets, new Point2(chunkX, chunkZ), islandMap, biomeCache); - Flooder flooder = new Flooder(new Point2(worldX, worldZ), propInfo); - flooder.start(); - } - - private Biome[] attemptGetBiomeSet(World world, int worldX, int worldZ, Cache biomeCache, Biome[][][] chunkBiomeSets) { - Point2 worldCoords = new Point2(worldX, worldZ); - Biome[] res = null; - - if (chunkBiomeSets != null) { - Point2 localCoords = GeneralUtilities.worldToLocalChunkCoordinates(worldCoords); - return chunkBiomeSets[localCoords.x][localCoords.y]; - } - - res = biomeCache.get(worldCoords); - return res; - } - - private void setCacheBiome(int worldX, int worldZ, Biome[] biomeSet, Biome[][][] localBiomes, Cache biomeCache) { - Point2 worldCoords = new Point2(worldX, worldZ); - if (localBiomes != null) { - Point2 localCoords = GeneralUtilities.worldToLocalChunkCoordinates(worldCoords); - localBiomes[localCoords.x][localCoords.y] = biomeSet; - } - biomeCache.set(worldCoords, biomeSet); - } - - private class IslandInfo implements CoordinateTargetValidatable, CoordinateValidatable { - public final IslandWorldMap mapper; - public final World world; - private final Cache biomeCache; - private Biome[] biomeset; - - public IslandInfo(IslandWorldMap mapper, World world, Cache biomeCache) { - this.mapper = mapper; - this.world = world; - this.biomeCache = biomeCache; - } - - @Override - public boolean isCoordinateTarget(int x, int y) { - biomeset = attemptGetBiomeSet(world, x, y, biomeCache, null); - if (biomeset != null) { - if (!isComplete()) throw new IllegalStateException("There was an incomplete biome set."); - return true; - } - return false; - } - - @Override - public boolean validate(int x, int y) { - return mapper.isIsland(x, y); - } - - public boolean isComplete() { - return !(biomeset == null || biomeset[1] == null || biomeset[2] == null || biomeset[3] == null || biomeset[4] == null); - } - } - - private class PropagatorInfo implements Floodable { - private final Biome[] biomeset; - private final Biome[][][] biomes; - private final Point2 chunkCoords; - private final IslandWorldMap mapper; - private final Cache biomeCache; - - public PropagatorInfo(Biome[] biomeset, Biome[][][] biomes, Point2 chunkCoords, IslandWorldMap mapper, Cache biomeCache) { - this.biomeset = biomeset; - this.biomes = biomes; - this.chunkCoords = chunkCoords; - this.mapper = mapper; - this.biomeCache = biomeCache; - } - - @Override - public boolean flood(Point2 point) { - Point2 chunkCoords = GeneralUtilities.worldToChunkCoordinates(point); - if (!this.chunkCoords.fastEquals(chunkCoords) || !mapper.isIsland(point.x, point.y)) return false; - int x = point.x; - int y = point.y; - Biome[] biomeSet = Arrays.copyOf(biomeset, biomeset.length); - if (mapper.isLand(x, y)) { - if (mapper.isShore(x, y)) { - biomeSet[0] = biomeset[2]; - } else if (mapper.getWorldValue(x, y) >= HILL_PORTION) { - biomeSet[0] = biomeset[4]; - } else { - biomeSet[0] = biomeset[1]; + float temperature = tempGenerator.getTemperature(worldX, worldZ); + if (!islandMap.isIsland(worldX, worldZ)) { + BiomeInfo oceanInfo = biomeSelector.getOceanBiome(temperature); + localBiomeInfo[localX][localZ] = oceanInfo; + biomeCache.set(worldCoords, oceanInfo); + return; } - } else { - biomeSet[0] = biomeset[3]; - } - - setCacheBiome(x, y, biomeSet, biomes, biomeCache); - return true; - } + Reference currentIslandInfo = new Reference<>(); + Point2 islandOrigin = islandMap.findIslandOrigin(worldX, worldZ, new CoordinateTargetValidatable() { + @Override + public boolean isCoordinateTarget(int x, int y) { + Point2 coord = new Point2(x, y); + BiomeInfo info = biomeCache.get(coord); + if (info == null) return false; + currentIslandInfo.value = info; + return true; + } + }); + if (currentIslandInfo.value == null) { + currentIslandInfo.value = biomeSelector.getLandBiomeInfo(temperature, islandOrigin.x, islandOrigin.y); + } + Flooder flooder = new Flooder(worldCoords, new Floodable() { + @Override + public boolean flood(Point2 point) { + Point2 chunkCoords = GeneralUtilities.worldToChunkCoordinates(point); + if (chunkCoords.x != chunkX || chunkCoords.y != chunkZ || !islandMap.isIsland(point.x, point.y)) return false; + biomeCache.set(point, currentIslandInfo.value); + Point2 localCoords = GeneralUtilities.worldToLocalChunkCoordinates(point); + localBiomeInfo[localCoords.x][localCoords.y] = currentIslandInfo.value; + return true; + } + }); + flooder.start(); } + } \ No newline at end of file diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/chunks/IslandWorldChunkGenerator.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/chunks/IslandWorldChunkGenerator.java index 7644e01..c546ad3 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/chunks/IslandWorldChunkGenerator.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/chunks/IslandWorldChunkGenerator.java @@ -14,6 +14,9 @@ import org.bukkit.event.Listener; import org.bukkit.generator.ChunkGenerator; import ca.recrown.islandsurvivalcraft.utilities.GeneralUtilities; +import ca.recrown.islandsurvivalcraft.utilities.biomes.BiomeInfo; +import ca.recrown.islandsurvivalcraft.utilities.biomes.LandBiomeInfo; +import ca.recrown.islandsurvivalcraft.utilities.biomes.OceanBiomeInfo; import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; import ca.recrown.islandsurvivalcraft.world.BiomeMap; @@ -27,6 +30,9 @@ import ca.recrown.islandsurvivalcraft.world.generation.shaders.WorldHeightShader import ca.recrown.islandsurvivalcraft.world.generation.shaders.WorldLayerShader; public class IslandWorldChunkGenerator extends ChunkGenerator implements Listener { + private final float TRANSITION_DEPTH_PORTION = 0.1f; + private final float DEEP_OCEAN_PORTION = 0.5f; + private final float HILL_BIOME_PORTION = 0.4f; private final int BEDROCK_HEIGHT = 5; private volatile GeneratorModes generatorType; private volatile boolean initialized = false; @@ -37,7 +43,7 @@ public class IslandWorldChunkGenerator extends ChunkGenerator implements Listene private volatile BiomeGenerator biomeGenerator; private volatile WorldHeightShader heightShader; private volatile WorldLayerShader layerShader; - private volatile Cache biomeCache = new Cache<>(131072); + private volatile Cache biomeCache = new Cache<>(131072); private final ExecutorService exAlpha = GeneralUtilities.ISC_EXECUTOR_ALPHA; public void initialize() { @@ -86,40 +92,72 @@ public class IslandWorldChunkGenerator extends ChunkGenerator implements Listene ChunkData chunkData = createChunkData(world); - Biome[][][] biomeArraySet = new Biome[GeneralUtilities.CHUNK_SIZE][GeneralUtilities.CHUNK_SIZE][5]; + BiomeInfo[][] localBiomeInfos = new BiomeInfo[GeneralUtilities.CHUNK_SIZE][GeneralUtilities.CHUNK_SIZE]; for (int x = 0; x < GeneralUtilities.CHUNK_SIZE; x++) { for (int z = 0; z < GeneralUtilities.CHUNK_SIZE; z++) { final int localX = x; final int localZ = z; final int worldX = GeneralUtilities.CHUNK_SIZE * chunkX + localX; final int worldZ = GeneralUtilities.CHUNK_SIZE * chunkZ + localZ; - if (biomeArraySet[localX][localZ][0] == null) { - biomeGenerator.generateBiomeColumn(biomeArraySet, world, chunkX, chunkZ, localX, localZ, islandMap, biomeMap, + if (localBiomeInfos[localX][localZ] == null) { + biomeGenerator.generateBiomeColumn(localBiomeInfos, chunkX, chunkZ, localX, localZ, islandMap, biomeMap, temperatureMap, biomeCache); } - - for (int y = 0; y < worldInfo.getWorldHeight(); y++) { - biomeGrid.setBiome(localX, y, localZ, biomeArraySet[localX][localZ][0]); + if (localBiomeInfos[localX][localZ] == null) throw new IllegalStateException("Biome column produced was null."); + Biome currentBiome = null; + if (islandMap.isIsland(worldX, worldZ)) { + LandBiomeInfo biomeInfo = (LandBiomeInfo) localBiomeInfos[localX][localZ]; + double islandVal = islandMap.getWorldValue(worldX, worldZ); + if (islandVal >= HILL_BIOME_PORTION) { + currentBiome = biomeInfo.getHillBiome(); + for (int y = 0; y < worldInfo.getWorldHeight(); y++) { + biomeGrid.setBiome(localX, y, localZ, biomeInfo.getHillBiome()); + } + } else { + currentBiome = biomeInfo.getBiome(); + for (int y = 0; y < worldInfo.getWorldHeight(); y++) { + biomeGrid.setBiome(localX, y, localZ, biomeInfo.getBiome()); + } + } + } else { + OceanBiomeInfo biomeInfo = (OceanBiomeInfo) localBiomeInfos[localX][localZ]; + double oceanVal = islandMap.getWorldValue(worldX, worldZ); + if (oceanVal >= TRANSITION_DEPTH_PORTION) { + currentBiome = biomeInfo.getTransitionOcean(); + for (int y = 0; y < worldInfo.getWorldHeight(); y++) { + biomeGrid.setBiome(localX, y, localZ, biomeInfo.getTransitionOcean()); + } + } else if (oceanVal >= DEEP_OCEAN_PORTION) { + currentBiome = biomeInfo.getOcean(); + for (int y = 0; y < worldInfo.getWorldHeight(); y++) { + biomeGrid.setBiome(localX, y, localZ, biomeInfo.getOcean()); + } + } else { + currentBiome = biomeInfo.getDeepAlternative(); + for (int y = 0; y < worldInfo.getWorldHeight(); y++) { + biomeGrid.setBiome(localX, y, localZ, biomeInfo.getDeepAlternative()); + } + } } - Biome[] currentBiomeSet = biomeArraySet[localX][localZ]; - int terrainHeight = heightShader.getTerrainHeight(worldX, worldZ, currentBiomeSet); + BiomeInfo currentBiomeInfo = localBiomeInfos[localX][localZ]; + int terrainHeight = heightShader.getTerrainHeight(worldX, worldZ, currentBiomeInfo); int currentTerrainHeight = terrainHeight - 1; int bedrockHeight = random.nextInt(5) + 1; - if (layerShader.hasSpecialLayers(currentBiomeSet[0])) { - BlockData currentMaterial = layerShader.getMaterialForHeight(worldInfo.getSeed(), worldX, worldZ, currentTerrainHeight, terrainHeight - 1, currentBiomeSet); + if (layerShader.hasSpecialLayers(currentBiome)) { + BlockData currentMaterial = layerShader.getMaterialForHeight(worldInfo.getSeed(), worldX, worldZ, currentTerrainHeight, terrainHeight - 1, currentBiome); while (currentMaterial != null) { chunkData.setBlock(localX, currentTerrainHeight, localZ, currentMaterial); currentTerrainHeight--; - currentMaterial = layerShader.getMaterialForHeight(worldInfo.getSeed(), worldX, worldZ, currentTerrainHeight, terrainHeight - 1, currentBiomeSet); + currentMaterial = layerShader.getMaterialForHeight(worldInfo.getSeed(), worldX, worldZ, currentTerrainHeight, terrainHeight - 1, currentBiome); } } else { - int surfaceThickness = layerShader.getSurfaceThickness(worldX, worldZ, currentBiomeSet[0]); + int surfaceThickness = layerShader.getSurfaceThickness(worldX, worldZ, currentBiome); currentTerrainHeight = currentTerrainHeight - surfaceThickness; - chunkData.setRegion(localX, currentTerrainHeight, localZ, localX + 1, currentTerrainHeight + surfaceThickness + 1, localZ + 1, layerShader.getSurfaceMaterial(currentBiomeSet[0])); - int transitionThickness = layerShader.getTransitionMaterialThickness(worldX, worldZ, currentBiomeSet[0]); + chunkData.setRegion(localX, currentTerrainHeight, localZ, localX + 1, currentTerrainHeight + surfaceThickness + 1, localZ + 1, layerShader.getSurfaceMaterial(currentBiome)); + int transitionThickness = layerShader.getTransitionMaterialThickness(worldX, worldZ, currentBiome); currentTerrainHeight = currentTerrainHeight - transitionThickness; - chunkData.setRegion(localX, currentTerrainHeight, localZ, localX + 1, currentTerrainHeight + transitionThickness + 1, localZ + 1, layerShader.getTransitionMaterial(currentBiomeSet[0])); + chunkData.setRegion(localX, currentTerrainHeight, localZ, localX + 1, currentTerrainHeight + transitionThickness + 1, localZ + 1, layerShader.getTransitionMaterial(currentBiome)); } chunkData.setRegion(localX, bedrockHeight, localZ, localX + 1, currentTerrainHeight + 1, localZ + 1, Material.STONE); if (terrainHeight < worldInfo.getSeaLevel()) { diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldHeightShader.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldHeightShader.java index 71e1018..cb21ca0 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldHeightShader.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldHeightShader.java @@ -5,6 +5,7 @@ import java.util.Random; import org.bukkit.block.Biome; import org.bukkit.util.noise.SimplexOctaveGenerator; +import ca.recrown.islandsurvivalcraft.utilities.biomes.BiomeInfo; import ca.recrown.islandsurvivalcraft.world.IslandWorldMap; public class WorldHeightShader { @@ -23,25 +24,16 @@ public class WorldHeightShader { this.noiseGenerator.setScale(0.0225d); } - public int getTerrainHeight(int worldX, int worldZ, Biome[] biomeSet) { + public int getTerrainHeight(int worldX, int worldZ, BiomeInfo biomeInfo) { int height = 0; - String biomeName = biomeSet[0].name().toLowerCase(); if (!mapper.isLand(worldX, worldZ)) { height = (int) Math.floor(calculateTerrainFactor(worldX, worldZ, seaLevel * 0.8d, 1.7d, 0.5d, 1d, 0.09d)); - } else if (biomeName.contains("beach")) { - if (biomeSet[1].name().toLowerCase().contains("mountains")) { - height = (int) (getIslandBiomeHeight(worldX, worldZ, biomeSet[1], -15d)); - } else { - height = (int) (getIslandBiomeHeight(worldX, worldZ, biomeSet[1], 0d)); - } - } else if (biomeName.contains("shore")) { - height = (int) (getIslandBiomeHeight(worldX, worldZ, biomeSet[1], -15d)); } else { - height = getIslandBiomeHeight(worldX, worldZ, biomeSet[0], 0d) + 1; + height = getIslandBiomeHeight(worldX, worldZ, biomeInfo.getMainBiome(), 0d); } height = Math.max(minimumHeight, height); - if (height > worldHeight) throw new IllegalStateException(String.format("Resulting height is greater than world height! Current biome set: %s, maximum height: %d, minimum height %d", biomeSet, worldHeight, minimumHeight)); + if (height > worldHeight) throw new IllegalStateException(String.format("Resulting height is greater than world height! Current biome info: %s, maximum height: %d, minimum height %d", biomeInfo, worldHeight, minimumHeight)); return height; } diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldLayerShader.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldLayerShader.java index 74f800b..a04f2f8 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldLayerShader.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldLayerShader.java @@ -54,8 +54,8 @@ public class WorldLayerShader { * @param biomeSet The biomeset for the current column. * @return The block data for the material, or null if there are no further special materials. */ - public BlockData getMaterialForHeight(long seed, int worldX, int worldZ, int y, int highestPoint, Biome[] biomeSet) { - Biome mainBiome = biomeSet[0]; + public BlockData getMaterialForHeight(long seed, int worldX, int worldZ, int y, int highestPoint, Biome currentBiome) { + Biome mainBiome = currentBiome; String mainBiomeName = mainBiome.toString().toLowerCase(); BlockData res = null; diff --git a/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/DummyWorld.java b/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/DummyWorld.java deleted file mode 100644 index b89bed3..0000000 --- a/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/DummyWorld.java +++ /dev/null @@ -1,1195 +0,0 @@ -package ca.recrown.islandsurvivalcraft.world.generation; - -import java.io.File; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.function.Predicate; - -import com.destroystokyo.paper.HeightmapType; - -import org.bukkit.BlockChangeDelegate; -import org.bukkit.Chunk; -import org.bukkit.ChunkSnapshot; -import org.bukkit.Difficulty; -import org.bukkit.Effect; -import org.bukkit.FluidCollisionMode; -import org.bukkit.GameRule; -import org.bukkit.HeightMap; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.Raid; -import org.bukkit.Sound; -import org.bukkit.SoundCategory; -import org.bukkit.StructureType; -import org.bukkit.TreeType; -import org.bukkit.World; -import org.bukkit.WorldBorder; -import org.bukkit.WorldType; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; -import org.bukkit.boss.DragonBattle; -import org.bukkit.entity.AbstractArrow; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Item; -import org.bukkit.entity.LightningStrike; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.generator.BlockPopulator; -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; -import org.bukkit.metadata.MetadataValue; -import org.bukkit.plugin.Plugin; -import org.bukkit.util.BoundingBox; -import org.bukkit.util.Consumer; -import org.bukkit.util.RayTraceResult; -import org.bukkit.util.Vector; - -@SuppressWarnings("deprecation") -public class DummyWorld implements World { - - @Override - public void sendPluginMessage(Plugin source, String channel, byte[] message) { - - } - - @Override - public Set getListeningPluginChannels() { - - return null; - } - - @Override - public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { - - } - - @Override - public List getMetadata(String metadataKey) { - - return null; - } - - @Override - public boolean hasMetadata(String metadataKey) { - - return false; - } - - @Override - public void removeMetadata(String metadataKey, Plugin owningPlugin) { - - } - - @Override - public int getEntityCount() { - - return 0; - } - - @Override - public int getTileEntityCount() { - - return 0; - } - - @Override - public int getTickableTileEntityCount() { - - return 0; - } - - @Override - public int getChunkCount() { - - return 0; - } - - @Override - public int getPlayerCount() { - - return 0; - } - - @Override - public Block getBlockAt(int x, int y, int z) { - - return null; - } - - @Override - public Block getBlockAt(Location location) { - - return null; - } - - @Override - public int getHighestBlockYAt(int x, int z) { - - return 0; - } - - @Override - public int getHighestBlockYAt(Location location) { - - return 0; - } - - @Override - public Block getHighestBlockAt(int x, int z) { - - return null; - } - - @Override - public Block getHighestBlockAt(Location location) { - - return null; - } - - @Override - public int getHighestBlockYAt(int x, int z, HeightmapType heightmap) throws UnsupportedOperationException { - - return 0; - } - - @Override - public int getHighestBlockYAt(int x, int z, HeightMap heightMap) { - - return 0; - } - - @Override - public int getHighestBlockYAt(Location location, HeightMap heightMap) { - - return 0; - } - - @Override - public Block getHighestBlockAt(int x, int z, HeightMap heightMap) { - - return null; - } - - @Override - public Block getHighestBlockAt(Location location, HeightMap heightMap) { - - return null; - } - - @Override - public Chunk getChunkAt(int x, int z) { - - return null; - } - - @Override - public Chunk getChunkAt(Location location) { - - return null; - } - - @Override - public Chunk getChunkAt(Block block) { - - return null; - } - - @Override - public CompletableFuture getChunkAtAsync(int x, int z, boolean gen) { - - return null; - } - - @Override - public boolean isChunkLoaded(Chunk chunk) { - - return false; - } - - @Override - public Chunk[] getLoadedChunks() { - - return null; - } - - @Override - public void loadChunk(Chunk chunk) { - - } - - @Override - public boolean isChunkLoaded(int x, int z) { - - return false; - } - - @Override - public boolean isChunkGenerated(int x, int z) { - - return false; - } - - @Override - public boolean isChunkInUse(int x, int z) { - - return false; - } - - @Override - public void loadChunk(int x, int z) { - - } - - @Override - public boolean loadChunk(int x, int z, boolean generate) { - - return false; - } - - @Override - public boolean unloadChunk(Chunk chunk) { - - return false; - } - - @Override - public boolean unloadChunk(int x, int z) { - - return false; - } - - @Override - public boolean unloadChunk(int x, int z, boolean save) { - - return false; - } - - @Override - public boolean unloadChunkRequest(int x, int z) { - - return false; - } - - @Override - public boolean regenerateChunk(int x, int z) { - - return false; - } - - @Override - public boolean refreshChunk(int x, int z) { - - return false; - } - - @Override - public boolean isChunkForceLoaded(int x, int z) { - - return false; - } - - @Override - public void setChunkForceLoaded(int x, int z, boolean forced) { - - } - - @Override - public Collection getForceLoadedChunks() { - - return null; - } - - @Override - public boolean addPluginChunkTicket(int x, int z, Plugin plugin) { - - return false; - } - - @Override - public boolean removePluginChunkTicket(int x, int z, Plugin plugin) { - - return false; - } - - @Override - public void removePluginChunkTickets(Plugin plugin) { - - } - - @Override - public Collection getPluginChunkTickets(int x, int z) { - - return null; - } - - @Override - public Map> getPluginChunkTickets() { - - return null; - } - - @Override - public Item dropItem(Location location, ItemStack item) { - - return null; - } - - @Override - public Item dropItemNaturally(Location location, ItemStack item) { - - return null; - } - - @Override - public Arrow spawnArrow(Location location, Vector direction, float speed, float spread) { - - return null; - } - - @Override - public T spawnArrow(Location location, Vector direction, float speed, float spread, - Class clazz) { - - return null; - } - - @Override - public boolean generateTree(Location location, TreeType type) { - - return false; - } - - @Override - public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { - - return false; - } - - @Override - public Entity spawnEntity(Location loc, EntityType type) { - - return null; - } - - @Override - public LightningStrike strikeLightning(Location loc) { - - return null; - } - - @Override - public LightningStrike strikeLightningEffect(Location loc) { - - return null; - } - - @Override - public List getEntities() { - - return null; - } - - @Override - public List getLivingEntities() { - - return null; - } - - @Override - @SuppressWarnings("unchecked") - public Collection getEntitiesByClass(Class... classes) { - - return null; - } - - @Override - public Collection getEntitiesByClass(Class cls) { - - return null; - } - - @Override - public Collection getEntitiesByClasses(Class... classes) { - - return null; - } - - @Override - public List getPlayers() { - - return null; - } - - @Override - public Collection getNearbyEntities(Location location, double x, double y, double z) { - - return null; - } - - @Override - public Entity getEntity(UUID uuid) { - - return null; - } - - @Override - public Collection getNearbyEntities(Location location, double x, double y, double z, - Predicate filter) { - - return null; - } - - @Override - public Collection getNearbyEntities(BoundingBox boundingBox) { - - return null; - } - - @Override - public Collection getNearbyEntities(BoundingBox boundingBox, Predicate filter) { - - return null; - } - - @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance) { - - return null; - } - - @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize) { - - return null; - } - - @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, - Predicate filter) { - - return null; - } - - @Override - public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, - Predicate filter) { - - return null; - } - - @Override - public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance) { - - return null; - } - - @Override - public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, - FluidCollisionMode fluidCollisionMode) { - - return null; - } - - @Override - public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, - FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) { - - return null; - } - - @Override - public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, - FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, - Predicate filter) { - - return null; - } - - @Override - public String getName() { - - return null; - } - - @Override - public UUID getUID() { - - return null; - } - - @Override - public Location getSpawnLocation() { - - return null; - } - - @Override - public boolean setSpawnLocation(int x, int y, int z) { - - return false; - } - - @Override - public long getTime() { - - return 0; - } - - @Override - public void setTime(long time) { - - } - - @Override - public long getFullTime() { - - return 0; - } - - @Override - public void setFullTime(long time) { - - } - - @Override - public boolean isDayTime() { - - return false; - } - - @Override - public boolean hasStorm() { - - return false; - } - - @Override - public void setStorm(boolean hasStorm) { - - } - - @Override - public int getWeatherDuration() { - - return 0; - } - - @Override - public void setWeatherDuration(int duration) { - - } - - @Override - public boolean isThundering() { - - return false; - } - - @Override - public void setThundering(boolean thundering) { - - } - - @Override - public int getThunderDuration() { - - return 0; - } - - @Override - public void setThunderDuration(int duration) { - - } - - @Override - public boolean createExplosion(double x, double y, double z, float power) { - - return false; - } - - @Override - public boolean createExplosion(double x, double y, double z, float power, boolean setFire) { - - return false; - } - - @Override - public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks) { - - return false; - } - - @Override - public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, - Entity source) { - - return false; - } - - @Override - public boolean createExplosion(Location loc, float power) { - - return false; - } - - @Override - public boolean createExplosion(Location loc, float power, boolean setFire) { - - return false; - } - - @Override - public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks) { - - return false; - } - - @Override - public boolean createExplosion(Location loc, float power, boolean setFire, boolean breakBlocks) { - - return false; - } - - @Override - public boolean createExplosion(Location loc, float power, boolean setFire, boolean breakBlocks, Entity source) { - - return false; - } - - @Override - public Environment getEnvironment() { - - return null; - } - - @Override - public long getSeed() { - - return 0; - } - - @Override - public boolean getPVP() { - - return false; - } - - @Override - public void setPVP(boolean pvp) { - - } - - @Override - public ChunkGenerator getGenerator() { - - return null; - } - - @Override - public void save() { - - } - - @Override - public List getPopulators() { - - return null; - } - - @Override - public T spawn(Location location, Class clazz) throws IllegalArgumentException { - - return null; - } - - @Override - public T spawn(Location location, Class clazz, Consumer function) - throws IllegalArgumentException { - - return null; - } - - @Override - public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException { - - return null; - } - - @Override - public FallingBlock spawnFallingBlock(Location location, BlockData data) throws IllegalArgumentException { - - return null; - } - - @Override - public FallingBlock spawnFallingBlock(Location location, Material material, byte data) - throws IllegalArgumentException { - - return null; - } - - @Override - public void playEffect(Location location, Effect effect, int data) { - - } - - @Override - public void playEffect(Location location, Effect effect, int data, int radius) { - - } - - @Override - public void playEffect(Location location, Effect effect, T data) { - - } - - @Override - public void playEffect(Location location, Effect effect, T data, int radius) { - - } - - @Override - public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTemp) { - - return null; - } - - @Override - public void setSpawnFlags(boolean allowMonsters, boolean allowAnimals) { - - } - - @Override - public boolean getAllowAnimals() { - - return false; - } - - @Override - public boolean getAllowMonsters() { - - return false; - } - - @Override - public Biome getBiome(int x, int z) { - - return null; - } - - @Override - public Biome getBiome(int x, int y, int z) { - - return null; - } - - @Override - public void setBiome(int x, int z, Biome bio) { - - } - - @Override - public void setBiome(int x, int y, int z, Biome bio) { - - } - - @Override - public double getTemperature(int x, int z) { - - return 0; - } - - @Override - public double getTemperature(int x, int y, int z) { - - return 0; - } - - @Override - public double getHumidity(int x, int z) { - - return 0; - } - - @Override - public double getHumidity(int x, int y, int z) { - - return 0; - } - - @Override - public int getMaxHeight() { - - return 0; - } - - @Override - public int getSeaLevel() { - - return 0; - } - - @Override - public boolean getKeepSpawnInMemory() { - - return false; - } - - @Override - public void setKeepSpawnInMemory(boolean keepLoaded) { - - } - - @Override - public boolean isAutoSave() { - - return false; - } - - @Override - public void setAutoSave(boolean value) { - - } - - @Override - public void setDifficulty(Difficulty difficulty) { - - } - - @Override - public Difficulty getDifficulty() { - - return null; - } - - @Override - public File getWorldFolder() { - - return null; - } - - @Override - public WorldType getWorldType() { - - return null; - } - - @Override - public boolean canGenerateStructures() { - - return false; - } - - @Override - public boolean isHardcore() { - - return false; - } - - @Override - public void setHardcore(boolean hardcore) { - - } - - @Override - public long getTicksPerAnimalSpawns() { - - return 0; - } - - @Override - public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns) { - - } - - @Override - public long getTicksPerMonsterSpawns() { - - return 0; - } - - @Override - public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) { - - } - - @Override - public long getTicksPerWaterSpawns() { - - return 0; - } - - @Override - public void setTicksPerWaterSpawns(int ticksPerWaterSpawns) { - - } - - @Override - public long getTicksPerAmbientSpawns() { - - return 0; - } - - @Override - public void setTicksPerAmbientSpawns(int ticksPerAmbientSpawns) { - - } - - @Override - public int getMonsterSpawnLimit() { - - return 0; - } - - @Override - public void setMonsterSpawnLimit(int limit) { - - } - - @Override - public int getAnimalSpawnLimit() { - - return 0; - } - - @Override - public void setAnimalSpawnLimit(int limit) { - - } - - @Override - public int getWaterAnimalSpawnLimit() { - - return 0; - } - - @Override - public void setWaterAnimalSpawnLimit(int limit) { - - } - - @Override - public int getAmbientSpawnLimit() { - - return 0; - } - - @Override - public void setAmbientSpawnLimit(int limit) { - - } - - @Override - public void playSound(Location location, Sound sound, float volume, float pitch) { - - } - - @Override - public void playSound(Location location, String sound, float volume, float pitch) { - - } - - @Override - public void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch) { - - } - - @Override - public void playSound(Location location, String sound, SoundCategory category, float volume, float pitch) { - - } - - @Override - public String[] getGameRules() { - - return null; - } - - @Override - public String getGameRuleValue(String rule) { - - return null; - } - - @Override - public boolean setGameRuleValue(String rule, String value) { - - return false; - } - - @Override - public boolean isGameRule(String rule) { - - return false; - } - - @Override - public T getGameRuleValue(GameRule rule) { - - return null; - } - - @Override - public T getGameRuleDefault(GameRule rule) { - - return null; - } - - @Override - public boolean setGameRule(GameRule rule, T newValue) { - - return false; - } - - @Override - public WorldBorder getWorldBorder() { - - return null; - } - - @Override - public void spawnParticle(Particle particle, Location location, int count) { - - } - - @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count) { - - } - - @Override - public void spawnParticle(Particle particle, Location location, int count, T data) { - - } - - @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, T data) { - - } - - @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, - double offsetZ) { - - } - - @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, - double offsetY, double offsetZ) { - - } - - @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, - double offsetZ, T data) { - - } - - @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, - double offsetY, double offsetZ, T data) { - - } - - @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, - double offsetZ, double extra) { - - } - - @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, - double offsetY, double offsetZ, double extra) { - - } - - @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, - double offsetZ, double extra, T data) { - - } - - @Override - public void spawnParticle(Particle particle, List receivers, Player source, double x, double y, - double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { - - } - - @Override - public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, - double offsetZ, double extra, T data, boolean force) { - - } - - @Override - public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, - double offsetY, double offsetZ, double extra, T data, boolean force) { - - } - - @Override - public Location locateNearestStructure(Location origin, StructureType structureType, int radius, - boolean findUnexplored) { - - return null; - } - - @Override - public int getViewDistance() { - - return 0; - } - - @Override - public Spigot spigot() { - - return null; - } - - @Override - public Raid locateNearestRaid(Location location, int radius) { - - return null; - } - - @Override - public List getRaids() { - - return null; - } - - @Override - public DragonBattle getEnderDragonBattle() { - - return null; - } - - @Override - public int getNoTickViewDistance() { - return 0; - } - - @Override - public void setNoTickViewDistance(int arg0) { - } - - @Override - public boolean setSpawnLocation(Location location) { - return false; - } - - @Override - public void setViewDistance(int arg0) { - } - -} \ No newline at end of file diff --git a/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGeneratorTest.java b/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGeneratorTest.java index d7d9a92..5724196 100644 --- a/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGeneratorTest.java +++ b/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGeneratorTest.java @@ -10,7 +10,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import org.bukkit.block.Biome; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -20,19 +19,17 @@ import org.junit.jupiter.api.Timeout; import org.junit.jupiter.api.TestInstance.Lifecycle; import ca.recrown.islandsurvivalcraft.utilities.GeneralUtilities; +import ca.recrown.islandsurvivalcraft.utilities.biomes.BiomeInfo; import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; import ca.recrown.islandsurvivalcraft.world.BiomeMap; import ca.recrown.islandsurvivalcraft.world.IslandWorldMap; import ca.recrown.islandsurvivalcraft.world.TemperatureMap; -import ca.recrown.islandsurvivalcraft.world.generation.DummyWorld; @TestInstance(Lifecycle.PER_CLASS) public class UniqueBiomeGeneratorTest { private final int SEED = 249398015; - private final DummyWorld dummyWorld = new DummyWorld(); - private volatile Cache blockValueCache; - private volatile Cache biomeCache; + private volatile Cache biomeCache; private final BiomeMap biomeSelector = new BiomeMap(new Random(SEED)); @@ -59,11 +56,11 @@ public class UniqueBiomeGeneratorTest { TemperatureMap temperatureMapGenerator = new TemperatureMap(random); BiomeGenerator biomeGenerator = new UniqueBiomeGenerator(); - Biome[][][] biomes = new Biome[GeneralUtilities.CHUNK_SIZE][GeneralUtilities.CHUNK_SIZE][4]; + BiomeInfo[][] biomes = new BiomeInfo[GeneralUtilities.CHUNK_SIZE][GeneralUtilities.CHUNK_SIZE]; for (int localX = 0; localX < GeneralUtilities.CHUNK_SIZE; localX++) { for (int localZ = 0; localZ < GeneralUtilities.CHUNK_SIZE; localZ++) { if (biomes[localX][localZ] == null) { - biomeGenerator.generateBiomeColumn(biomes, dummyWorld, chunkX, chunkZ, localX, localZ, mapper, + biomeGenerator.generateBiomeColumn(biomes, chunkX, chunkZ, localX, localZ, mapper, biomeSelector, temperatureMapGenerator, biomeCache); } if (biomes[localX][localZ] == null) @@ -79,13 +76,11 @@ public class UniqueBiomeGeneratorTest { @BeforeEach public void individualSetup() { - blockValueCache = new Cache<>(524288); biomeCache = new Cache<>(524288); } @AfterEach public void individualCleanup() { - blockValueCache.clearCache(); biomeCache.clearCache(); } @@ -122,7 +117,6 @@ public class UniqueBiomeGeneratorTest { @Test @Timeout(value = 1, unit = TimeUnit.MINUTES) public void testBiomeGenerationMultithread1608ChunksSmallCache() { - this.blockValueCache = new Cache<>(1024); this.biomeCache = new Cache<>(1024); int chunksToDoEach = 268; @@ -192,7 +186,6 @@ public class UniqueBiomeGeneratorTest { @Test @Timeout(value = 1, unit = TimeUnit.MINUTES) public void testBiomeGenerationMultithread1608ChunksScatteredColumnsSmallCache() { - this.blockValueCache = new Cache<>(1024); this.biomeCache = new Cache<>(1024); int chunksToDoEach = 268; Runnable g1 = new BiomeGenTask(chunksToDoEach, 0); @@ -254,7 +247,6 @@ public class UniqueBiomeGeneratorTest { @Test @Timeout(value = 1, unit = TimeUnit.MINUTES) public void testBiomeGenerationMultithread6000ChunksScatteredColumnsSmallCache() { - this.blockValueCache = new Cache<>(1024); this.biomeCache = new Cache<>(1024); int chunksToDoEach = 1000;