From fc9aca3bb145b650094d69800be8449343606504 Mon Sep 17 00:00:00 2001 From: Harrison Date: Sun, 3 May 2020 18:24:23 -0500 Subject: [PATCH] Overworld general terrain generation complete. Added warning supression for unused as it may be used in the future. --- .../islandsurvivalcraft/Utilities.java | 4 +-- .../preferences/GeneralConfiguration.java | 13 ++++++++++ .../generation/IslandWorldChunkGenerator.java | 25 +++++++++++++++++++ .../generation/populators/TreePopulator.java | 18 ------------- .../world/shaders/WorldHeightShader.java | 3 +-- .../world/shaders/WorldLayerShader.java | 19 ++------------ 6 files changed, 43 insertions(+), 39 deletions(-) create mode 100644 src/main/java/ca/recrown/islandsurvivalcraft/preferences/GeneralConfiguration.java delete mode 100644 src/main/java/ca/recrown/islandsurvivalcraft/world/generation/populators/TreePopulator.java diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/Utilities.java b/src/main/java/ca/recrown/islandsurvivalcraft/Utilities.java index ebf6391..3138388 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/Utilities.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/Utilities.java @@ -11,8 +11,8 @@ import ca.recrown.islandsurvivalcraft.datatypes.Point2; public class Utilities { public final static int CHUNK_SIZE = 16; - public final static ExecutorService ISC_EXECUTOR_ALPHA = Executors.newFixedThreadPool(1, createThreadFactory("ALPHA", Thread.NORM_PRIORITY)); - public final static ExecutorService ISC_EXECUTOR_BETA = Executors.newFixedThreadPool(2, createThreadFactory("BETA", Thread.MIN_PRIORITY)); + public final static ExecutorService ISC_EXECUTOR_ALPHA = Executors.newFixedThreadPool(1, createThreadFactory("ALPHA", Thread.NORM_PRIORITY + 1)); + public final static ExecutorService ISC_EXECUTOR_BETA = Executors.newFixedThreadPool(2, createThreadFactory("BETA", Thread.NORM_PRIORITY)); public static HashMap> invertHashMap(HashMap hashMap) { HashMap> res = new HashMap<>(); diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/preferences/GeneralConfiguration.java b/src/main/java/ca/recrown/islandsurvivalcraft/preferences/GeneralConfiguration.java new file mode 100644 index 0000000..af1c2b1 --- /dev/null +++ b/src/main/java/ca/recrown/islandsurvivalcraft/preferences/GeneralConfiguration.java @@ -0,0 +1,13 @@ +package ca.recrown.islandsurvivalcraft.preferences; + +import java.io.Serializable; + +public class GeneralConfiguration implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 5820622075140630470L; + + +} \ No newline at end of file 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 90ad8ee..3078135 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/IslandWorldChunkGenerator.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/IslandWorldChunkGenerator.java @@ -130,6 +130,31 @@ public class IslandWorldChunkGenerator extends ChunkGenerator implements Listene return location; } + @Override + public boolean canSpawn(World world, int x, int z) { + IslandWorldMapper mapper = new IslandWorldMapper(world.getSeed(), blockValueCache); + return mapper.isLand(x, z); + } + + @Override + public boolean shouldGenerateCaves() { + return true; + } + + @Override + public boolean shouldGenerateDecorations() { + return true; + } + + @Override + public boolean shouldGenerateStructures() { + return true; + } + + @Override + public boolean shouldGenerateMobs() { + return true; + } @Override public boolean isParallelCapable() { diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/populators/TreePopulator.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/populators/TreePopulator.java deleted file mode 100644 index fd9318b..0000000 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/populators/TreePopulator.java +++ /dev/null @@ -1,18 +0,0 @@ -package ca.recrown.islandsurvivalcraft.world.generation.populators; - -import java.util.Random; - -import org.bukkit.Chunk; -import org.bukkit.World; -import org.bukkit.generator.BlockPopulator; - -public class TreePopulator extends BlockPopulator { - - @Override - public void populate(World world, Random random, Chunk source) { - if (random.nextBoolean()) { - - } - } - -} \ No newline at end of file diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/shaders/WorldHeightShader.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/shaders/WorldHeightShader.java index 07b3307..5334879 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/shaders/WorldHeightShader.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/shaders/WorldHeightShader.java @@ -31,12 +31,11 @@ public class WorldHeightShader { } else if (biomeName.contains("beach")) { height = (int) (getIslandBiomeHeight(worldX, worldZ, biomeSet[1], 5d)); } else if (biomeName.contains("shore")) { - height = (int) (getIslandBiomeHeight(worldX, worldZ, biomeSet[1], 20d)); + height = (int) (getIslandBiomeHeight(worldX, worldZ, biomeSet[1], 30d)); } else { height = getIslandBiomeHeight(worldX, worldZ, biomeSet[0], 0d) + 1; } - if (biomeName.contains("snowy")) height++; if (height > worldHeight) throw new IllegalStateException("Resulting height is greater than world height! Biome this occurred on: " + biomeName); height = Math.max(minimumHeight, height); return height; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/shaders/WorldLayerShader.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/shaders/WorldLayerShader.java index f660677..1cc59b6 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/shaders/WorldLayerShader.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/shaders/WorldLayerShader.java @@ -5,13 +5,13 @@ import java.util.Random; import org.bukkit.Material; import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Snowable; import org.bukkit.util.noise.SimplexOctaveGenerator; import ca.recrown.islandsurvivalcraft.caching.Cache; import ca.recrown.islandsurvivalcraft.datatypes.Vector3; import ca.recrown.islandsurvivalcraft.world.IslandWorldMapper; +@SuppressWarnings("unused") public class WorldLayerShader { private final Cache noiseCache = new Cache<>(256); private final SimplexOctaveGenerator noise; @@ -82,7 +82,7 @@ public class WorldLayerShader { } } } else if (mainBiomeName.contains("mountain")) { - if (y > (maxHeight * 0.48d) - getNormalizedNoise(worldX, worldZ, 2f) * 6d) { + if (y > (maxHeight * 0.48d) - getNormalizedNoise(worldX, worldZ, 2.2f) * 8d) { res = Material.STONE.createBlockData(); } else if (y > highestPoint - getSurfaceThickness(worldX, worldZ, mainBiome)) { res = getSurfaceMaterial(mainBiome).createBlockData(); @@ -91,20 +91,6 @@ public class WorldLayerShader { } } - - if (mainBiomeName.contains("snowy")) { - if (highestPoint == y) { - res = Material.SNOW.createBlockData(); - } else if (y > highestPoint - 1 - getSurfaceThickness(worldX, worldZ, mainBiome)) { - if (res == null || res.getMaterial() == Material.DIRT) res = getSurfaceMaterial(mainBiome).createBlockData(); - if (res.getMaterial() == Material.GRASS_BLOCK) { - Snowable snowable = (Snowable) res; - snowable.setSnowy(true); - } - } else if (y > highestPoint - 1 - getSurfaceThickness(worldX, worldZ, mainBiome) - getTransitionMaterialThickness(worldX, worldZ, mainBiome)) { - if (res == null) res = getTransitionMaterial(mainBiome).createBlockData(); - } - } return res; } @@ -128,7 +114,6 @@ public class WorldLayerShader { if (biomeName.contains("beach")) { return (int) (getNormalizedNoise(worldX, worldZ, 1.3f) * 5) + 4; } - return 1; }