diff --git a/Engine b/Engine index 6babefb..7cda523 160000 --- a/Engine +++ b/Engine @@ -1 +1 @@ -Subproject commit 6babefb3017d33a78c914eda21fd1fa3b53dc9e3 +Subproject commit 7cda523891ce81b36dd5f09f5573e1f258f92923 diff --git a/FeatureManager b/FeatureManager index 0da0d13..fceeea1 160000 --- a/FeatureManager +++ b/FeatureManager @@ -1 +1 @@ -Subproject commit 0da0d13c3dc8426b18a55107b42986e9d66387f1 +Subproject commit fceeea1cac7174f873834fa12b5d78952710a516 diff --git a/TerraEngine b/TerraEngine deleted file mode 160000 index c369779..0000000 --- a/TerraEngine +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c36977964d2f203fe9a940df908d1b7c2fac264b diff --git a/TerraForgedAPI/README.md b/TerraForgedAPI/README.md deleted file mode 100644 index 2d5f64e..0000000 --- a/TerraForgedAPI/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# TerraForgedAPI - -### Dependency -```groovy -repositories { - maven { - url "https://io.terraforged.com/repository/maven/" - } -} - -dependencies { - implementation "com.terraforged:TerraForgedAPI:1.15.2-0.0.1" -} -``` - -### Usage - -TerraForged fires a number of setup events each time its chunk generator is created. These events expose certain -components of the generator allowing for world-gen content to be configured, modified, or added to. - -See the `com.terraforged.api.TerraEvent` class for the available events. - -All events are fired on the `FORGE` event bus. \ No newline at end of file diff --git a/TerraForgedAPI/build.gradle b/TerraForgedAPI/build.gradle deleted file mode 100644 index cf77135..0000000 --- a/TerraForgedAPI/build.gradle +++ /dev/null @@ -1,70 +0,0 @@ -buildscript { - repositories { - maven { url "https://files.minecraftforge.net/maven" } - jcenter() - mavenCentral() - } - dependencies { - classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "3.+", changing: true - } -} - -apply plugin: "net.minecraftforge.gradle" -apply plugin: "maven-publish" -apply plugin: "eclipse" - -version = "${mc_version}-${mod_version}" -archivesBaseName = "TerraForgedAPI" - -repositories { - jcenter() - mavenCentral() -} - -dependencies { - minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" - compile project(":FeatureManager") - compile project(":TerraForgedCore") -} - -minecraft { - mappings channel: mcp_channel, version: mcp_version -} - -task sourceJar(type: Jar) { - classifier = "sources" - from("$projectDir/src/main/java") - from(project(":Noise2D").projectDir.getPath() + "/src/main/java") - from(project(":FeatureManager").projectDir.getPath() + "/src/main/java") - from(project(":TerraForgedCore").projectDir.getPath() + "/src/main/java") -} - -jar { - dependsOn(sourceJar) - from("$buildDir/classes/java/main") - from(project(":Noise2D").buildDir.getPath() + "/classes/java/main") - from(project(":FeatureManager").buildDir.getPath() + "/classes/java/main") - from(project(":TerraForgedCore").buildDir.getPath() + "/classes/java/main") -} - -publishing { - publications { - mavenJava(MavenPublication) { - artifact jar - artifact sourceJar - } - } - - if (System.getenv("MAVEN_USER") != null && System.getenv("MAVEN_PASS") != null) { - repositories { - maven { - credentials { - username System.getenv("MAVEN_USER") - password System.getenv("MAVEN_PASS") - } - name = "nexus" - url = "https://io.terraforged.com/repository/maven/" - } - } - } -} \ No newline at end of file diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/state/StateTagPredicate.java b/TerraForgedAPI/src/main/java/com/terraforged/api/material/state/StateTagPredicate.java deleted file mode 100644 index 87f0d5f..0000000 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/material/state/StateTagPredicate.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.terraforged.api.material.state; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.tags.Tag; - -import java.util.function.Predicate; - -public class StateTagPredicate implements Predicate { - - private final Tag tag; - - public StateTagPredicate(Tag tag) { - this.tag = tag; - } - - @Override - public boolean test(BlockState state) { - return tag.contains(state.getBlock()); - } -} diff --git a/TerraForgedApp/build.gradle b/TerraForgedApp/build.gradle deleted file mode 100644 index dfefdc8..0000000 --- a/TerraForgedApp/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -apply plugin: "maven-publish" -apply plugin: "java" - -repositories { - mavenCentral() - jcenter() -} - -dependencies { - compile "com.google.code.gson:gson:2.8.0" - compile "org.processing:core:3.3.7" - compile "it.unimi.dsi:fastutil:8.2.1" - compile project(":TerraForgedCore") -} - -jar { - manifest { attributes "Main-Class": "com.terraforged.app.Main" } - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } -} - -publish { - dependsOn(jar) -} \ No newline at end of file diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/Applet.java b/TerraForgedApp/src/main/java/com/terraforged/app/Applet.java deleted file mode 100644 index 9945daf..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/Applet.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app; - -import com.terraforged.app.renderer.MeshRenderer; -import com.terraforged.app.renderer.Renderer; -import com.terraforged.app.renderer.VoxelRenderer; -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; -import processing.core.PApplet; -import processing.event.KeyEvent; -import processing.event.MouseEvent; - -public abstract class Applet extends PApplet { - - public static final int ELEVATION = 1; - public static final int BIOME_TYPE = 2; - public static final int TEMPERATURE = 3; - public static final int MOISTURE = 4; - public static final int BIOME = 5; - public static final int STEEPNESS = 6; - public static final int TERRAIN_TYPE = 7; - public static final int EROSION = 8; - public static final int CONTINENT = 9; - - protected Renderer mesh = new MeshRenderer(this); - protected Renderer voxel = new VoxelRenderer(this); - - public final Controller controller = new Controller(); - - public abstract Cache getCache(); - - public abstract float color(Cell cell); - - @Override - public void settings() { - size(800, 800, P3D); - } - - @Override - public void mousePressed(MouseEvent event) { - controller.mousePress(event); - } - - @Override - public void mouseReleased(MouseEvent event) { - controller.mouseRelease(event); - } - - @Override - public void mouseDragged(MouseEvent event) { - controller.mouseDrag(event); - } - - @Override - public void mouseWheel(MouseEvent event) { - controller.mouseWheel(event); - } - - @Override - public void keyPressed(KeyEvent event) { - controller.keyPress(event); - } - - @Override - public void keyReleased(KeyEvent event) { - controller.keyRelease(event); - } - - public void leftAlignText(int margin, int top, int lineHeight, String... lines) { - noLights(); - fill(0, 0, 100); - for (int i = 0; i < lines.length; i++) { - int y = top + (i * lineHeight); - text(lines[i], margin, y); - } - } - - - public void drawTerrain(float zoom) { - if (controller.getRenderMode() == 0) { - voxel.render(zoom); - } else { - mesh.render(zoom); - } - } - - public String colorModeName() { - switch (controller.getColorMode()) { - case STEEPNESS: - return "GRADIENT"; - case TEMPERATURE: - return "TEMPERATURE"; - case MOISTURE: - return "MOISTURE"; - case TERRAIN_TYPE: - return "TERRAIN TYPE"; - case ELEVATION: - return "ELEVATION"; - case BIOME_TYPE: - return "BIOME TYPE"; - case BIOME: - return "BIOME"; - case EROSION: - return "EROSION"; - case CONTINENT: - return "CONTINENT"; - default: - return "-"; - } - } - - public static float hue(float value, int steps, int max) { - value = Math.round(value * (steps - 1)); - value /= (steps - 1); - return value * max; - } - - public void drawCompass() { - pushStyle(); - pushMatrix(); - textSize(200); - fill(100, 0, 100); - - char[] chars = {'N', 'E', 'S', 'W'}; - for (int r = 0; r < 4; r++) { - char c = chars[r]; - float x = -textWidth(c) / 2; - float y = -width * 1.2F; - text(c, x, y); - rotateZ(0.5F * PI); - } - - popMatrix(); - popStyle(); - textSize(16); - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/Cache.java b/TerraForgedApp/src/main/java/com/terraforged/app/Cache.java deleted file mode 100644 index 17aff83..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/Cache.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.region.Region; -import com.terraforged.core.region.gen.RegionGenerator; -import com.terraforged.core.settings.Settings; -import com.terraforged.core.util.concurrent.ThreadPool; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.WorldGeneratorFactory; -import com.terraforged.core.world.biome.BiomeType; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; - -public class Cache { - - private float offsetX = 0; - private float offsetZ = 0; - private float zoom = 0F; - private boolean filter = true; - private Terrains terrain; - private Settings settings; - private GeneratorContext context; - private Region region; - private RegionGenerator renderer; - - public Cache(int seed) { - Settings settings = new Settings(); - settings.generator.seed = seed; - this.settings = settings; - this.terrain = Terrains.create(settings); - this.context = new GeneratorContext(terrain, settings); - this.renderer = RegionGenerator.builder() - .factory(new WorldGeneratorFactory(context)) - .pool(ThreadPool.getPool()) - .size(3, 2) - .build(); - } - - public Settings getSettings() { - return settings; - } - - public Terrains getTerrain() { - return terrain; - } - - public Terrain getCenterTerrain() { - Terrain tag = getCenterCell().tag; - return tag == null ? terrain.ocean : tag; - } - - public BiomeType getCenterBiomeType() { - return getCenterCell().biomeType; - } - - public int getCenterHeight() { - return (int) (context.levels.worldHeight * getCenterCell().value); - } - - public Cell getCenterCell() { - int center = region.getBlockSize().size / 2; - return region.getCell(center, center); - } - - public Region getRegion() { - return region; - } - - public void update(float offsetX, float offsetZ, float zoom, boolean filters) { - if (region == null) { - record(offsetX, offsetZ, zoom, filters); - return; - } - if (this.offsetX != offsetX || this.offsetZ != offsetZ) { - record(offsetX, offsetZ, zoom, filters); - return; - } - if (this.zoom != zoom) { - record(offsetX, offsetZ, zoom, filters); - return; - } - if (this.filter != filters) { - record(offsetX, offsetZ, zoom, filters); - } - } - - private void record(float offsetX, float offsetZ, float zoom, boolean filters) { - this.zoom = zoom; - this.filter = filters; - this.offsetX = offsetX; - this.offsetZ = offsetZ; - try { - this.region = renderer.generateRegion(offsetX, offsetZ, zoom, filters); - } catch (Throwable t) { - t.printStackTrace(); - } - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/Controller.java b/TerraForgedApp/src/main/java/com/terraforged/app/Controller.java deleted file mode 100644 index b5ee022..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/Controller.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app; - -import processing.core.PApplet; -import processing.event.KeyEvent; -import processing.event.MouseEvent; - -import java.awt.*; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.StringSelection; -import java.awt.event.ActionEvent; - -public class Controller { - - private static final int BUTTON_NONE = -1; - private static final int BUTTON_1 = 37; - private static final int BUTTON_2 = 39; - private static final int BUTTON_3 = 3; - - private static final float cameraSpeed = 100F; - private static final float zoomSpeed = 0.01F; - private static final float rotateSpeed = 0.002F; - private static final float translateSpeed = 2F; - private static final float moveSpeed = 10F; - - private int mouseButton = BUTTON_NONE; - private int lastX = 0; - private int lastY = 0; - - private float yaw = -0.2F; - private float pitch = 0.85F; - private float translateX = 0F; - private float translateY = 0F; - private float translateZ = -800; - private float velocityX = 0F; - private float velocityY = 0F; - - private int colorMode = 1; - private int renderMode = 0; - private int newSeed = 0; - private int left = 0; - private int right = 0; - private int up = 0; - private int down = 0; - private float zoom = 16; - private boolean filters = true; - - public void apply(PApplet applet) { - applet.translate(translateX, translateY, translateZ); - applet.translate(applet.width / 2, applet.height / 2, 0); - applet.rotateX(pitch); - applet.rotateZ(yaw); - update(); - } - - public void update() { - float forward = up + down; - float strafe = left + right; - velocityX = forward * (float) Math.sin(yaw); - velocityY = forward * (float) Math.cos(yaw); - velocityX += strafe * (float) Math.sin(yaw + Math.toRadians(90)); - velocityY += strafe * (float) Math.cos(yaw + Math.toRadians(90)); - if (velocityX != 0 || velocityY != 0) { - float magnitude = (float) Math.sqrt(velocityX * velocityX + velocityY * velocityY); - velocityX /= magnitude; - velocityY /= magnitude; - } - } - - public int getColorMode() { - return colorMode; - } - - public int getRenderMode() { - return renderMode; - } - - public float velocityX() { - return velocityX * moveSpeed / zoom; - } - - public float velocityY() { - return velocityY * moveSpeed / zoom; - } - - public float zoomLevel() { - return zoom; - } - - public boolean filters() { - return filters; - } - - public int getNewSeed() { - if (newSeed == 1) { - newSeed = 0; - return 1; - } - if (newSeed != 0) { - int val = newSeed; - newSeed = 0; - return val; - } - return 0; - } - - public void keyPress(KeyEvent event) { - switch (event.getKey()) { - case 'w': - up = -1; - break; - case 'a': - left = -1; - break; - case 's': - down = 1; - break; - case 'd': - right = 1; - break; - } - } - - public void keyRelease(KeyEvent event) { - switch (event.getKey()) { - case 'w': - up = 0; - return; - case 'a': - left = 0; - return; - case 's': - down = 0; - return; - case 'd': - right = 0; - return; - case 'r': - renderMode = renderMode == 0 ? 1 : 0; - return; - case 'n': - newSeed = 1; - return; - case 'm': - newSeed = Main.seed; - return; - case 'f': - filters = !filters; - return; - case 'c': - StringSelection selection = new StringSelection("" + Main.seed); - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, null); - return; - case 'v': - try { - Object data = Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor); - newSeed = (int) Long.parseLong(data.toString()); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - if (event.getKey() >= '1' && event.getKey() <= '9') { - colorMode = event.getKey() - '0'; - return; - } - } - - public void mousePress(MouseEvent event) { - if (mouseButton == BUTTON_NONE) { - lastX = event.getX(); - lastY = event.getY(); - mouseButton = event.getButton(); - } - } - - public void mouseRelease(MouseEvent event) { - mouseButton = BUTTON_NONE; - } - - public void mouseWheel(MouseEvent event) { - translateZ -= event.getCount() * cameraSpeed; - } - - public void mouseDrag(MouseEvent event) { - int dx = event.getX() - lastX; - int dy = event.getY() - lastY; - boolean ctrl = (event.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK; - - lastX = event.getX(); - lastY = event.getY(); - - if (mouseButton == BUTTON_1) { - yaw -= dx * rotateSpeed; - pitch -= dy * rotateSpeed; - } - - if (mouseButton == BUTTON_2) { - translateX += dx * translateSpeed; - translateY += dy * translateSpeed; - } - - if (mouseButton == BUTTON_3) { - if (ctrl) { - zoom += (dy - dx) * zoom * zoomSpeed; - zoom = Math.max(1F, zoom); - } else { - translateZ -= (dy - dx) * cameraSpeed * 0.1F; - } - } - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/Main.java b/TerraForgedApp/src/main/java/com/terraforged/app/Main.java deleted file mode 100644 index b1627ff..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/Main.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app; - -import com.terraforged.app.biome.BiomeProvider; -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.biome.BiomeData; -import com.terraforged.core.world.biome.BiomeType; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.util.NoiseUtil; - -import java.awt.*; -import java.util.Random; - -public class Main extends Applet { - - public static void main(String[] args) { - Main.start(-1); - } - - public static void start(long seed) { - Main.seed = (int) seed; - Main.random = seed == -1; - main(Main.class.getName()); - } - - private static boolean random = false; - public static int seed = -1; - - private Cache cache; - private float offsetX = 0; - private float offsetZ = 0; - private final String bits = System.getProperty("sun.arch.data.model"); - private final BiomeProvider biomeProvider = new BiomeProvider(); - - @Override - public Cache getCache() { - return cache; - } - - @Override - public void setup() { - super.setup(); - if (random) { - setSeed(new Random(System.currentTimeMillis()).nextInt()); - offsetX = 0; - offsetZ = 0; - } - setSeed(seed); - } - - public void setSeed(int seed) { - Main.seed = seed; - cache = new Cache(seed); - System.out.println(seed); - } - - @Override - public float color(Cell cell) { - switch (controller.getColorMode()) { - case STEEPNESS: - return hue(1 - cell.steepness, 64, 70); - case TEMPERATURE: - return hue(1 - cell.temperature, 64, 70); - case MOISTURE: - return hue(cell.moisture, 64, 70); - case TERRAIN_TYPE: - if (cell.tag == getCache().getTerrain().volcano) { - return 0F; - } - return 20 + (cell.tag.getHue() * 80); - case ELEVATION: - float value = (cell.value - 0.245F) / 0.65F; - return (1 - value) * 30; - case BIOME: - BiomeData biome = biomeProvider.getBiome(cell); - if (biome == null) { - return 0F; - } - return cell.biome * 70; - case CONTINENT: - return cell.continent * 70; - default: - return 50; - } - } - - @Override - public void draw() { - int nextSeed = controller.getNewSeed(); - if (nextSeed == 1) { - setup(); - } else if (nextSeed != 0) { - setSeed(nextSeed); - } - - offsetX += controller.velocityX() * controller.zoomLevel() * controller.zoomLevel(); - offsetZ += controller.velocityY() * controller.zoomLevel() * controller.zoomLevel(); - cache.update(offsetX, offsetZ, controller.zoomLevel(), controller.filters()); - - // color stuff - noStroke(); - background(0); - colorMode(HSB, 100); - - // lighting - ambientLight(0, 0, 75, width / 2, -height, height / 2); - pointLight(0, 0, 50, width / 2, -height * 100, height / 2); - - // render - pushMatrix(); - controller.apply(this); -// translate(-width / 2F, -height / 2F); - drawTerrain(controller.zoomLevel()); - drawCompass(); -// translate(0, 0, 255 * (width / (float) controller.resolution()) / controller.zoomLevel()); -// mesh.renderWind(controller.resolution(), controller.zoomLevel()); - popMatrix(); - - pushMatrix(); - translate(0, 0, -1); -// drawGradient(0, height - 150, 100F, width, 150); - popMatrix(); - - drawStats(); - drawBiomeKey(); - drawControls(); - } - - private void drawGradient(int x, int y, float d, float w, float h) { - noFill(); - for (int dy = 0; dy <= h; dy++) { - float dist = Math.min(1, dy / d); - stroke(0, 0, 0, dist * 100F); - line(x, y + dy, x + w, y + dy); - } - noStroke(); - } - - private void drawStats() { - int resolution = cache.getRegion().getBlockSize().size; - int blocks = NoiseUtil.round(resolution * controller.zoomLevel()); - - String[][] info = { - {"Java:", String.format("x%s", bits)}, - {"Fps: ", String.format("%.3f", frameRate)}, - {"Seed:", String.format("%s", seed)}, - {"Zoom: ", String.format("%.2f", controller.zoomLevel())}, - {"Area: ", String.format("%sx%s [%sx%s]", blocks, blocks, resolution, resolution)}, - {"Center: ", String.format("x=%.0f, y=%s, z=%.0f", offsetX, cache.getCenterHeight(), offsetZ)}, - {"Terrain: ", cache.getCenterTerrain().getName()}, - {"BiomeType:", cache.getCenterBiomeType().name()}, -// {"Biome: ", String.format("%s", biomeProvider.getBiome(cache.getCenterCell()).name)}, - {"Overlay: ", colorModeName()}, - }; - - int widest = 0; - for (String[] s : info) { - widest = Math.max(widest, (int) textWidth(s[0])); - } - - int top = 20; - int lineHeight = 15; - for (String[] s : info) { - leftAlignText(10, top, 0, s[0]); - top += lineHeight; - } - - top = 20; - for (String[] s : info) { - if (s.length == 2) { - leftAlignText(12 + widest, top, 0, s[1]); - top += lineHeight; - } - } - } - - private void drawBiomeKey() { - int top = 20; - int lineHeight = 15; - int widest = 0; - for (BiomeType type : BiomeType.values()) { - widest = Math.max(widest, (int) textWidth(type.name())); - } - - int left = width - widest - lineHeight - 15; - for (BiomeType type : BiomeType.values()) { - leftAlignText(left, top, 0, type.name()); - float[] hsb = Color.RGBtoHSB(type.getColor().getRed(), type.getColor().getGreen(), - type.getColor().getBlue(), null); - fill(0, 0, 100); - rect(width - lineHeight - 11, top - lineHeight + 1, lineHeight + 2, lineHeight + 2); - - fill(hsb[0] * 100, hsb[1] * 100, hsb[2] * 100); - rect(width - lineHeight - 10, top - lineHeight + 2, lineHeight, lineHeight); - top += lineHeight; - } - } - - private void drawControls() { - String[][][] columns = { - { - {"Mouse-Left + Move", " - Rotate terrain"}, - {"Mouse-Right + Move", " - Pan terrain"}, - {"Mouse-Scroll + Move", " - Zoom camera"}, - {"Mouse-Scroll + LCTRL + Move", " - Zoom terrain"}, - {"WASD", "- Move terrain"} - }, { - {"Key 1-8", "- Select overlay"}, - {"Key R", "- Toggle mesh renderer"}, - {"Key F", "- Toggle filters"}, - {"Key N", "- Generate new world"}, - {"Key C", "- Copy seed to clipboard"}, - {"Key V", "- Paste seed from clipboard"}, - }}; - - int lineHeight = 15; - int rows = 0; - for (String[][] column : columns) { - rows = Math.max(rows, column.length); - } - - int left = 10; - int widest = 0; - for (String[][] column : columns) { - int top = (height - 10) - ((rows - 1) * lineHeight); - - for (String[] row : column) { - int width = 0; - for (String cell : row) { - leftAlignText(left + width, top, 0, cell); - width += (int) textWidth(cell); - } - top += lineHeight; - widest = Math.max(widest, width); - } - - left += widest + 10; - } - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/biome/BiomeColor.java b/TerraForgedApp/src/main/java/com/terraforged/app/biome/BiomeColor.java deleted file mode 100644 index 7deaa3e..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/biome/BiomeColor.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app.biome; - -import me.dags.noise.util.NoiseUtil; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.InputStream; - -public class BiomeColor { - - private static final BufferedImage image = load(); - private static final int width = image.getWidth() - 1; - private static final int height = image.getHeight() - 1; - - public static int getRGB(float temp, float moist) { - float humidity = temp * moist; - temp = 1 - temp; - humidity = 1 - humidity; - int x = NoiseUtil.round(temp * width); - int y = NoiseUtil.round(humidity * height); - return image.getRGB(x, y); - } - - - private static BufferedImage load() { - try (InputStream inputStream = BiomeColor.class.getResourceAsStream("/grass.png")) { - return ImageIO.read(inputStream); - } catch (IOException e) { - e.printStackTrace(); - return new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); - } - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/biome/BiomeProvider.java b/TerraForgedApp/src/main/java/com/terraforged/app/biome/BiomeProvider.java deleted file mode 100644 index d5b82ba..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/biome/BiomeProvider.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app.biome; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.util.grid.FixedGrid; -import com.terraforged.core.world.biome.BiomeData; -import com.terraforged.core.world.biome.BiomeType; -import com.terraforged.core.world.terrain.Terrain; -import processing.data.JSONArray; -import processing.data.JSONObject; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class BiomeProvider { - - private final List> biomes; - - public BiomeProvider() { - biomes = getBiomes(5); - } - - public BiomeData getBiome(Cell cell) { - FixedGrid grid = biomes.get(cell.biomeType.ordinal()); - if (grid == null) { - return null; - } - return grid.get(cell.moisture, cell.temperature, cell.biome); - } - - private static List> getBiomes(int gridSize) { - List> data = new ArrayList<>(); - for (BiomeType type : BiomeType.values()) { - data.add(type.ordinal(), null); - } - - Map biomes = loadBiomes(); - Map> types = loadBiomeTypes(); - for (Map.Entry> e : types.entrySet()) { - List list = new LinkedList<>(); - for (String id : e.getValue()) { - BiomeData biome = biomes.get(id); - if (biome != null) { - list.add(biome); - } - } - FixedGrid grid = FixedGrid.generate(gridSize, list, b -> b.rainfall, b -> b.temperature); - data.set(e.getKey().ordinal(), grid); - } - - return data; - } - - private static Map loadBiomes() { - try (InputStream inputStream = BiomeProvider.class.getResourceAsStream("/biome_data.json")) { - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - StringBuilder sb = new StringBuilder(); - reader.lines().forEach(sb::append); - JSONArray array = JSONArray.parse(sb.toString()); - Map biomes = new HashMap<>(); - for (int i = 0; i < array.size(); i++) { - JSONObject object = array.getJSONObject(i); - String name = object.getString("id"); - float moisture = object.getFloat("moisture"); - float temperature = object.getFloat("temperature"); - int color = BiomeColor.getRGB(temperature, moisture); - BiomeData biome = new BiomeData(name, null, color, moisture, temperature); - biomes.put(name, biome); - } - return biomes; - } catch (IOException e) { - e.printStackTrace(); - return Collections.emptyMap(); - } - } - - private static Map> loadBiomeTypes() { - try (InputStream inputStream = BiomeProvider.class.getResourceAsStream("/biome_groups.json")) { - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - StringBuilder sb = new StringBuilder(); - reader.lines().forEach(sb::append); - JSONObject object = JSONObject.parse(sb.toString()); - Iterator iterator = object.keyIterator(); - Map> biomes = new HashMap<>(); - while (iterator.hasNext()) { - String key = "" + iterator.next(); - if (key.contains("rivers")) { - continue; - } - if (key.contains("oceans")) { - continue; - } - BiomeType type = BiomeType.valueOf(key); - List group = new LinkedList<>(); - JSONArray array = object.getJSONArray(key); - for (int i = 0; i < array.size(); i++) { - group.add(array.getString(i)); - } - biomes.put(type, group); - } - return biomes; - } catch (IOException e) { - e.printStackTrace(); - return Collections.emptyMap(); - } - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/mesh/Mesh.java b/TerraForgedApp/src/main/java/com/terraforged/app/mesh/Mesh.java deleted file mode 100644 index 2696c06..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/mesh/Mesh.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app.mesh; - -public class Mesh { - - private final Mesh inner; - private final float x0; - private final float y0; - private final float x1; - private final float y1; - private final float quality; - - public Mesh(Mesh inner, float x0, float y0, float x1, float y1, float quality) { - this.inner = inner; - this.x0 = x0; - this.y0 = y0; - this.x1 = x1; - this.y1 = y1; - this.quality = quality; - } - - public Mesh expand(float scale) { - return expand(scale, scale); - } - - public Mesh expand(float scale, float quality) { - float width0 = getWidth(); - float height0 = getHeight(); - float width1 = width0 * scale; - float height1 = height0 * scale; - float deltaX = (width1 - width0) / 2F; - float deltaY = (height1 - height0) / 2F; - float newQuality = this.quality * quality; - return new Mesh(this, x0 - deltaX, y0 - deltaY, x1 + deltaX, y1 + deltaY, newQuality); - } - - public float getWidth() { - return x1 - x0; - } - - public float getHeight() { - return y1 - y0; - } - - public void start(float width, float height) { - if (inner != null) { - inner.start(width, height); - } - } - - public void render() { - if (inner == null) { - renderNormal(); - } else { - renderCutout(); - inner.render(); - } - } - - public void beginStrip() { - if (inner != null) { - inner.beginStrip(); - } - } - - public void endStrip() { - if (inner != null) { - inner.endStrip(); - } - } - - public void visit(float x, float y) { - if (inner != null) { - inner.visit(x, y); - } - } - - private void renderNormal() { - beginStrip(); - iterate(x0, y0, x1, y1); - endStrip(); - } - - private void renderCutout() { - beginStrip(); - iterate(x0, y0, inner.x1, inner.y0); - endStrip(); - - beginStrip(); - iterate(inner.x1, y0, x1, inner.y1); - endStrip(); - - beginStrip(); - iterate(inner.x0, inner.y1, x1, y1); - endStrip(); - - beginStrip(); - iterate(x0, inner.y0, inner.x0, y1); - endStrip(); - } - - private void iterate(float minX, float minY, float maxX, float maxY) { - float x = minX - quality; - float y = minY - quality; - while (y < maxY) { - y = Math.min(y + quality, maxY); - beginStrip(); - while (x < maxX) { - x = Math.min(x + quality, maxX); - visit(x, y); - visit(x, y + quality); - } - x = minX - quality; - endStrip(); - } - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/mesh/NoiseMesh.java b/TerraForgedApp/src/main/java/com/terraforged/app/mesh/NoiseMesh.java deleted file mode 100644 index 021e846..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/mesh/NoiseMesh.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app.mesh; - -import com.terraforged.app.Applet; -import com.terraforged.app.renderer.Renderer; -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; -import processing.core.PApplet; - -public class NoiseMesh extends Mesh { - - private final Applet applet; - private final Renderer renderer; - private final Cell cell = new Cell<>(); - - public NoiseMesh(Applet applet, Renderer renderer, float x0, float y0, float x1, float y1) { - super(null, x0, y0, x1, y1, 1F); - this.applet = applet; - this.renderer = renderer; - } - - @Override - public void start(float width, float height) { - applet.noStroke(); - } - - @Override - public void beginStrip() { - applet.beginShape(PApplet.TRIANGLE_STRIP); - } - - @Override - public void endStrip() { - applet.endShape(); - } - - @Override - public void visit(float x, float y) { - float height = cell.value * 255; - float surface = renderer.getSurface(cell, height, 63, 10F); - applet.vertex(x * 10F, y * 10F, (int) surface); - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/mesh/TestRenderer.java b/TerraForgedApp/src/main/java/com/terraforged/app/mesh/TestRenderer.java deleted file mode 100644 index 4c82c08..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/mesh/TestRenderer.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app.mesh; - -import com.terraforged.app.Applet; -import com.terraforged.app.renderer.Renderer; - -public class TestRenderer extends Renderer { - - private static boolean printed = false; - - public TestRenderer(Applet visualizer) { - super(visualizer); - } - - @Override - public void render(float zoom) { - Mesh mesh = new NoiseMesh(applet, this, -64, -64, 64, 64); - for (int i = 0; i < 1; i++) { -// mesh = mesh.expand(4); - } - - float width = mesh.getWidth(); - float height = mesh.getHeight(); - if (!printed) { - printed = true; - System.out.println(width + "x" + height); - } - - applet.pushMatrix(); - mesh.start(mesh.getWidth(), mesh.getHeight()); - mesh.render(); - applet.popMatrix(); - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/renderer/MeshRenderer.java b/TerraForgedApp/src/main/java/com/terraforged/app/renderer/MeshRenderer.java deleted file mode 100644 index f76ce76..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/renderer/MeshRenderer.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app.renderer; - -import com.terraforged.app.Applet; -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; -import processing.core.PApplet; - -public class MeshRenderer extends Renderer { - - public MeshRenderer(Applet visualizer) { - super(visualizer); - } - - @Override - public void render(float zoom) { - float seaLevel = new Levels(applet.getCache().getSettings().generator).water; - int worldHeight = applet.getCache().getSettings().generator.world.worldHeight; - int waterLevel = (int) (seaLevel * worldHeight); - int seabedLevel = (int) ((seaLevel - 0.04) * worldHeight); - int resolution = applet.getCache().getRegion().getBlockSize().size; - - float w = applet.width / (float) (resolution - 1); - float h = applet.width / (float) (resolution - 1); - - applet.noStroke(); - applet.pushMatrix(); - applet.translate(-applet.width / 2F, -applet.width / 2F); - - for (int dy = 0; dy < resolution - 1; dy++) { - applet.beginShape(PApplet.TRIANGLE_STRIP); - for (int dx = 0; dx < resolution; dx++) { - draw(dx, dy, w, h, zoom, worldHeight, waterLevel, seabedLevel); - draw(dx, dy + 1, w, h, zoom, worldHeight, waterLevel, resolution / 2); - } - applet.endShape(); - } - - applet.popMatrix(); - } - - private void draw(int dx, int dz, float w, float h, float zoom, int worldHeight, int waterLevel, int center) { - Cell cell = applet.getCache().getRegion().getCell(dx, dz); - float height = (cell.value * worldHeight); - float x = dx * w; - float z = dz * h; - float y = (int) getSurface(cell, height, waterLevel, 1); - applet.vertex(x, z, y / (zoom * 0.2F)); - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/renderer/Renderer.java b/TerraForgedApp/src/main/java/com/terraforged/app/renderer/Renderer.java deleted file mode 100644 index c2472f0..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/renderer/Renderer.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app.renderer; - -import com.terraforged.app.Applet; -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; - -import java.awt.*; - -public abstract class Renderer { - - protected final Applet applet; - - protected Renderer(Applet visualizer) { - this.applet = visualizer; - } - - public float getSurface(Cell cell, float height, int waterLevel, float el) { - if (cell.tag == applet.getCache().getTerrain().volcanoPipe) { - applet.fill(2, 80, 64); - return height * 0.95F * el; - } - if (height < waterLevel) { - float temp = cell.temperature; - float tempDelta = temp > 0.5 ? temp - 0.5F : -(0.5F - temp); - float tempAlpha = (tempDelta / 0.5F); - float hueMod = 4 * tempAlpha; - - float depth = (waterLevel - height) / (float) (90); - float darkness = (1 - depth); - float darknessMod = 0.5F + (darkness * 0.5F); - - applet.fill(60 - hueMod, 65, 90 * darknessMod); - return height * el; - } else if (applet.controller.getColorMode() == Applet.ELEVATION) { - float hei = Math.min(1, Math.max(0, height - waterLevel) / (255F - waterLevel)); - float temp = cell.temperature; - float moist = Math.min(temp, cell.moisture); - - float hue = 35 - (temp * (1 - moist)) * 25; - float sat = 75 * (1 - hei); - float bri = 50 + 40 * hei; - applet.fill(hue, sat, bri); - return height * el; - } else if (applet.controller.getColorMode() == Applet.BIOME_TYPE) { - Color c = cell.biomeType.getColor(); - if (cell.riverMask < 0.025) { - c = Color.white; - } - float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); - float bri = 90 + cell.biomeTypeMask * 10; - applet.fill(hsb[0] * 100, hsb[1] * 100, hsb[2] * bri); - return height * el; - } else if (applet.controller.getColorMode() == Applet.BIOME) { - float hue = applet.color(cell); - float sat = 70; - float bright = 50 + 50 * cell.riverMask; - applet.fill(hue, sat, bright); - return height * el; - } else if(applet.controller.getColorMode() == Applet.TERRAIN_TYPE) { - float hue = applet.color(cell); - if (cell.tag == applet.getCache().getTerrain().coast) { - hue = 15; - } - float modifier = cell.mask(0.4F, 0.5F, 0F, 1F); - float modAlpha = 0.1F; - float mod = (1 - modAlpha) + (modifier * modAlpha); - float sat = 70; - float bri = 70; - applet.fill(hue, 65, 70); - return height * el; - } else if(applet.controller.getColorMode() == Applet.EROSION) { - float change = cell.sediment + cell.erosion; - float value = Math.abs(cell.sediment * 250); - value = Math.max(0, Math.min(1, value)); - float hue = value * 70; - float sat = 70; - float bri = 70; - applet.fill(hue, sat, bri); - return height * el; - } else { - float hue = applet.color(cell); - float sat = 70; - float bri = 70; - applet.fill(hue, sat, bri); - return height * el; - } - } - - public abstract void render(float zoom); - - private void renderGradLine(int steps, float x1, float y1, float x2, float y2, float hue1, float hue2, float sat, float bright) { - float dx = x2 - x1; - float dy = y2 - y1; - float fx = dx / steps; - float fy = dy / steps; - float dhue = hue2 - hue1; - float fhue = dhue / steps; - for (int i = 0; i < steps; i++) { - float px1 = x1 + (i * fx); - float py1 = y1 + (i * fy); - float px2 = x2 + ((i + 1) * fx); - float py2 = y2 + ((i + 1) * fy); - float hue = (i + 1) * fhue; - applet.stroke(hue1 + hue, sat, bright); - applet.line(px1, py1, px2, py2); - } - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/renderer/VoxelRenderer.java b/TerraForgedApp/src/main/java/com/terraforged/app/renderer/VoxelRenderer.java deleted file mode 100644 index cb42b96..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/renderer/VoxelRenderer.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.app.renderer; - -import com.terraforged.app.Applet; -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; -import processing.core.PApplet; - -public class VoxelRenderer extends Renderer { - - public VoxelRenderer(Applet visualizer) { - super(visualizer); - } - - @Override - public void render(float zoom) { - Levels levels = new Levels(applet.getCache().getSettings().generator); - int worldHeight = applet.getCache().getSettings().generator.world.worldHeight; - int waterLevel = levels.waterY; - int resolution = applet.getCache().getRegion().getBlockSize().size; - int center = resolution / 2; - - float w = applet.width / (float) resolution; - float h = applet.width / (float) resolution; - float el = w / zoom; - - applet.pushMatrix(); - applet.translate(-applet.width / 2F, -applet.width / 2F); - - int difX = Math.max(0, applet.getCache().getRegion().getBlockSize().size - resolution); - int difY = Math.max(0, applet.getCache().getRegion().getBlockSize().size - resolution); - int offsetX = difX / 2; - int offsetZ = difY / 2; - - for (int dy = 0; dy < resolution; dy++) { - for (int dx = 0; dx < resolution; dx++) { - Cell cell = applet.getCache().getRegion().getCell(dx + offsetX, dy + offsetZ); - - float cellHeight = cell.value * worldHeight; - int height = Math.min(worldHeight, Math.max(0, (int) cellHeight)); - - if (height < 0) { - continue; - } - - float x0 = dx * w; - float x1 = (dx + 1) * w; - float z0 = dy * h; - float z1 = (dy + 1) * h; - float y = getSurface(cell, height, waterLevel, el); - - if ((dx == center && (dy == center || dy - 1 == center || dy + 1 == center)) - || (dy == center && (dx - 1 == center || dx + 1 == center))) { - applet.fill(100F, 100F, 100F); - } - - drawColumn(x0, z0, 0, x1, z1, y); - } - } - - drawRulers(16, worldHeight, resolution, h, el); - - applet.popMatrix(); - } - - private void drawRulers(int step, int max, int resolution, float unit, float height) { - float width = (resolution + 1) * unit; - int doubleStep = step * 2; - - for (int dz = 0; dz <= 1; dz++) { - for (int dx = 0; dx <= 1; dx++) { - float x0 = dx * width; - float x1 = x0 - unit; - float z0 = dz * width; - float z1 = z0 - unit; - for (int dy = 0; dy < max; dy += step) { - float y0 = dy * height; - float y1 = y0 + (step * height); - float h = 100, s = 100, b = 100; - if ((dy % doubleStep) != step) { - s = 0; - } - applet.fill(h, s, b); - drawColumn(x0, z0, y0, x1, z1, y1); - } - } - } - } - - private void drawColumn(float x0, float y0, float z0, float x1, float y1, float z1) { - applet.beginShape(PApplet.QUADS); - // +Z "front" face - applet.vertex(x0, y0, z1); - applet.vertex(x1, y0, z1); - applet.vertex(x1, y1, z1); - applet.vertex(x0, y1, z1); - - // -Z "back" face - applet.vertex(x1, y0, z0); - applet.vertex(x0, y0, z0); - applet.vertex(x0, y1, z0); - applet.vertex(x1, y1, z0); - - // +Y "bottom" face - applet.vertex(x0, y1, z1); - applet.vertex(x1, y1, z1); - applet.vertex(x1, y1, z0); - applet.vertex(x0, y1, z0); - - // -Y "top" face - applet.vertex(x0, y0, z0); - applet.vertex(x1, y0, z0); - applet.vertex(x1, y0, z1); - applet.vertex(x0, y0, z1); - - // +X "right" face - applet.vertex(x1, y0, z1); - applet.vertex(x1, y0, z0); - applet.vertex(x1, y1, z0); - applet.vertex(x1, y1, z1); - - // -X "left" face - applet.vertex(x0, y0, z0); - applet.vertex(x0, y0, z1); - applet.vertex(x0, y1, z1); - applet.vertex(x0, y1, z0); - - applet.endShape(); - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/util/JsonReader.java b/TerraForgedApp/src/main/java/com/terraforged/app/util/JsonReader.java deleted file mode 100644 index 7592af2..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/util/JsonReader.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.terraforged.app.util; - -import com.google.gson.JsonElement; -import com.terraforged.core.util.serialization.serializer.Reader; - -import java.util.Collection; -import java.util.Map; -import java.util.stream.Collectors; - -public class JsonReader implements Reader { - - private final JsonElement element; - - public JsonReader(JsonElement element) { - this.element = element; - } - - @Override - public int getSize() { - if (element.isJsonObject()) { - return element.getAsJsonObject().size(); - } - if (element.isJsonArray()) { - return element.getAsJsonArray().size(); - } - return 0; - } - - @Override - public Reader getChild(String key) { - return new JsonReader(element.getAsJsonObject().get(key)); - } - - @Override - public Reader getChild(int index) { - return new JsonReader(element.getAsJsonArray().get(index)); - } - - @Override - public Collection getKeys() { - return element.getAsJsonObject().entrySet().stream().map(Map.Entry::getKey).collect(Collectors.toList()); - } - - @Override - public String getString() { - return element.getAsString(); - } - - @Override - public boolean getBool() { - return element.getAsBoolean(); - } - - @Override - public float getFloat() { - return element.getAsFloat(); - } - - @Override - public int getInt() { - return element.getAsInt(); - } -} diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/util/Loader.java b/TerraForgedApp/src/main/java/com/terraforged/app/util/Loader.java deleted file mode 100644 index 510a23f..0000000 --- a/TerraForgedApp/src/main/java/com/terraforged/app/util/Loader.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.terraforged.app.util; - -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.terraforged.core.settings.Settings; -import com.terraforged.core.util.serialization.serializer.Deserializer; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.Reader; - -public class Loader { - - public static Settings load() { - Settings settings = new Settings(); - load(settings); - return settings; - } - - private static void load(Settings settings) { - try (Reader reader = new BufferedReader(new FileReader("terraforged-generator.json"))) { - JsonElement json = new JsonParser().parse(reader); - new Deserializer().deserialize(new JsonReader(json), settings); - } catch (Throwable e) { - e.printStackTrace(); - } - } -} diff --git a/TerraForgedApp/src/main/resources/biome_data.json b/TerraForgedApp/src/main/resources/biome_data.json deleted file mode 100644 index 1de2bf8..0000000 --- a/TerraForgedApp/src/main/resources/biome_data.json +++ /dev/null @@ -1,764 +0,0 @@ -[ - { - "id": "biomesoplenty:alps", - "moisture": 0.2, - "temperature": 0.1, - "color": -2302756 - }, - { - "id": "biomesoplenty:alps_foothills", - "moisture": 0.2, - "temperature": 0.1, - "color": -10461088 - }, - { - "id": "biomesoplenty:bayou", - "moisture": 0.59999996, - "temperature": 0.58000004, - "color": -13592211 - }, - { - "id": "biomesoplenty:bog", - "moisture": 0.59999996, - "temperature": 0.42, - "color": -13592211 - }, - { - "id": "biomesoplenty:boreal_forest", - "moisture": 0.4, - "temperature": 0.32, - "color": -13592211 - }, - { - "id": "biomesoplenty:brushland", - "moisture": 0.06666667, - "temperature": 0.8, - "color": -13592211 - }, - { - "id": "biomesoplenty:chaparral", - "moisture": 0.29999998, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "biomesoplenty:cherry_blossom_grove", - "moisture": 0.59999996, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "biomesoplenty:cold_desert", - "moisture": 0.0, - "temperature": 0.3, - "color": -6034953 - }, - { - "id": "biomesoplenty:coniferous_forest", - "moisture": 0.33333334, - "temperature": 0.38, - "color": -13592211 - }, - { - "id": "biomesoplenty:dead_forest", - "moisture": 0.2, - "temperature": 0.32, - "color": -13592211 - }, - { - "id": "biomesoplenty:fir_clearing", - "moisture": 0.33333334, - "temperature": 0.38, - "color": -13592211 - }, - { - "id": "biomesoplenty:floodplain", - "moisture": 0.8, - "temperature": 0.56, - "color": -13592211 - }, - { - "id": "biomesoplenty:flower_meadow", - "moisture": 0.46666667, - "temperature": 0.35999998, - "color": -13592211 - }, - { - "id": "biomesoplenty:grassland", - "moisture": 0.46666667, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "biomesoplenty:gravel_beach", - "moisture": 0.33333334, - "temperature": 0.44, - "color": -6034953 - }, - { - "id": "biomesoplenty:grove", - "moisture": 0.18333334, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "biomesoplenty:highland", - "moisture": 0.4, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "biomesoplenty:highland_moor", - "moisture": 0.4, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "biomesoplenty:lavender_field", - "moisture": 0.46666667, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "biomesoplenty:lush_grassland", - "moisture": 0.59999996, - "temperature": 0.58000004, - "color": -13592211 - }, - { - "id": "biomesoplenty:lush_swamp", - "moisture": 0.6666667, - "temperature": 0.48000002, - "color": -13592211 - }, - { - "id": "biomesoplenty:mangrove", - "moisture": 0.46666667, - "temperature": 0.524, - "color": -13592211 - }, - { - "id": "biomesoplenty:maple_woods", - "moisture": 0.53333336, - "temperature": 0.3, - "color": -13592211 - }, - { - "id": "biomesoplenty:marsh", - "moisture": 0.46666667, - "temperature": 0.45999998, - "color": -13592211 - }, - { - "id": "biomesoplenty:meadow", - "moisture": 0.46666667, - "temperature": 0.35999998, - "color": -13592211 - }, - { - "id": "biomesoplenty:mire", - "moisture": 0.59999996, - "temperature": 0.42, - "color": -13592211 - }, - { - "id": "biomesoplenty:mystic_grove", - "moisture": 0.53333336, - "temperature": 0.48000002, - "color": -13592211 - }, - { - "id": "biomesoplenty:oasis", - "moisture": 0.33333334, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "biomesoplenty:ominous_woods", - "moisture": 0.4, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "biomesoplenty:orchard", - "moisture": 0.26666668, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "biomesoplenty:outback", - "moisture": 0.033333335, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "biomesoplenty:overgrown_cliffs", - "moisture": 0.53333336, - "temperature": 0.58000004, - "color": -13592211 - }, - { - "id": "biomesoplenty:pasture", - "moisture": 0.2, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "biomesoplenty:prairie", - "moisture": 0.2, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "biomesoplenty:pumpkin_patch", - "moisture": 0.53333336, - "temperature": 0.35999998, - "color": -13592211 - }, - { - "id": "biomesoplenty:rainforest", - "moisture": 1.0, - "temperature": 0.54, - "color": -13592211 - }, - { - "id": "biomesoplenty:redwood_forest", - "moisture": 0.4, - "temperature": 0.52, - "color": -12427646 - }, - { - "id": "biomesoplenty:redwood_forest_edge", - "moisture": 0.4, - "temperature": 0.52, - "color": -12427646 - }, - { - "id": "biomesoplenty:scrubland", - "moisture": 0.06666667, - "temperature": 0.64, - "color": -13592211 - }, - { - "id": "biomesoplenty:seasonal_forest", - "moisture": 0.53333336, - "temperature": 0.35999998, - "color": -13592211 - }, - { - "id": "biomesoplenty:shield", - "moisture": 0.53333336, - "temperature": 0.35999998, - "color": -13592211 - }, - { - "id": "biomesoplenty:shrubland", - "moisture": 0.033333335, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "biomesoplenty:silkglade", - "moisture": 0.13333334, - "temperature": 0.5, - "color": -13592211 - }, - { - "id": "biomesoplenty:snowy_coniferous_forest", - "moisture": 0.33333334, - "temperature": 0.1, - "color": -13592211 - }, - { - "id": "biomesoplenty:snowy_fir_clearing", - "moisture": 0.33333334, - "temperature": 0.1, - "color": -13592211 - }, - { - "id": "biomesoplenty:snowy_forest", - "moisture": 0.33333334, - "temperature": 0.1, - "color": -13592211 - }, - { - "id": "biomesoplenty:steppe", - "moisture": 0.033333335, - "temperature": 0.51, - "color": -13592211 - }, - { - "id": "biomesoplenty:temperate_rainforest", - "moisture": 0.8, - "temperature": 0.45999998, - "color": -13592211 - }, - { - "id": "biomesoplenty:temperate_rainforest_hills", - "moisture": 0.8, - "temperature": 0.45999998, - "color": -13592211 - }, - { - "id": "biomesoplenty:tropical_rainforest", - "moisture": 0.6666667, - "temperature": 0.6, - "color": -13592211 - }, - { - "id": "biomesoplenty:tundra", - "moisture": 0.33333334, - "temperature": 0.28, - "color": -13592211 - }, - { - "id": "biomesoplenty:wasteland", - "moisture": 0.0, - "temperature": 1.0, - "color": -12427646 - }, - { - "id": "biomesoplenty:wetland", - "moisture": 0.46666667, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "biomesoplenty:white_beach", - "moisture": 0.6666667, - "temperature": 0.58000004, - "color": -6034953 - }, - { - "id": "biomesoplenty:woodland", - "moisture": 0.33333334, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "biomesoplenty:xeric_shrubland", - "moisture": 0.06666667, - "temperature": 0.9, - "color": -6034953 - }, - { - "id": "minecraft:badlands", - "moisture": 0.0, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "minecraft:badlands_plateau", - "moisture": 0.0, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "minecraft:bamboo_jungle", - "moisture": 0.59999996, - "temperature": 0.58000004, - "color": -13592211 - }, - { - "id": "minecraft:bamboo_jungle_hills", - "moisture": 0.59999996, - "temperature": 0.58000004, - "color": -13592211 - }, - { - "id": "minecraft:beach", - "moisture": 0.26666668, - "temperature": 0.52, - "color": -6034953 - }, - { - "id": "minecraft:birch_forest", - "moisture": 0.4, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "minecraft:birch_forest_hills", - "moisture": 0.4, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "minecraft:cold_ocean", - "moisture": 0.33333334, - "temperature": 0.4, - "color": -13592211 - }, - { - "id": "minecraft:dark_forest", - "moisture": 0.53333336, - "temperature": 0.48000002, - "color": -13592211 - }, - { - "id": "minecraft:dark_forest_hills", - "moisture": 0.53333336, - "temperature": 0.48000002, - "color": -13592211 - }, - { - "id": "minecraft:deep_cold_ocean", - "moisture": 0.33333334, - "temperature": 0.4, - "color": -13592211 - }, - { - "id": "minecraft:deep_frozen_ocean", - "moisture": 0.33333334, - "temperature": 0.4, - "color": -13592211 - }, - { - "id": "minecraft:deep_lukewarm_ocean", - "moisture": 0.33333334, - "temperature": 0.4, - "color": -13592211 - }, - { - "id": "minecraft:deep_ocean", - "moisture": 0.33333334, - "temperature": 0.4, - "color": -13592211 - }, - { - "id": "minecraft:deep_warm_ocean", - "moisture": 0.33333334, - "temperature": 0.4, - "color": -6034953 - }, - { - "id": "minecraft:desert", - "moisture": 0.0, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "minecraft:desert_hills", - "moisture": 0.0, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "minecraft:desert_lakes", - "moisture": 0.0, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "minecraft:eroded_badlands", - "moisture": 0.0, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "minecraft:flower_forest", - "moisture": 0.53333336, - "temperature": 0.48000002, - "color": -13592211 - }, - { - "id": "minecraft:forest", - "moisture": 0.53333336, - "temperature": 0.48000002, - "color": -13592211 - }, - { - "id": "minecraft:frozen_ocean", - "moisture": 0.33333334, - "temperature": 0.2, - "color": -13592211 - }, - { - "id": "minecraft:frozen_river", - "moisture": 0.33333334, - "temperature": 0.2, - "color": -13592211 - }, - { - "id": "minecraft:giant_spruce_taiga", - "moisture": 0.53333336, - "temperature": 0.3, - "color": -13592211 - }, - { - "id": "minecraft:giant_spruce_taiga_hills", - "moisture": 0.53333336, - "temperature": 0.3, - "color": -13592211 - }, - { - "id": "minecraft:giant_tree_taiga", - "moisture": 0.53333336, - "temperature": 0.32, - "color": -13592211 - }, - { - "id": "minecraft:giant_tree_taiga_hills", - "moisture": 0.53333336, - "temperature": 0.32, - "color": -13592211 - }, - { - "id": "minecraft:gravelly_mountains", - "moisture": 0.2, - "temperature": 0.28, - "color": -13592211 - }, - { - "id": "minecraft:ice_spikes", - "moisture": 0.33333334, - "temperature": 0.2, - "color": -2302756 - }, - { - "id": "minecraft:jungle", - "moisture": 0.59999996, - "temperature": 0.58000004, - "color": -13592211 - }, - { - "id": "minecraft:jungle_hills", - "moisture": 0.59999996, - "temperature": 0.58000004, - "color": -13592211 - }, - { - "id": "minecraft:lukewarm_ocean", - "moisture": 0.33333334, - "temperature": 0.4, - "color": -13592211 - }, - { - "id": "minecraft:modified_badlands_plateau", - "moisture": 0.0, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "minecraft:modified_gravelly_mountains", - "moisture": 0.2, - "temperature": 0.28, - "color": -13592211 - }, - { - "id": "minecraft:modified_jungle", - "moisture": 0.59999996, - "temperature": 0.58000004, - "color": -13592211 - }, - { - "id": "minecraft:modified_wooded_badlands_plateau", - "moisture": 0.0, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "minecraft:mountains", - "moisture": 0.2, - "temperature": 0.28, - "color": -13592211 - }, - { - "id": "minecraft:mushroom_field_shore", - "moisture": 0.6666667, - "temperature": 0.56, - "color": -13592211 - }, - { - "id": "minecraft:mushroom_fields", - "moisture": 0.6666667, - "temperature": 0.56, - "color": -13592211 - }, - { - "id": "minecraft:ocean", - "moisture": 0.33333334, - "temperature": 0.4, - "color": -13592211 - }, - { - "id": "minecraft:plains", - "moisture": 0.26666668, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "minecraft:river", - "moisture": 0.33333334, - "temperature": 0.4, - "color": -13592211 - }, - { - "id": "minecraft:savanna", - "moisture": 0.0, - "temperature": 0.68, - "color": -13592211 - }, - { - "id": "minecraft:savanna_plateau", - "moisture": 0.0, - "temperature": 0.6, - "color": -13592211 - }, - { - "id": "minecraft:shattered_savanna", - "moisture": 0.0, - "temperature": 0.64, - "color": -13592211 - }, - { - "id": "minecraft:shattered_savanna_plateau", - "moisture": 0.0, - "temperature": 0.6, - "color": -13592211 - }, - { - "id": "minecraft:snowy_beach", - "moisture": 0.2, - "temperature": 0.22, - "color": -6034953 - }, - { - "id": "minecraft:snowy_mountains", - "moisture": 0.33333334, - "temperature": 0.2, - "color": -13592211 - }, - { - "id": "minecraft:snowy_taiga", - "moisture": 0.26666668, - "temperature": 0.0, - "color": -13592211 - }, - { - "id": "minecraft:snowy_taiga_hills", - "moisture": 0.26666668, - "temperature": 0.0, - "color": -13592211 - }, - { - "id": "minecraft:snowy_taiga_mountains", - "moisture": 0.26666668, - "temperature": 0.0, - "color": -13592211 - }, - { - "id": "minecraft:snowy_tundra", - "moisture": 0.33333334, - "temperature": 0.2, - "color": -13592211 - }, - { - "id": "minecraft:sunflower_plains", - "moisture": 0.26666668, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "minecraft:swamp", - "moisture": 0.59999996, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "minecraft:swamp_hills", - "moisture": 0.59999996, - "temperature": 0.52, - "color": -13592211 - }, - { - "id": "minecraft:taiga", - "moisture": 0.53333336, - "temperature": 0.3, - "color": -13592211 - }, - { - "id": "minecraft:taiga_hills", - "moisture": 0.53333336, - "temperature": 0.3, - "color": -13592211 - }, - { - "id": "minecraft:taiga_mountains", - "moisture": 0.53333336, - "temperature": 0.3, - "color": -13592211 - }, - { - "id": "minecraft:tall_birch_forest", - "moisture": 0.4, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "minecraft:tall_birch_hills", - "moisture": 0.4, - "temperature": 0.44, - "color": -13592211 - }, - { - "id": "minecraft:warm_ocean", - "moisture": 0.33333334, - "temperature": 0.4, - "color": -6034953 - }, - { - "id": "minecraft:wooded_badlands_plateau", - "moisture": 0.0, - "temperature": 1.0, - "color": -6034953 - }, - { - "id": "minecraft:wooded_hills", - "moisture": 0.53333336, - "temperature": 0.48000002, - "color": -13592211 - }, - { - "id": "minecraft:wooded_mountains", - "moisture": 0.2, - "temperature": 0.28, - "color": -13592211 - }, - { - "id": "terraforged:cold_steppe", - "moisture": 0.06666667, - "temperature": 0.28, - "color": -13592211 - }, - { - "id": "terraforged:savanna_scrub", - "moisture": 0.0, - "temperature": 0.68, - "color": -13592211 - }, - { - "id": "terraforged:shattered_savanna_scrub", - "moisture": 0.0, - "temperature": 0.64, - "color": -13592211 - }, - { - "id": "terraforged:snowy_taiga_scrub", - "moisture": 0.26666668, - "temperature": 0.0, - "color": -13592211 - }, - { - "id": "terraforged:steppe", - "moisture": 0.06666667, - "temperature": 0.48000002, - "color": -13592211 - }, - { - "id": "terraforged:taiga_scrub", - "moisture": 0.53333336, - "temperature": 0.3, - "color": -13592211 - } -] \ No newline at end of file diff --git a/TerraForgedApp/src/main/resources/biome_groups.json b/TerraForgedApp/src/main/resources/biome_groups.json deleted file mode 100644 index 5eed0dd..0000000 --- a/TerraForgedApp/src/main/resources/biome_groups.json +++ /dev/null @@ -1,168 +0,0 @@ -{ - "TROPICAL_RAINFOREST": [ - "biomesoplenty:overgrown_cliffs", - "biomesoplenty:tropical_rainforest", - "minecraft:bamboo_jungle", - "minecraft:bamboo_jungle_hills", - "minecraft:jungle", - "minecraft:jungle_hills", - "minecraft:modified_jungle" - ], - "SAVANNA": [ - "biomesoplenty:brushland", - "biomesoplenty:scrubland", - "biomesoplenty:xeric_shrubland", - "minecraft:savanna", - "minecraft:savanna_plateau", - "minecraft:shattered_savanna", - "minecraft:shattered_savanna_plateau", - "terraforged:savanna_scrub", - "terraforged:shattered_savanna_scrub" - ], - "DESERT": [ - "biomesoplenty:oasis", - "biomesoplenty:outback", - "biomesoplenty:wasteland", - "minecraft:badlands", - "minecraft:badlands_plateau", - "minecraft:desert", - "minecraft:desert_hills", - "minecraft:desert_lakes", - "minecraft:eroded_badlands", - "minecraft:modified_badlands_plateau", - "minecraft:modified_wooded_badlands_plateau", - "minecraft:wooded_badlands_plateau" - ], - "TEMPERATE_RAINFOREST": [ - "biomesoplenty:rainforest", - "biomesoplenty:temperate_rainforest", - "biomesoplenty:temperate_rainforest_hills", - "minecraft:plains" - ], - "TEMPERATE_FOREST": [ - "biomesoplenty:cherry_blossom_grove", - "biomesoplenty:grove", - "biomesoplenty:mystic_grove", - "biomesoplenty:orchard", - "biomesoplenty:pumpkin_patch", - "biomesoplenty:redwood_forest", - "biomesoplenty:redwood_forest_edge", - "biomesoplenty:seasonal_forest", - "biomesoplenty:silkglade", - "biomesoplenty:temperate_rainforest", - "biomesoplenty:temperate_rainforest_hills", - "biomesoplenty:woodland", - "minecraft:birch_forest", - "minecraft:birch_forest_hills", - "minecraft:dark_forest", - "minecraft:flower_forest", - "minecraft:forest", - "minecraft:plains", - "minecraft:tall_birch_forest", - "minecraft:wooded_hills" - ], - "GRASSLAND": [ - "biomesoplenty:bayou", - "biomesoplenty:bog", - "biomesoplenty:chaparral", - "biomesoplenty:floodplain", - "biomesoplenty:grassland", - "biomesoplenty:highland_moor", - "biomesoplenty:lavender_field", - "biomesoplenty:lush_grassland", - "biomesoplenty:lush_swamp", - "biomesoplenty:mangrove", - "biomesoplenty:marsh", - "biomesoplenty:mire", - "biomesoplenty:pasture", - "biomesoplenty:prairie", - "biomesoplenty:shrubland", - "biomesoplenty:steppe", - "biomesoplenty:wetland", - "minecraft:plains", - "minecraft:sunflower_plains", - "minecraft:swamp" - ], - "COLD_STEPPE": [ - "terraforged:cold_steppe" - ], - "STEPPE": [ - "biomesoplenty:steppe", - "terraforged:steppe" - ], - "TAIGA": [ - "biomesoplenty:boreal_forest", - "biomesoplenty:coniferous_forest", - "biomesoplenty:dead_forest", - "biomesoplenty:fir_clearing", - "biomesoplenty:flower_meadow", - "biomesoplenty:maple_woods", - "biomesoplenty:meadow", - "biomesoplenty:ominous_woods", - "biomesoplenty:shield", - "biomesoplenty:tundra", - "minecraft:giant_spruce_taiga", - "minecraft:giant_tree_taiga", - "minecraft:giant_tree_taiga_hills", - "minecraft:taiga", - "minecraft:taiga_hills", - "terraforged:taiga_scrub" - ], - "TUNDRA": [ - "biomesoplenty:alps", - "biomesoplenty:alps_foothills", - "biomesoplenty:snowy_coniferous_forest", - "biomesoplenty:snowy_fir_clearing", - "biomesoplenty:snowy_forest", - "minecraft:ice_spikes", - "minecraft:snowy_taiga", - "minecraft:snowy_taiga_hills", - "minecraft:snowy_tundra", - "terraforged:snowy_taiga_scrub" - ], - "ALPINE": [ - "biomesoplenty:highland", - "minecraft:gravelly_mountains", - "minecraft:modified_gravelly_mountains", - "minecraft:mountains", - "minecraft:snowy_mountains", - "minecraft:snowy_taiga_mountains", - "minecraft:taiga_mountains", - "minecraft:wooded_mountains" - ], - "rivers": { - "COLD": [ - "minecraft:frozen_river" - ], - "MEDIUM": [ - "minecraft:river" - ], - "WARM": [] - }, - "oceans": { - "COLD": [ - "minecraft:cold_ocean", - "minecraft:frozen_ocean" - ], - "MEDIUM": [ - "minecraft:ocean" - ], - "WARM": [ - "minecraft:lukewarm_ocean", - "minecraft:warm_ocean" - ] - }, - "deep_oceans": { - "COLD": [ - "minecraft:deep_cold_ocean", - "minecraft:deep_frozen_ocean" - ], - "MEDIUM": [ - "minecraft:deep_ocean" - ], - "WARM": [ - "minecraft:deep_lukewarm_ocean", - "minecraft:deep_warm_ocean" - ] - } -} \ No newline at end of file diff --git a/TerraForgedApp/src/main/resources/grass.png b/TerraForgedApp/src/main/resources/grass.png deleted file mode 100644 index f59dd38..0000000 Binary files a/TerraForgedApp/src/main/resources/grass.png and /dev/null differ diff --git a/TerraForgedApp/src/main/resources/license.txt b/TerraForgedApp/src/main/resources/license.txt deleted file mode 100644 index 0b31935..0000000 --- a/TerraForgedApp/src/main/resources/license.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 TerraForged - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/TerraForgedCore/build.gradle b/TerraForgedCore/build.gradle deleted file mode 100644 index f68ce7d..0000000 --- a/TerraForgedCore/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -apply plugin: "maven-publish" - -repositories { - mavenCentral() -} - -dependencies { - compile project(":Noise2D") - compile "it.unimi.dsi:fastutil:8.2.1" -} - -publishing { - publications { - mavenJava(MavenPublication) { - artifact jar - } - } - - if (System.getenv("MAVEN_USER") != null && System.getenv("MAVEN_PASS") != null) { - repositories { - maven { - credentials { - username System.getenv("MAVEN_USER") - password System.getenv("MAVEN_PASS") - } - name = "nexus" - url = "https://io.terraforged.com/repository/maven/" - } - } - } -} \ No newline at end of file diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Cell.java b/TerraForgedCore/src/main/java/com/terraforged/core/cell/Cell.java deleted file mode 100644 index f1b99fe..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Cell.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.cell; - -import com.terraforged.core.util.concurrent.ObjectPool; -import com.terraforged.core.world.biome.BiomeType; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.util.NoiseUtil; - -public class Cell { - - private static final Cell EMPTY = new Cell() { - @Override - public boolean isAbsent() { - return true; - } - }; - - private static final ObjectPool> POOL = new ObjectPool<>(100, Cell::new); - - public float continent; - public float continentEdge; - public float region; - public float regionEdge; - public float biome; - public float biomeEdge = 1F; - public float riverMask = 1F; - - public float value; - public float biomeMoisture; - public float biomeTemperature; - public float moisture; - public float temperature; - public float steepness; - public float erosion; - public float sediment; - public float biomeTypeMask = 1F; - public BiomeType biomeType = BiomeType.GRASSLAND; - - public T tag = null; - - public void copy(Cell other) { - value = other.value; - - continent = other.continent; - continentEdge = other.continentEdge; - - region = other.region; - regionEdge = other.regionEdge; - - biome = other.biome; - biomeEdge = other.biomeEdge; - - riverMask = other.riverMask; - - moisture = other.moisture; - temperature = other.temperature; - biomeMoisture = other.biomeMoisture; - biomeTemperature = other.biomeTemperature; - - steepness = other.steepness; - erosion = other.erosion; - sediment = other.sediment; - biomeType = other.biomeType; - biomeTypeMask = other.biomeTypeMask; - - tag = other.tag; - } - - public float continentMask(float min, float max) { - return NoiseUtil.map(continentEdge, min, max, max - min); - } - - public float regionMask(float min, float max) { - return NoiseUtil.map(regionEdge, min, max, max - min); - } - - public float biomeMask(float min, float max) { - return NoiseUtil.map(biomeEdge, min, max, max - min); - } - - public float mask(float cmin, float cmax, float rmin, float rmax) { - return riverMask * continentMask(cmin, cmax) * regionMask(rmin, rmax); - } - - public boolean isAbsent() { - return false; - } - - @SuppressWarnings("unchecked") - public static Cell empty() { - return EMPTY; - } - - public static ObjectPool.Item> pooled() { - return POOL.get(); - } - - public interface Visitor { - - void visit(Cell cell, int dx, int dz); - } - - public interface ContextVisitor { - - void visit(Cell cell, int dx, int dz, C ctx); - } - - public interface ZoomVisitor { - - void visit(Cell cell, float x, float z); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Extent.java b/TerraForgedCore/src/main/java/com/terraforged/core/cell/Extent.java deleted file mode 100644 index 0d8af1e..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Extent.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.cell; - -import com.terraforged.core.world.terrain.Terrain; - -public interface Extent { - - void visit(int minX, int minZ, int maxX, int maxZ, Cell.Visitor visitor); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Populator.java b/TerraForgedCore/src/main/java/com/terraforged/core/cell/Populator.java deleted file mode 100644 index 60fc88d..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Populator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.cell; - -import com.terraforged.core.util.concurrent.ObjectPool; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.Module; - -public interface Populator extends Module { - - void apply(Cell cell, float x, float y); - - void tag(Cell cell, float x, float y); - - @Override - default float getValue(float x, float z) { - try (ObjectPool.Item> cell = Cell.pooled()) { - apply(cell.getValue(), x, z); - return cell.getValue().value; - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Tag.java b/TerraForgedCore/src/main/java/com/terraforged/core/cell/Tag.java deleted file mode 100644 index 5cf6ad8..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Tag.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.cell; - -public interface Tag { - - String getName(); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java deleted file mode 100644 index b6228c1..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.filter; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.region.Size; -import com.terraforged.core.settings.Settings; -import com.terraforged.core.world.heightmap.Levels; -import me.dags.noise.util.NoiseUtil; - -import java.util.Random; - -/* - * This class in an adaption of the work by Sebastian Lague which is also licensed under MIT. - * Reference: - * https://github.com/SebLague/Hydraulic-Erosion/blob/Coding-Adventure-E01/Assets/Scripts/Erosion.cs - * https://github.com/SebLague/Hydraulic-Erosion/blob/Coding-Adventure-E01/LICENSE - * - * License In Full: - * MIT License - * - * Copyright (c) 2019 Sebastian Lague - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -public class Erosion implements Filter { - - private int erosionRadius = 3; - private float inertia = 0.05f; - private float sedimentCapacityFactor = 4; - private float minSedimentCapacity = 0.01f; - private float erodeSpeed = 0.3f; - private float depositSpeed = 0.3f; - private float evaporateSpeed = 0.01f; - private float gravity = 8; - private int maxDropletLifetime = 30; - private float initialWaterVolume = 1; - private float initialSpeed = 1; - private final TerrainPos gradient = new TerrainPos(); - private int[][] erosionBrushIndices = new int[0][]; - private float[][] erosionBrushWeights = new float[0][]; - - private final Modifier modifier; - private final Random random = new Random(); - - public Erosion(Settings settings, Levels levels) { - erodeSpeed = settings.filters.erosion.erosionRate; - depositSpeed = settings.filters.erosion.depositeRate; - modifier = Modifier.range(levels.ground, levels.ground(15)); - } - - @Override - public void apply(Filterable map, int seedX, int seedZ, int iterations) { - if (erosionBrushIndices.length != map.getSize().total) { - init(map.getSize().total, erosionRadius); - } - - applyMain(map, seedX, seedZ, iterations, random); - -// applyNeighbours(map, seedX, seedZ, iterations, random); - } - - private int nextCoord(Size size, Random random) { - return random.nextInt(size.total - 1); - } - - private void applyMain(Filterable map, int seedX, int seedZ, int iterations, Random random) { - random.setSeed(NoiseUtil.seed(seedX, seedZ)); - while (iterations-- > 0) { - int posX = nextCoord(map.getSize(), random); - int posZ = nextCoord(map.getSize(), random); - apply(map.getBacking(), posX, posZ, map.getSize().total); - } - } - - private void apply(Cell[] cells, float posX, float posY, int size) { - float dirX = 0; - float dirY = 0; - float speed = initialSpeed; - float water = initialWaterVolume; - float sediment = 0; - - for (int lifetime = 0; lifetime < maxDropletLifetime; lifetime++) { - int nodeX = (int) posX; - int nodeY = (int) posY; - int dropletIndex = nodeY * size + nodeX; - // Calculate droplet's offset inside the cell (0,0) = at NW node, (1,1) = at SE node - float cellOffsetX = posX - nodeX; - float cellOffsetY = posY - nodeY; - - // Calculate droplet's height and direction of flow with bilinear interpolation of surrounding heights - gradient.update(cells, size, posX, posY); - - // Update the droplet's direction and position (move position 1 unit regardless of speed) - dirX = (dirX * inertia - gradient.gradientX * (1 - inertia)); - dirY = (dirY * inertia - gradient.gradientY * (1 - inertia)); - - // Normalize direction - float len = (float) Math.sqrt(dirX * dirX + dirY * dirY); - if (Float.isNaN(len)) { - len = 0; - } - - if (len != 0) { - dirX /= len; - dirY /= len; - } - - posX += dirX; - posY += dirY; - - // Stop simulating droplet if it's not moving or has flowed over edge of map - if ((dirX == 0 && dirY == 0) || posX < 0 || posX >= size - 1 || posY < 0 || posY >= size - 1) { - break; - } - - // Find the droplet's new height and calculate the deltaHeight - float oldHeight = gradient.height; - float newHeight = gradient.update(cells, size, posX, posY).height; - float deltaHeight = newHeight - oldHeight; - - // Calculate the droplet's sediment capacity (higher when moving fast down a slope and contains lots of water) - float sedimentCapacity = Math.max(-deltaHeight * speed * water * sedimentCapacityFactor, minSedimentCapacity); - - // If carrying more sediment than capacity, or if flowing uphill: - if (sediment > sedimentCapacity || deltaHeight > 0) { - // If moving uphill (deltaHeight > 0) try fill up to the current height, otherwise deposit a fraction of the excess sediment - float amountToDeposit = (deltaHeight > 0) ? Math.min(deltaHeight, sediment) : (sediment - sedimentCapacity) * depositSpeed; - sediment -= amountToDeposit; - - // Add the sediment to the four nodes of the current cell using bilinear interpolation - // Deposition is not distributed over a radius (like erosion) so that it can fill small pits - deposit(cells[dropletIndex], amountToDeposit * (1 - cellOffsetX) * (1 - cellOffsetY)); - deposit(cells[dropletIndex + 1], amountToDeposit * cellOffsetX * (1 - cellOffsetY)); - deposit(cells[dropletIndex + size], amountToDeposit * (1 - cellOffsetX) * cellOffsetY); - deposit(cells[dropletIndex + size + 1], amountToDeposit * cellOffsetX * cellOffsetY); - } else { - // Erode a fraction of the droplet's current carry capacity. - // Clamp the erosion to the change in height so that it doesn't dig a hole in the terrain behind the droplet - float amountToErode = Math.min((sedimentCapacity - sediment) * erodeSpeed, -deltaHeight); - - // Use erosion brush to erode from all nodes inside the droplet's erosion radius - for (int brushPointIndex = 0; brushPointIndex < erosionBrushIndices[dropletIndex].length; brushPointIndex++) { - int nodeIndex = erosionBrushIndices[dropletIndex][brushPointIndex]; - Cell cell = cells[nodeIndex]; - float brushWeight = erosionBrushWeights[dropletIndex][brushPointIndex]; - float weighedErodeAmount = amountToErode * brushWeight; - float deltaSediment = Math.min(cell.value, weighedErodeAmount);//cell.value < weighedErodeAmount) ? cell.value : weighedErodeAmount; - erode(cell, deltaSediment); - sediment += deltaSediment; - } - } - - // Update droplet's speed and water content - speed = (float) Math.sqrt(speed * speed + deltaHeight * gravity); - water *= (1 - evaporateSpeed); - - if (Float.isNaN(speed)) { - speed = 0; - } - } - } - - private void init(int size, int radius) { - erosionBrushIndices = new int[size * size][]; - erosionBrushWeights = new float[size * size][]; - - int[] xOffsets = new int[radius * radius * 4]; - int[] yOffsets = new int[radius * radius * 4]; - float[] weights = new float[radius * radius * 4]; - float weightSum = 0; - int addIndex = 0; - - for (int i = 0; i < erosionBrushIndices.length; i++) { - int centreX = i % size; - int centreY = i / size; - - if (centreY <= radius || centreY >= size - radius || centreX <= radius + 1 || centreX >= size - radius) { - weightSum = 0; - addIndex = 0; - for (int y = -radius; y <= radius; y++) { - for (int x = -radius; x <= radius; x++) { - float sqrDst = x * x + y * y; - if (sqrDst < radius * radius) { - int coordX = centreX + x; - int coordY = centreY + y; - - if (coordX >= 0 && coordX < size && coordY >= 0 && coordY < size) { - float weight = 1 - (float) Math.sqrt(sqrDst) / radius; - weightSum += weight; - weights[addIndex] = weight; - xOffsets[addIndex] = x; - yOffsets[addIndex] = y; - addIndex++; - } - } - } - } - } - - int numEntries = addIndex; - erosionBrushIndices[i] = new int[numEntries]; - erosionBrushWeights[i] = new float[numEntries]; - - for (int j = 0; j < numEntries; j++) { - erosionBrushIndices[i][j] = (yOffsets[j] + centreY) * size + xOffsets[j] + centreX; - erosionBrushWeights[i][j] = weights[j] / weightSum; - } - } - } - - private void deposit(Cell cell, float amount) { - float change = modifier.modify(cell, amount); - cell.value += change; - cell.sediment += change; - } - - private void erode(Cell cell, float amount) { - float change = modifier.modify(cell, amount); - cell.value -= change; - cell.erosion -= change; - } - - private static class TerrainPos { - private float height; - private float gradientX; - private float gradientY; - - private TerrainPos update(Cell[] nodes, int mapSize, float posX, float posY) { - int coordX = (int) posX; - int coordY = (int) posY; - - // Calculate droplet's offset inside the cell (0,0) = at NW node, (1,1) = at SE node - float x = posX - coordX; - float y = posY - coordY; - - // Calculate heights of the four nodes of the droplet's cell - int nodeIndexNW = coordY * mapSize + coordX; - float heightNW = nodes[nodeIndexNW].value; - float heightNE = nodes[nodeIndexNW + 1].value; - float heightSW = nodes[nodeIndexNW + mapSize].value; - float heightSE = nodes[nodeIndexNW + mapSize + 1].value; - - // Calculate droplet's direction of flow with bilinear interpolation of height difference along the edges - this.gradientX = (heightNE - heightNW) * (1 - y) + (heightSE - heightSW) * y; - this.gradientY = (heightSW - heightNW) * (1 - x) + (heightSE - heightNE) * x; - // Calculate height with bilinear interpolation of the heights of the nodes of the cell - this.height = heightNW * (1 - x) * (1 - y) + heightNE * x * (1 - y) + heightSW * (1 - x) * y + heightSE * x * y; - return this; - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filter.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filter.java deleted file mode 100644 index 483ba90..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.filter; - -import com.terraforged.core.cell.Cell; - -public interface Filter { - - void apply(Filterable map, int seedX, int seedZ, int iterations); - - default void iterate(Filterable map, Visitor visitor) { - for (int dz = 0; dz < map.getSize().total; dz++) { - for (int dx = 0; dx < map.getSize().total; dx++) { - Cell cell = map.getCellRaw(dx, dz); - visitor.visit(map, cell, dx, dz); - } - } - } - - interface Visitor { - - void visit(Filterable cellMap, Cell cell, int dx, int dz); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filterable.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filterable.java deleted file mode 100644 index bc11e86..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Filterable.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.filter; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Tag; -import com.terraforged.core.region.Size; - -public interface Filterable { - - Size getSize(); - - Cell[] getBacking(); - - Cell getCellRaw(int x, int z); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Modifier.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Modifier.java deleted file mode 100644 index bfb9f22..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Modifier.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.filter; - -import com.terraforged.core.cell.Cell; - -public interface Modifier { - - float getModifier(float value); - - default float modify(Cell cell, float value) { - return value * getModifier(cell.value); - } - - default Modifier invert() { - return v -> 1 - getModifier(v); - } - - static Modifier range(float minValue, float maxValue) { - return new Modifier() { - - private final float min = minValue; - private final float max = maxValue; - private final float range = maxValue - minValue; - - @Override - public float getModifier(float value) { - if (value > max) { - return 1F; - } - if (value < min) { - return 0F; - } - return (value - min) / range; - } - }; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java deleted file mode 100644 index 7e7e462..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.filter; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.settings.Settings; -import com.terraforged.core.world.heightmap.Levels; -import me.dags.noise.util.NoiseUtil; - -public class Smoothing implements Filter { - - private final int radius; - private final float rad2; - private final float strength; - private final Modifier modifier; - - public Smoothing(Settings settings, Levels levels) { - this.radius = NoiseUtil.round(settings.filters.smoothing.smoothingRadius + 0.5F); - this.rad2 = settings.filters.smoothing.smoothingRadius * settings.filters.smoothing.smoothingRadius; - this.strength = settings.filters.smoothing.smoothingRate; - this.modifier = Modifier.range(levels.ground(1), levels.ground(120)).invert(); - } - - @Override - public void apply(Filterable map, int seedX, int seedZ, int iterations) { - while (iterations-- > 0) { - apply(map); - } - } - - private void apply(Filterable cellMap) { - int maxZ = cellMap.getSize().total - radius; - int maxX = cellMap.getSize().total - radius; - for (int z = radius; z < maxZ; z++) { - for (int x = radius; x < maxX; x++) { - Cell cell = cellMap.getCellRaw(x, z); - - float total = 0; - float weights = 0; - - for (int dz = -radius; dz <= radius; dz++) { - for (int dx = -radius; dx <= radius; dx++) { - float dist2 = dx * dx + dz * dz; - if (dist2 > rad2) { - continue; - } - int px = x + dx; - int pz = z + dz; - Cell neighbour = cellMap.getCellRaw(px, pz); - if (neighbour.isAbsent()) { - continue; - } - float value = neighbour.value; - float weight = 1F - (dist2 / rad2); - total += (value * weight); - weights += weight; - } - } - - if (weights > 0) { - float dif = cell.value - (total / weights); - cell.value -= modifier.modify(cell, dif * strength); - } - } - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Steepness.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Steepness.java deleted file mode 100644 index dc16467..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Steepness.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.filter; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrains; - -public class Steepness implements Filter, Filter.Visitor { - - private final int radius; - private final float scaler; - private final float waterLevel; - private final float maxBeachLevel; - private final Terrains terrains; - - public Steepness(int radius, float scaler, Terrains terrains, Levels levels) { - this.radius = radius; - this.scaler = scaler; - this.terrains = terrains; - this.waterLevel = levels.water; - this.maxBeachLevel = levels.water(6); - } - - @Override - public void apply(Filterable cellMap, int seedX, int seedZ, int iterations) { - iterate(cellMap, this); - } - - @Override - public void visit(Filterable cellMap, Cell cell, int cx, int cz) { - float totalHeightDif = 0F; - for (int dz = -1; dz <= 2; dz++) { - for (int dx = -1; dx <= 2; dx++) { - if (dx == 0 && dz == 0) { - continue; - } - - int x = cx + dx * radius; - int z = cz + dz * radius; - Cell neighbour = cellMap.getCellRaw(x, z); - if (neighbour.isAbsent()) { - continue; - } - - float height = Math.max(neighbour.value, waterLevel); - - totalHeightDif += (Math.abs(cell.value - height) / radius); - } - } - cell.steepness = Math.min(1, totalHeightDif * scaler); - if (cell.tag == terrains.coast && cell.steepness < 0.225F && cell.value < maxBeachLevel) { - cell.tag = terrains.beach; - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/module/Blender.java b/TerraForgedCore/src/main/java/com/terraforged/core/module/Blender.java deleted file mode 100644 index 2cd17d2..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/module/Blender.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.module; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.Module; -import me.dags.noise.func.Interpolation; -import me.dags.noise.util.NoiseUtil; - -public class Blender extends Select implements Populator { - - private final Populator lower; - private final Populator upper; - - private final float blendLower; - private final float blendUpper; - private final float blendRange; - private final float midpoint; - private final float tagThreshold; - - public Blender(Module control, Populator lower, Populator upper, float min, float max, float split) { - super(control); - this.lower = lower; - this.upper = upper; - this.blendLower = min; - this.blendUpper = max; - this.blendRange = blendUpper - blendLower; - this.midpoint = blendLower + (blendRange * split); - this.tagThreshold = midpoint; - } - - public Blender(Populator control, Populator lower, Populator upper, float min, float max, float split, float tagThreshold) { - super(control); - this.lower = lower; - this.upper = upper; - this.blendLower = min; - this.blendUpper = max; - this.blendRange = blendUpper - blendLower; - this.midpoint = blendLower + (blendRange * split); - this.tagThreshold = tagThreshold; - } - - @Override - public void apply(Cell cell, float x, float y) { - float select = getSelect(cell, x, y); - - if (select < blendLower) { - lower.apply(cell, x, y); - return; - } - - if (select > blendUpper) { - upper.apply(cell, x, y); - return; - } - - float alpha = Interpolation.LINEAR.apply((select - blendLower) / blendRange); - lower.apply(cell, x, y); - - float lowerVal = cell.value; - Terrain lowerType = cell.tag; - - upper.apply(cell, x, y); - float upperVal = cell.value; - - cell.value = NoiseUtil.lerp(lowerVal, upperVal, alpha); - if (select < midpoint) { - cell.tag = lowerType; - } - } - - @Override - public void tag(Cell cell, float x, float y) { - float select = getSelect(cell, x, y); - if (select < blendLower) { - lower.tag(cell, x, y); - return; - } - - if (select > blendUpper) { - upper.tag(cell, x, y); - return; - } - - if (select < tagThreshold) { - lower.tag(cell, x, y); - } else { - upper.tag(cell, x, y); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/module/MultiBlender.java b/TerraForgedCore/src/main/java/com/terraforged/core/module/MultiBlender.java deleted file mode 100644 index 121015d..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/module/MultiBlender.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.module; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.func.Interpolation; -import me.dags.noise.util.NoiseUtil; - -public class MultiBlender extends Select implements Populator { - - private final Climate climate; - private final Populator lower; - private final Populator middle; - private final Populator upper; - private final float midpoint; - - private final float blendLower; - private final float blendUpper; - - private final float lowerRange; - private final float upperRange; - - public MultiBlender(Climate climate, Populator control, Populator lower, Populator middle, Populator upper, float min, float mid, float max) { - super(control); - this.climate = climate; - this.lower = lower; - this.upper = upper; - this.middle = middle; - - this.midpoint = mid; - this.blendLower = min; - this.blendUpper = max; - - this.lowerRange = midpoint - blendLower; - this.upperRange = blendUpper - midpoint; - } - - @Override - public void apply(Cell cell, float x, float y) { - float select = getSelect(cell, x, y); - if (select < blendLower) { - lower.apply(cell, x, y); - return; - } - - if (select > blendUpper) { - upper.apply(cell, x, y); - return; - } - - if (select < midpoint) { - float alpha = Interpolation.CURVE3.apply((select - blendLower) / lowerRange); - - lower.apply(cell, x, y); - float lowerVal = cell.value; - Terrain lowerType = cell.tag; - - middle.apply(cell, x, y); - float upperVal = cell.value; - - cell.value = NoiseUtil.lerp(lowerVal, upperVal, alpha); - } else { - float alpha = Interpolation.CURVE3.apply((select - midpoint) / upperRange); - - middle.apply(cell, x, y); - float lowerVal = cell.value; - - upper.apply(cell, x, y); - cell.value = NoiseUtil.lerp(lowerVal, cell.value, alpha); - } - } - - @Override - public void tag(Cell cell, float x, float y) { - float select = getSelect(cell, x, y); - if (select < blendLower) { - lower.tag(cell, x, y); - return; - } - - if (select > blendUpper) { - upper.tag(cell, x, y); - return; - } - - if (select < midpoint) { - lower.tag(cell, x, y); -// upper.tag(cell, x, y); - if (cell.value > cell.tag.getMax(climate.getRand().getValue(x, y))) { - upper.tag(cell, x, y); - } - } else { - upper.tag(cell, x, y); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/module/Select.java b/TerraForgedCore/src/main/java/com/terraforged/core/module/Select.java deleted file mode 100644 index c77fcf9..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/module/Select.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.module; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.Module; - -public class Select { - - private final Module control; - - public Select(Module control) { - this.control = control; - } - - public float getSelect(Cell cell, float x, float y) { - return control.getValue(x, y); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java deleted file mode 100644 index b4a145f..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java +++ /dev/null @@ -1,404 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.region; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Extent; -import com.terraforged.core.filter.Filterable; -import com.terraforged.core.region.chunk.ChunkReader; -import com.terraforged.core.region.chunk.ChunkWriter; -import com.terraforged.core.util.concurrent.Disposable; -import com.terraforged.core.world.decorator.Decorator; -import com.terraforged.core.world.heightmap.Heightmap; -import com.terraforged.core.world.rivermap.RiverRegionList; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.util.NoiseUtil; - -import java.util.Collection; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Consumer; - -public class Region implements Extent, Disposable { - - private final int regionX; - private final int regionZ; - private final int chunkX; - private final int chunkZ; - private final int blockX; - private final int blockZ; - private final int border; - private final Size blockSize; - private final Size chunkSize; - private final GenCell[] blocks; - private final GenChunk[] chunks; - private final int disposableChunks; - private final Disposable.Listener disposalListener; - private final AtomicInteger disposedChunks = new AtomicInteger(); - - public Region(int regionX, int regionZ, int size, int borderChunks) { - this(regionX, regionZ, size, borderChunks, region -> {}); - } - - public Region(int regionX, int regionZ, int size, int borderChunks, Disposable.Listener disposalListener) { - this.regionX = regionX; - this.regionZ = regionZ; - this.chunkX = regionX << size; - this.chunkZ = regionZ << size; - this.blockX = Size.chunkToBlock(chunkX); - this.blockZ = Size.chunkToBlock(chunkZ); - this.border = borderChunks; - this.chunkSize = Size.chunks(size, borderChunks); - this.blockSize = Size.blocks(size, borderChunks); - this.disposalListener = disposalListener; - this.disposableChunks = chunkSize.size * chunkSize.size; - this.blocks = new GenCell[blockSize.total * blockSize.total]; - this.chunks = new GenChunk[chunkSize.total * chunkSize.total]; - } - - @Override - public void dispose() { - int disposed = disposedChunks.incrementAndGet(); - if (disposed < disposableChunks) { - return; - } - disposalListener.onDispose(this); - } - - public long getRegionId() { - return NoiseUtil.seed(getRegionX(), getRegionZ()); - } - - public int getRegionX() { - return regionX; - } - - public int getRegionZ() { - return regionZ; - } - - public int getBlockX() { - return blockX; - } - - public int getBlockZ() { - return blockZ; - } - - public int getOffsetChunks() { - return border; - } - - public int getChunkCount() { - return chunks.length; - } - - public int getBlockCount() { - return blocks.length; - } - - public Size getChunkSize() { - return chunkSize; - } - - public Size getBlockSize() { - return blockSize; - } - - public Filterable filterable() { - return new FilterRegion(); - } - - public Cell getCell(int blockX, int blockZ) { - int relBlockX = blockSize.border + blockSize.mask(blockX); - int relBlockZ = blockSize.border + blockSize.mask(blockZ); - int index = blockSize.indexOf(relBlockX, relBlockZ); - return blocks[index]; - } - - public Cell getRawCell(int blockX, int blockZ) { - int index = blockSize.indexOf(blockX, blockZ); - return blocks[index]; - } - - public ChunkReader getChunk(int chunkX, int chunkZ) { - int relChunkX = chunkSize.border + chunkSize.mask(chunkX); - int relChunkZ = chunkSize.border + chunkSize.mask(chunkZ); - int index = chunkSize.indexOf(relChunkX, relChunkZ); - return chunks[index]; - } - - public void generate(Consumer consumer) { - for (int cz = 0; cz < chunkSize.total; cz++) { - for (int cx = 0; cx < chunkSize.total; cx++) { - int index = chunkSize.indexOf(cx, cz); - GenChunk chunk = computeChunk(index, cx, cz); - consumer.accept(chunk); - } - } - } - - public void generateBase(Heightmap heightmap) { - for (int cz = 0; cz < chunkSize.total; cz++) { - for (int cx = 0; cx < chunkSize.total; cx++) { - int index = chunkSize.indexOf(cx, cz); - GenChunk chunk = computeChunk(index, cx, cz); - for (int dz = 0; dz < 16; dz++) { - for (int dx = 0; dx < 16; dx++) { - float x = chunk.getBlockX() + dx; - float z = chunk.getBlockZ() + dz; - Cell cell = chunk.genCell(dx, dz); - heightmap.applyBase(cell, x, z); - } - } - } - } - } - - public void generateRivers(Heightmap heightmap, RiverRegionList rivers) { - for (int cz = 0; cz < chunkSize.total; cz++) { - for (int cx = 0; cx < chunkSize.total; cx++) { - int index = chunkSize.indexOf(cx, cz); - GenChunk chunk = computeChunk(index, cx, cz); - for (int dz = 0; dz < 16; dz++) { - for (int dx = 0; dx < 16; dx++) { - float x = chunk.getBlockX() + dx; - float z = chunk.getBlockZ() + dz; - Cell cell = chunk.genCell(dx, dz); - heightmap.applyRivers(cell, x, z, rivers); - heightmap.applyClimate(cell, x, z); - } - } - } - } - } - - public void generateZoom(Heightmap heightmap, float offsetX, float offsetZ, float zoom) { - float translateX = offsetX - ((blockSize.size * zoom) / 2F); - float translateZ = offsetZ - ((blockSize.size * zoom) / 2F); - for (int cz = 0; cz < chunkSize.total; cz++) { - for (int cx = 0; cx < chunkSize.total; cx++) { - int index = chunkSize.indexOf(cx, cz); - GenChunk chunk = computeChunk(index, cx, cz); - for (int dz = 0; dz < 16; dz++) { - for (int dx = 0; dx < 16; dx++) { - float x = ((chunk.getBlockX() + dx) * zoom) + translateX; - float z = ((chunk.getBlockZ() + dz) * zoom) + translateZ; - Cell cell = chunk.genCell(dx, dz); - heightmap.apply(cell, x, z); - } - } - } - } - } - - public void decorate(Collection decorators) { - for (int dz = 0; dz < blockSize.total; dz++) { - for (int dx = 0; dx < blockSize.total; dx++) { - int index = blockSize.indexOf(dx, dz); - GenCell cell = blocks[index]; - for (Decorator decorator : decorators) { - if (decorator.apply(cell, getBlockX() + dx, getBlockZ() + dz)) { - break; - } - } - } - } - } - - public void decorateZoom(Collection decorators, float offsetX, float offsetZ, float zoom) { - float translateX = offsetX - ((blockSize.size * zoom) / 2F); - float translateZ = offsetZ - ((blockSize.size * zoom) / 2F); - for (int cz = 0; cz < chunkSize.total; cz++) { - for (int cx = 0; cx < chunkSize.total; cx++) { - int index = chunkSize.indexOf(cx, cz); - GenChunk chunk = computeChunk(index, cx, cz); - chunk.iterate((cell, dx, dz) -> { - float x = ((chunk.getBlockX() + dx) * zoom) + translateX; - float z = ((chunk.getBlockZ() + dz) * zoom) + translateZ; - for (Decorator decorator : decorators) { - decorator.apply(cell, x, z); - } - }); - } - } - } - - public void iterate(Consumer consumer) { - for (int cz = 0; cz < chunkSize.size; cz++) { - int chunkZ = chunkSize.border + cz; - for (int cx = 0; cx < chunkSize.size; cx++) { - int chunkX = chunkSize.border + cx; - int index = chunkSize.indexOf(chunkX, chunkZ); - GenChunk chunk = chunks[index]; - consumer.accept(chunk); - } - } - } - - public void iterate(Cell.Visitor visitor) { - for (int dz = 0; dz < blockSize.size; dz++) { - int z = blockSize.border + dz; - for (int dx = 0; dx < blockSize.size; dx++) { - int x = blockSize.border + dx; - int index = blockSize.indexOf(x, z); - GenCell cell = blocks[index]; - visitor.visit(cell, dx, dz); - } - } - } - - @Override - public void visit(int minX, int minZ, int maxX, int maxZ, Cell.Visitor visitor) { - int regionMinX = getBlockX(); - int regionMinZ = getBlockZ(); - if (maxX < regionMinX || maxZ < regionMinZ) { - return; - } - - int regionMaxX = getBlockX() + getBlockSize().size - 1; - int regionMaxZ = getBlockZ() + getBlockSize().size - 1; - if (minX > regionMaxX || maxZ > regionMaxZ) { - return; - } - - minX = Math.max(minX, regionMinX); - minZ = Math.max(minZ, regionMinZ); - maxX = Math.min(maxX, regionMaxX); - maxZ = Math.min(maxZ, regionMaxZ); - - for (int z = minZ; z <= maxX; z++) { - for (int x = minX; x <= maxZ; x++) { - visitor.visit(getCell(x, z), x, z); - } - } - } - - private GenChunk computeChunk(int index, int chunkX, int chunkZ) { - GenChunk chunk = chunks[index]; - if (chunk == null) { - chunk = new GenChunk(chunkX, chunkZ); - chunks[index] = chunk; - } - return chunk; - } - - private GenCell computeCell(int index) { - GenCell cell = blocks[index]; - if (cell == null) { - cell = new GenCell(); - blocks[index] = cell; - } - return cell; - } - - private static class GenCell extends Cell {} - - private class GenChunk implements ChunkReader, ChunkWriter { - - private final int chunkX; - private final int chunkZ; - private final int blockX; - private final int blockZ; - private final int regionBlockX; - private final int regionBlockZ; - - // the coordinate of the chunk within this region (relative to 0,0) - private GenChunk(int regionChunkX, int regionChunkZ) { - // the block coordinate of this chunk within this region (relative 0,0) - this.regionBlockX = regionChunkX << 4; - this.regionBlockZ = regionChunkZ << 4; - // the real coordinate of this chunk within the world - this.chunkX = Region.this.chunkX + regionChunkX - getOffsetChunks(); - this.chunkZ = Region.this.chunkZ + regionChunkZ - getOffsetChunks(); - // the real block coordinate of this chunk within the world - this.blockX = chunkX << 4; - this.blockZ = chunkZ << 4; - } - - @Override - public int getChunkX() { - return chunkX; - } - - @Override - public int getChunkZ() { - return chunkZ; - } - - @Override - public int getBlockX() { - return blockX; - } - - @Override - public int getBlockZ() { - return blockZ; - } - - @Override - public void dispose() { - Region.this.dispose(); - } - - @Override - public Cell getCell(int blockX, int blockZ) { - int relX = regionBlockX + (blockX & 15); - int relZ = regionBlockZ + (blockZ & 15); - int index = blockSize.indexOf(relX, relZ); - return blocks[index]; - } - - @Override - public Cell genCell(int blockX, int blockZ) { - int relX = regionBlockX + (blockX & 15); - int relZ = regionBlockZ + (blockZ & 15); - int index = blockSize.indexOf(relX, relZ); - return computeCell(index); - } - } - - private class FilterRegion implements Filterable { - - @Override - public Size getSize() { - return blockSize; - } - - @Override - public Cell[] getBacking() { - return blocks; - } - - @Override - public Cell getCellRaw(int x, int z) { - int index = blockSize.indexOf(x, z); - if (index < 0 || index >= blocks.length) { - return Cell.empty(); - } - return blocks[index]; - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionFactory.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionFactory.java deleted file mode 100644 index 83c927e..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionFactory.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.terraforged.core.region; - -import com.terraforged.core.util.concurrent.Disposable; - -public interface RegionFactory { - - Region create(int regionX, int regionZ, int size, int borderChunks, Disposable.Listener listener); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/Size.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/Size.java deleted file mode 100644 index c9f9d34..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/Size.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.region; - -public class Size { - - public final int size; - public final int total; - public final int border; - private final int mask; - - public Size(int size, int border) { - this.size = size; - this.mask = size - 1; - this.border = border; - this.total = size + (2 * border); - } - - public int mask(int i) { - return i & mask; - } - - public int indexOf(int x, int z) { - return (z * total) + x; - } - - public static int chunkToBlock(int i) { - return i << 4; - } - - public static int blockToChunk(int i) { - return i >> 4; - } - - public static int count(int minX, int minZ, int maxX, int maxZ) { - int dx = maxX - minX; - int dz = maxZ - minZ; - return dx * dz; - } - - public static Size chunks(int factor, int borderChunks) { - int chunks = 1 << factor; - return new Size(chunks, borderChunks); - } - - public static Size blocks(int factor, int borderChunks) { - int chunks = 1 << factor; - int blocks = chunks << 4; - int borderBlocks = borderChunks << 4; - return new Size(blocks, borderBlocks); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkGenTask.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkGenTask.java deleted file mode 100644 index 51cba50..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkGenTask.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.region.chunk; - -import com.terraforged.core.world.heightmap.Heightmap; - -public class ChunkGenTask implements Runnable { - - protected final ChunkWriter chunk; - protected final Heightmap heightmap; - - public ChunkGenTask(ChunkWriter chunk, Heightmap heightmap) { - this.chunk = chunk; - this.heightmap = heightmap; - } - - @Override - public void run() { - chunk.generate((cell, dx, dz) -> { - float x = chunk.getBlockX() + dx; - float z = chunk.getBlockZ() + dz; - heightmap.apply(cell, x, z); - }); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkHolder.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkHolder.java deleted file mode 100644 index 8d417d7..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkHolder.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.region.chunk; - -import com.terraforged.core.cell.Extent; -import com.terraforged.core.util.concurrent.Disposable; - -public interface ChunkHolder extends Extent, Disposable { - - int getChunkX(); - - int getChunkZ(); - - int getBlockX(); - - int getBlockZ(); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkReader.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkReader.java deleted file mode 100644 index 11e39b8..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkReader.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.region.chunk; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; - -public interface ChunkReader extends ChunkHolder { - - Cell getCell(int dx, int dz); - - @Override - default void visit(int minX, int minZ, int maxX, int maxZ, Cell.Visitor visitor) { - int regionMinX = getBlockX(); - int regionMinZ = getBlockZ(); - if (maxX < regionMinX || maxZ < regionMinZ) { - return; - } - - int regionMaxX = getBlockX() + 15; - int regionMaxZ = getBlockZ() + 15; - if (minX > regionMaxX || maxZ > regionMaxZ) { - return; - } - - minX = Math.max(minX, regionMinX); - minZ = Math.max(minZ, regionMinZ); - maxX = Math.min(maxX, regionMaxX); - maxZ = Math.min(maxZ, regionMaxZ); - - for (int z = minZ; z <= maxX; z++) { - for (int x = minX; x <= maxZ; x++) { - visitor.visit(getCell(x, z), x, z); - } - } - } - - default void iterate(Cell.Visitor visitor) { - for (int dz = 0; dz < 16; dz++) { - for (int dx = 0; dx < 16; dx++) { - visitor.visit(getCell(dx, dz), dx, dz); - } - } - } - - default void iterate(C context, Cell.ContextVisitor visitor) { - for (int dz = 0; dz < 16; dz++) { - for (int dx = 0; dx < 16; dx++) { - visitor.visit(getCell(dx, dz), dx, dz, context); - } - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkWriter.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkWriter.java deleted file mode 100644 index d581910..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkWriter.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.region.chunk; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; - -public interface ChunkWriter extends ChunkHolder { - - Cell genCell(int dx, int dz); - - default void generate(Cell.Visitor visitor) { - for (int dz = 0; dz < 16; dz++) { - for (int dx = 0; dx < 16; dx++) { - visitor.visit(genCell(dx, dz), dx, dz); - } - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkZoomTask.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkZoomTask.java deleted file mode 100644 index f089d3b..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/chunk/ChunkZoomTask.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.region.chunk; - -import com.terraforged.core.world.heightmap.Heightmap; - -public class ChunkZoomTask extends ChunkGenTask { - - private final float translateX; - private final float translateZ; - private final float zoom; - - public ChunkZoomTask(ChunkWriter chunk, Heightmap heightmap, float translateX, float translateZ, float zoom) { - super(chunk, heightmap); - this.translateX = translateX; - this.translateZ = translateZ; - this.zoom = zoom; - } - - @Override - public void run() { - chunk.generate((cell, dx, dz) -> { - float x = ((chunk.getBlockX() + dx) * zoom) + translateX; - float z = ((chunk.getBlockZ() + dz) * zoom) + translateZ; - heightmap.apply(cell, x, z); - }); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/FutureRegion.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/FutureRegion.java deleted file mode 100644 index 5ddfb3b..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/FutureRegion.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.terraforged.core.region.gen; - -import com.terraforged.core.region.Region; - -import java.util.concurrent.Callable; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -public class FutureRegion implements Future, Callable { - - private final int rx; - private final int rz; - private final RegionGenerator generator; - - private volatile Region result; - - public FutureRegion(int rx, int rz, RegionGenerator generator) { - this.rx = rx; - this.rz = rz; - this.generator = generator; - } - - @Override - public Region call() { - Region region = result; - if (region == null) { - region = generator.generateRegion(rx, rz); - result = region; - } - return region; - } - - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - - @Override - public boolean isDone() { - return result != null; - } - - @Override - public Region get() { - return call(); - } - - @Override - public Region get(long timeout, TimeUnit unit) { - return get(); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/FutureRegionZoom.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/FutureRegionZoom.java deleted file mode 100644 index 039f638..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/FutureRegionZoom.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.terraforged.core.region.gen; - -import com.terraforged.core.region.Region; - -import java.util.concurrent.Callable; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -public class FutureRegionZoom implements Future, Callable { - - private final float cx; - private final float cz; - private final float zoom; - private final boolean filters; - private final RegionGenerator generator; - - private volatile Region result; - - public FutureRegionZoom(float cx, float cz, float zoom, boolean filters, RegionGenerator generator) { - this.cx = cx; - this.cz = cz; - this.zoom = zoom; - this.filters = filters; - this.generator = generator; - } - - @Override - public Region call() { - Region region = result; - if (region == null) { - region = generator.generateRegion(cx, cz, zoom, filters); - result = region; - } - return region; - } - - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - - @Override - public boolean isDone() { - return result != null; - } - - @Override - public Region get() { - return call(); - } - - @Override - public Region get(long timeout, TimeUnit unit) { - return get(); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/GenContext.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/GenContext.java deleted file mode 100644 index 7b60433..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/GenContext.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.terraforged.core.region.gen; - -import com.terraforged.core.world.WorldGenerator; -import com.terraforged.core.world.WorldGeneratorFactory; -import com.terraforged.core.world.rivermap.RiverRegionList; - -import java.util.function.Supplier; - -public class GenContext { - - public final WorldGenerator generator; - public final RiverRegionList rivers = new RiverRegionList(); - - public GenContext(WorldGenerator generator) { - this.generator = generator; - } - - public static Supplier supplier(WorldGeneratorFactory factory) { - return () -> new GenContext(factory.get()); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/RegionCache.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/RegionCache.java deleted file mode 100644 index 323417f..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/RegionCache.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.region.gen; - -import com.terraforged.core.region.Region; -import com.terraforged.core.region.chunk.ChunkReader; -import com.terraforged.core.util.concurrent.Disposable; -import com.terraforged.core.util.concurrent.cache.Cache; -import com.terraforged.core.util.concurrent.cache.CacheEntry; -import com.terraforged.core.world.heightmap.RegionExtent; -import me.dags.noise.util.NoiseUtil; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; - -public class RegionCache implements RegionExtent, Disposable.Listener { - - private final boolean queuing; - private final RegionGenerator generator; - private final Cache> cache; - - public RegionCache(boolean queueNeighbours, RegionGenerator generator) { - this.queuing = queueNeighbours; - this.generator = new RegionGenerator(generator, this); - this.cache = new Cache<>(60, 30, TimeUnit.SECONDS); - } - - @Override - public void onDispose(Region region) { - cache.remove(region.getRegionId()); - } - - @Override - public int chunkToRegion(int coord) { - return generator.chunkToRegion(coord); - } - - @Override - public CompletableFuture getRegionAsync(int regionX, int regionZ) { - return generator.generate(regionX, regionZ); - } - - @Override - public ChunkReader getChunk(int chunkX, int chunkZ) { - int regionX = generator.chunkToRegion(chunkX); - int regionZ = generator.chunkToRegion(chunkZ); - Region region = getRegion(regionX, regionZ); - return region.getChunk(chunkX, chunkZ); - } - - @Override - public Region getRegion(int regionX, int regionZ) { - Region region = computeRegion(regionX, regionZ).get(); - - if (queuing) { - queueNeighbours(regionX, regionZ); - } - - return region; - } - - private CacheEntry computeRegion(int regionX, int regionZ) { - long id = NoiseUtil.seed(regionX, regionZ); - return cache.computeIfAbsent(id, l -> generator.compute(regionX, regionZ)); - } - - public CacheEntry queueRegion(int regionX, int regionZ) { - long id = NoiseUtil.seed(regionX, regionZ); - return cache.computeIfAbsent(id, l -> generator.queue(regionX, regionZ)); - } - - private void queueNeighbours(int regionX, int regionZ) { - for (int z = -1; z <= 1; z++) { - for (int x = -1; x <= 1; x++){ - if (x == 0 && z == 0) { - continue; - } - queueRegion(regionX + x, regionZ + z); - } - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/RegionCacheFactory.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/RegionCacheFactory.java deleted file mode 100644 index 27c2c58..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/RegionCacheFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.region.gen; - -import com.terraforged.core.world.WorldGeneratorFactory; - -public interface RegionCacheFactory { - - RegionCache create(WorldGeneratorFactory factory); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/RegionGenerator.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/RegionGenerator.java deleted file mode 100644 index 83fc3ea..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/gen/RegionGenerator.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.region.gen; - -import com.terraforged.core.region.Region; -import com.terraforged.core.region.RegionFactory; -import com.terraforged.core.region.legacy.LegacyRegion; -import com.terraforged.core.util.concurrent.Disposable; -import com.terraforged.core.util.concurrent.ObjectPool; -import com.terraforged.core.util.concurrent.ThreadPool; -import com.terraforged.core.util.concurrent.cache.CacheEntry; -import com.terraforged.core.world.WorldGenerator; -import com.terraforged.core.world.WorldGeneratorFactory; -import com.terraforged.core.world.heightmap.RegionExtent; -import com.terraforged.core.world.rivermap.RiverRegionList; - -import java.util.concurrent.CompletableFuture; - -public class RegionGenerator implements RegionExtent { - - private final int factor; - private final int border; - private final RegionFactory regions; - private final ThreadPool threadPool; - private final ObjectPool genPool; - private final Disposable.Listener disposalListener; - - private RegionGenerator(Builder builder) { - this.factor = builder.factor; - this.border = builder.border; - this.threadPool = builder.threadPool; - this.regions = builder.regionFactory; - this.genPool = new ObjectPool<>(6, GenContext.supplier(builder.factory)); - this.disposalListener = region -> {}; - } - - protected RegionGenerator(RegionGenerator from, Disposable.Listener listener) { - this.factor = from.factor; - this.border = from.border; - this.threadPool = from.threadPool; - this.regions = from.regions; - this.genPool = from.genPool; - this.disposalListener = listener; - } - - public RegionCache toCache() { - return toCache(true); - } - - public RegionCache toCache(boolean queueNeighbours) { - return new RegionCache(queueNeighbours, this); - } - - @Override - public int chunkToRegion(int i) { - return i >> factor; - } - - @Override - public Region getRegion(int regionX, int regionZ) { - return generateRegion(regionX, regionZ); - } - - @Override - public CompletableFuture getRegionAsync(int regionX, int regionZ) { - return generate(regionX, regionZ); - } - - public CompletableFuture generate(int regionX, int regionZ) { - return CompletableFuture.supplyAsync(() -> generateRegion(regionX, regionZ), threadPool); - } - - public CompletableFuture generate(float centerX, float centerZ, float zoom, boolean filter) { - return CompletableFuture.supplyAsync(() -> generateRegion(centerX, centerZ, zoom, filter), threadPool); - } - - public CacheEntry compute(int regionX, int regionZ) { - return CacheEntry.supply(new FutureRegion(regionX, regionZ, this)); - } - - public CacheEntry compute(float centerX, float centerZ, float zoom, boolean filter) { - return CacheEntry.supply(new FutureRegionZoom(centerX, centerZ, zoom, filter, this)); - } - - public CacheEntry queue(int regionX, int regionZ) { - return CacheEntry.supplyAsync(new FutureRegion(regionX, regionZ, this), threadPool); - } - - public CacheEntry queue(float centerX, float centerZ, float zoom, boolean filter) { - return CacheEntry.supplyAsync(new FutureRegionZoom(centerX, centerZ, zoom, filter, this), threadPool); - } - - public Region generateRegion(int regionX, int regionZ) { - try (ObjectPool.Item item = genPool.get()) { - RiverRegionList rivers = item.getValue().rivers; - WorldGenerator generator = item.getValue().generator; - Region region = regions.create(regionX, regionZ, factor, border, disposalListener); - generator.getHeightmap().getRiverMap().getRivers(region, rivers); - region.generateBase(generator.getHeightmap()); - region.generateRivers(generator.getHeightmap(), rivers); - postProcess(region, generator); - rivers.clear(); - return region; - } - } - - private void postProcess(Region region, WorldGenerator generator) { - generator.getFilters().apply(region); - region.decorate(generator.getDecorators().getDecorators()); - } - - public Region generateRegion(float centerX, float centerZ, float zoom, boolean filter) { - try (ObjectPool.Item item = genPool.get()) { - WorldGenerator generator = item.getValue().generator; - Region region = regions.create(0, 0, factor, border, disposalListener); - region.generateZoom(generator.getHeightmap(), centerX, centerZ, zoom); - postProcess(region, generator, centerX, centerZ, zoom, filter); - return region; - } - } - - private void postProcess(Region region, WorldGenerator generator, float centerX, float centerZ, float zoom, boolean filter) { - if (filter) { - generator.getFilters().apply(region); - } - region.decorateZoom(generator.getDecorators().getDecorators(), centerX, centerZ, zoom); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private int factor = 0; - private int border = 0; - private ThreadPool threadPool; - private WorldGeneratorFactory factory; - private RegionFactory regionFactory = Region::new; - - public Builder size(int factor, int border) { - return factor(factor).border(border); - } - - public Builder factor(int factor) { - this.factor = factor; - return this; - } - - public Builder border(int border) { - this.border = border; - return this; - } - - public Builder pool(ThreadPool threadPool) { - this.threadPool = threadPool; - return this; - } - - public Builder regions(RegionFactory factory) { - this.regionFactory = factory; - return this; - } - - public Builder legacy(boolean legacy) { - if (legacy) { - return regions(LegacyRegion::new); - } - return this; - } - - public Builder factory(WorldGeneratorFactory factory) { - this.factory = factory; - return this; - } - - public RegionGenerator build() { - return new RegionGenerator(this); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/legacy/LegacyRegion.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/legacy/LegacyRegion.java deleted file mode 100644 index 34d77dc..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/legacy/LegacyRegion.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.terraforged.core.region.legacy; - -import com.terraforged.core.region.Region; -import com.terraforged.core.util.concurrent.Disposable; - -/** - * This is here to provide compatibility for versions 0.0.2 and below which contained a - * bug where Regions generated with an x,z offset equal to the size of the chunk border - * around the region (x16) ie 32 blocks - */ -public class LegacyRegion extends Region { - - public LegacyRegion(int regionX, int regionZ, int size, int borderChunks, Disposable.Listener listener) { - super(regionX, regionZ, size, borderChunks, listener); - } - - /** - * This is used when calculating the 'real world' chunk position of the chunk-view - * and subsequently the 'real world' block start position. In versions 0.0.2 and - * below, no offset was being deducted, so return 0 here to maintain that broken - * behaviour... RIP :/ - */ - @Override - public int getOffsetChunks() { - return 0; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/settings/BiomeSettings.java b/TerraForgedCore/src/main/java/com/terraforged/core/settings/BiomeSettings.java deleted file mode 100644 index 8b27fcb..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/settings/BiomeSettings.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.settings; - -import com.terraforged.core.util.serialization.annotation.Comment; -import com.terraforged.core.util.serialization.annotation.Range; -import com.terraforged.core.util.serialization.annotation.Serializable; -import com.terraforged.core.world.biome.BiomeType; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class BiomeSettings { - - public BiomeGroup desert = new BiomeGroup(BiomeType.DESERT); - public BiomeGroup steppe = new BiomeGroup(BiomeType.STEPPE); - public BiomeGroup coldSteppe = new BiomeGroup(BiomeType.COLD_STEPPE); - public BiomeGroup grassland = new BiomeGroup(BiomeType.GRASSLAND); - public BiomeGroup savanna = new BiomeGroup(BiomeType.SAVANNA); - public BiomeGroup taiga = new BiomeGroup(BiomeType.TAIGA); - public BiomeGroup temperateForest = new BiomeGroup(BiomeType.TEMPERATE_FOREST); - public BiomeGroup temperateRainForest = new BiomeGroup(BiomeType.TEMPERATE_RAINFOREST); - public BiomeGroup tropicalRainForest = new BiomeGroup(BiomeType.TROPICAL_RAINFOREST); - public BiomeGroup tundra = new BiomeGroup(BiomeType.TUNDRA); - - public List asList() { - return Arrays.asList( - desert, - steppe, - coldSteppe, - grassland, - savanna, - taiga, - temperateForest, - temperateRainForest, - tropicalRainForest, - tundra - ); - } - - public Map asMap() { - return asList().stream().collect(Collectors.toMap(g -> g.type, g -> g)); - } - - @Serializable - public static class BiomeGroup { - - public BiomeType type; - - public BiomeWeight[] biomes = new BiomeWeight[0]; - - public BiomeGroup() { - - } - - public BiomeGroup(BiomeType biomeType) { - this.type = biomeType; - } - } - - @Serializable - public static class BiomeWeight { - - public String id; - - @Range(min = 0, max = 50) - @Comment("Controls how common this biome type is") - public int weight; - - public BiomeWeight() { - - } - - public BiomeWeight(String id, int weight) { - this.id = id; - this.weight = weight; - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/settings/ClimateSettings.java b/TerraForgedCore/src/main/java/com/terraforged/core/settings/ClimateSettings.java deleted file mode 100644 index b6619c4..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/settings/ClimateSettings.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.terraforged.core.settings; - -import com.terraforged.core.util.serialization.annotation.Comment; -import com.terraforged.core.util.serialization.annotation.Range; -import com.terraforged.core.util.serialization.annotation.Serializable; -import me.dags.noise.Module; -import me.dags.noise.Source; - -@Serializable -public class ClimateSettings { - - public RangeValue moisture = new RangeValue(0, 1F); - - public RangeValue temperature = new RangeValue(0, 1F); - - @Serializable - public static class RangeValue { - - @Range(min = 0F, max = 1F) - @Comment("The lower limit of the range") - public float min; - - @Range(min = 0F, max = 1F) - @Comment("The upper limit of the range") - public float max; - - public RangeValue() { - this(0, 1); - } - - public RangeValue(float min, float max) { - this.min = min; - this.max = max; - } - - public float getMin() { - return Math.min(min, max); - } - - public float getMax() { - return Math.max(min, max); - } - - public Module clamp(Module module) { - float min = getMin(); - float max = getMax(); - float range = max - min; - if (range == 0) { - return Source.constant(min); - } - return module.scale(range).bias(min); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/settings/FilterSettings.java b/TerraForgedCore/src/main/java/com/terraforged/core/settings/FilterSettings.java deleted file mode 100644 index 198826b..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/settings/FilterSettings.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.settings; - -import com.terraforged.core.util.serialization.annotation.Comment; -import com.terraforged.core.util.serialization.annotation.Range; -import com.terraforged.core.util.serialization.annotation.Serializable; - -@Serializable -public class FilterSettings { - - public Erosion erosion = new Erosion(); - - public Smoothing smoothing = new Smoothing(); - - @Serializable - public static class Erosion { - - @Range(min = 1000, max = 50000) - @Comment("Controls the number of erosion iterations") - public int iterations = 12000; - - @Range(min = 0F, max = 1F) - @Comment("Controls how quickly material dissolves (during erosion)") - public float erosionRate = 0.5F; - - @Range(min = 0F, max = 1F) - @Comment("Controls how quickly material is deposited (during erosion)") - public float depositeRate = 0.2F; - } - - @Serializable - public static class Smoothing { - - @Range(min = 0, max = 5) - @Comment("Controls the number of smoothing iterations") - public int iterations = 1; - - @Range(min = 0, max = 5) - @Comment("Controls the smoothing radius") - public float smoothingRadius = 1.75F; - - @Range(min = 0, max = 1) - @Comment("Controls how strongly smoothing is applied") - public float smoothingRate = 0.85F; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java b/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java deleted file mode 100644 index 9d6e660..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.settings; - -import com.terraforged.core.util.serialization.annotation.Comment; -import com.terraforged.core.util.serialization.annotation.Name; -import com.terraforged.core.util.serialization.annotation.Range; -import com.terraforged.core.util.serialization.annotation.Serializable; -import me.dags.noise.Module; -import me.dags.noise.Source; - -@Serializable -public class GeneratorSettings { - - public transient long seed = 0L; - - /** - * WORLD PROPERTIES - */ - public World world = new World(); - - /** - * TERRAIN PROPERTIES - */ - public Land land = new Land(); - - /** - * BIOME PROPERTIES - */ - public Biome biome = new Biome(); - - public BiomeNoise biomeEdgeNoise = new BiomeNoise(); - - @Serializable - public static class World { - - @Range(min = 0, max = 256) - @Comment("Controls the world height") - public int worldHeight = 256; - - @Range(min = 0, max = 255) - @Comment("Controls the sea level") - public int seaLevel = 63; - - @Range(min = 0F, max = 1F) - @Comment("Controls the amount of ocean between continents") - public float oceanSize = 0.25F; - } - - @Serializable - public static class Land { - - @Range(min = 100, max = 10000) - @Comment("Controls the size of continents") - public int continentScale = 4000; - - @Range(min = 250, max = 5000) - @Name("Mountain Range Scale") - @Comment("Controls the size of mountain ranges") - public int mountainScale = 950; - - @Range(min = 125, max = 5000) - @Comment("Controls the size of terrain regions") - public int regionSize = 1000; - } - - @Serializable - public static class Biome { - - @Range(min = 50, max = 1000) - @Comment("Controls the size of individual biomes") - public int biomeSize = 200; - - @Range(min = 1, max = 500) - @Comment("Controls the scale of shape distortion for biomes") - public int biomeWarpScale = 35; - - @Range(min = 1, max = 500) - @Comment("Controls the strength of shape distortion for biomes") - public int biomeWarpStrength = 70; - } - - @Serializable - public static class BiomeNoise { - - @Comment("The noise type") - public Source type = Source.PERLIN; - - @Range(min = 1, max = 500) - @Comment("Controls the scale of the noise") - public int scale = 8; - - @Range(min = 1, max = 5) - @Comment("Controls the number of noise octaves") - public int octaves = 2; - - @Range(min = 0F, max = 5.5F) - @Comment("Controls the gain subsequent noise octaves") - public float gain = 0.5F; - - @Range(min = 0F, max = 10.5F) - @Comment("Controls the lacunarity of subsequent noise octaves") - public float lacunarity = 2.5F; - - @Range(min = 1, max = 500) - @Comment("Controls the strength of the noise") - public int strength = 24; - - public Module build(int seed) { - return Source.build(seed, scale, octaves).gain(gain).lacunarity(lacunarity).build(type).bias(-0.5); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/settings/RiverSettings.java b/TerraForgedCore/src/main/java/com/terraforged/core/settings/RiverSettings.java deleted file mode 100644 index 04d8d77..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/settings/RiverSettings.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.settings; - -import com.terraforged.core.util.serialization.annotation.Comment; -import com.terraforged.core.util.serialization.annotation.Range; -import com.terraforged.core.util.serialization.annotation.Serializable; - -@Serializable -public class RiverSettings { - - /** - * RIVER PROPERTIES - */ - @Range(min = 0.0F, max = 5F) - @Comment("Controls how frequently rivers generate") - public float riverFrequency = 1; - - public River primaryRivers = new River(5, 2, 8, 25, 8, 0.75F); - - public River secondaryRiver = new River(4, 1, 6, 15, 5, 0.75F); - - public River tertiaryRivers = new River(3, 0, 4, 10, 4, 0.75F); - - public Lake lake = new Lake(); - - @Serializable - public static class River { - - @Range(min = 1, max = 10) - @Comment("Controls the depth of the river") - public int bedDepth; - - @Range(min = 0, max = 10) - @Comment("Controls the height of river banks") - public int minBankHeight; - - @Range(min = 1, max = 10) - @Comment("Controls the height of river banks") - public int maxBankHeight; - - @Range(min = 1, max = 20) - @Comment("Controls the river-bed width") - public int bedWidth; - - @Range(min = 1, max = 50) - @Comment("Controls the river-banks width") - public int bankWidth; - - @Range(min = 0.0F, max = 1.0F) - @Comment("Controls how much rivers taper") - public float fade; - - public River() { - } - - public River(int depth, int minBank, int maxBank, int outer, int inner, float fade) { - this.minBankHeight = minBank; - this.maxBankHeight = maxBank; - this.bankWidth = outer; - this.bedWidth = inner; - this.bedDepth = depth; - this.fade = fade; - } - } - - public static class Lake { - - @Range(min = 0.0F, max = 1.0F) - @Comment("Controls the chance of a lake spawning") - public float chance = 0.2F; - - @Range(min = 0F, max = 1F) - @Comment("The minimum distance along a river that a lake will spawn") - public float minStartDistance = 0.03F; - - @Range(min = 0F, max = 1F) - @Comment("The maximum distance along a river that a lake will spawn") - public float maxStartDistance = 0.07F; - - @Range(min = 1, max = 20) - @Comment("The max depth of the lake") - public int depth = 10; - - @Range(min = 10, max = 50) - @Comment("The minimum size of the lake") - public int sizeMin = 50; - - @Range(min = 50, max = 150) - @Comment("The maximum size of the lake") - public int sizeMax = 100; - - @Range(min = 1, max = 10) - @Comment("The minimum bank height") - public int minBankHeight = 2; - - @Range(min = 1, max = 10) - @Comment("The maximum bank height") - public int maxBankHeight = 10; - - public Lake() { - - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/settings/Settings.java b/TerraForgedCore/src/main/java/com/terraforged/core/settings/Settings.java deleted file mode 100644 index d768788..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/settings/Settings.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.settings; - -import com.terraforged.core.util.serialization.annotation.Serializable; - -@Serializable -public class Settings { - - public GeneratorSettings generator = new GeneratorSettings(); - - public ClimateSettings climate = new ClimateSettings(); - - public RiverSettings rivers = new RiverSettings(); - - public FilterSettings filters = new FilterSettings(); - - public TerrainSettings terrain = new TerrainSettings(); - - public BiomeSettings biomes = new BiomeSettings(); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/settings/TerrainSettings.java b/TerraForgedCore/src/main/java/com/terraforged/core/settings/TerrainSettings.java deleted file mode 100644 index 91cc0ae..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/settings/TerrainSettings.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.settings; - -import com.terraforged.core.util.serialization.annotation.Comment; -import com.terraforged.core.util.serialization.annotation.Range; -import com.terraforged.core.util.serialization.annotation.Serializable; -import com.terraforged.core.world.terrain.TerrainPopulator; -import me.dags.noise.Module; - -@Serializable -public class TerrainSettings { - - @Range(min = 0, max = 1) - @Comment("Globally controls the vertical scaling of terrain") - public float globalVerticalScale = 0.985F; - - @Range(min = 0, max = 5) - @Comment("Globally controls the horizontal scaling of terrain") - public float globalHorizontalScale = 1.0F; - - public Terrain steppe = new Terrain(5F, 1F, 1F); - public Terrain plains = new Terrain(5F, 1F, 1F); - public Terrain hills = new Terrain(2F, 1F, 1F); - public Terrain dales = new Terrain(2F, 1F, 1F); - public Terrain plateau = new Terrain(2F, 1F, 1F); - public Terrain badlands = new Terrain(2F, 1F, 1F); - public Terrain torridonian = new Terrain(0.5F, 1F, 1F); - public Terrain mountains = new Terrain(0.5F, 1F, 1F); - public Terrain volcano = new Terrain(1F, 1F, 1F); - - @Serializable - public static class Terrain { - - @Range(min = 0, max = 10) - @Comment("Controls how common this terrain type is") - public float weight = 1F; - - @Range(min = 0, max = 2) - @Comment("Controls the base height of this terrain") - public float baseScale = 1F; - - @Range(min = 0F, max = 10F) - @Comment("Stretches or compresses the terrain vertically") - public float verticalScale = 1F; - - @Range(min = 0F, max = 10F) - @Comment("Stretches or compresses the terrain horizontally") - public float horizontalScale = 1F; - - public Terrain() { - - } - - public Terrain(float weight, float vertical, float horizontal) { - this.weight = weight; - this.verticalScale = vertical; - this.horizontalScale = horizontal; - } - - public Module apply(double bias, double scale, Module module) { - double moduleBias = bias * baseScale; - double moduleScale = scale * verticalScale; - Module outputModule = module.scale(moduleScale).bias(moduleBias); - return TerrainPopulator.clamp(outputModule); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/PosIterator.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/PosIterator.java deleted file mode 100644 index d2fce85..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/PosIterator.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util; - -public class PosIterator { - - private final int minX; - private final int minZ; - private final int maxX; - private final int maxY; - private final int maxZ; - private final int size; - - private int x; - private int y; - private int z; - private int index = -1; - - public PosIterator(int x, int y, int z, int width, int height, int length) { - this.x = x - 1; - this.y = y; - this.z = z; - this.minX = x; - this.minZ = z; - this.maxX = x + width; - this.maxY = y + height; - this.maxZ = z + length; - this.size = (width * height * length) - 1; - } - - /** - * Steps the iterator forward one position if there there is a new position within it's x/y/z bounds. - * - * @return true if the an increment was made, false if the maximum x,y,z coord has been reached - */ - public boolean next() { - if (x + 1 < maxX) { - x += 1; - index++; - return true; - } - - if (z + 1 < maxZ) { - x = minX; - z += 1; - index++; - return true; - } - - if (y + 1 < maxY) { - x = minX - 1; - z = minZ; - y += 1; - return true; - } - - return false; - } - - public int size() { - return size; - } - - public int index() { - return index; - } - - public int x() { - return x; - } - - public int y() { - return y; - } - - public int z() { - return z; - } - - /** - * Iterates over a 2D area in the x-z planes, centered on x:z, with the given radius - * - * Iteration Order: - * 1. Increments the x-axis from x - radius to x + radius (inclusive), then: - * 2. Increments the z-axis once, resets the x-axis to x - radius, then: - * 3. Repeats steps 1 & 2 until z reaches z + radius - */ - public static PosIterator radius2D(int x, int z, int radius) { - int startX = x - radius; - int startZ = z - radius; - int size = radius * 2 + 1; - return new PosIterator(startX, 0, startZ, size, 0, size); - } - - /** - * Iterates over a 3D volume, centered on x:y:z, with the given radius - * - * Iteration Order: - * 1. Increments the x-axis (starting from x - radius) up to x + radius (inclusive), then: - * 2. Increments the z-axis once (starting from z - radius) and resets the x-axis to x - radius, then: - * 3. Increments the y-axis once (starting from y - radius), resets the x & z axes to x - radius & z - radius - * respectively, then: - * 4. Repeats steps 1-3 until y reaches y + radius - */ - public static PosIterator radius3D(int x, int y, int z, int radius) { - int startX = x - radius; - int startY = y - radius; - int startZ = z - radius; - int size = radius * 2 + 1; - return new PosIterator(startX, startY, startZ, size, size, size); - } - - public static PosIterator area(int x, int z, int width, int length) { - return new PosIterator(x, 0, z, width, 0, length); - } - - public static PosIterator volume3D(int x, int y, int z, int width, int height, int length) { - return new PosIterator(x, y, z, width, height, length); - } - - public static PosIterator range2D(int minX, int minZ, int maxX, int maxZ) { - int width = maxX - minX; - int length = maxZ - minZ; - return new PosIterator(minX, 0, minZ, width, 0, length); - } - - public static PosIterator range2D(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { - int width = 1 + maxX - minX; - int height = 1 + maxY - minY; - int length = 1 + maxZ - minZ; - return new PosIterator(minX, minY, minZ, width, height, length); - } -} \ No newline at end of file diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/Seed.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/Seed.java deleted file mode 100644 index 6148874..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/Seed.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util; - -public class Seed { - - private final Seed root; - - private final int value; - private int seed; - - public Seed(long seed) { - this((int) seed); - } - - public Seed(int seed) { - this.value = seed; - this.seed = seed; - this.root = this; - } - - private Seed(Seed root) { - this.root = root; - this.seed = root.next(); - this.value = seed; - } - - public int next() { - return ++root.seed; - } - - public int get() { - return value; - } - - public Seed nextSeed() { - return new Seed(root); - } - - public Seed reset() { - this.seed = value; - return this; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/VariablePredicate.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/VariablePredicate.java deleted file mode 100644 index e43ab95..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/VariablePredicate.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.Module; -import me.dags.noise.Source; - -import java.util.function.BiPredicate; - -public class VariablePredicate { - - private final Module module; - private final BiPredicate, Float> predicate; - - public VariablePredicate(Module module, BiPredicate, Float> predicate) { - this.module = module; - this.predicate = predicate; - } - - public boolean test(Cell cell, float x, float z) { - return predicate.test(cell, module.getValue(x, z)); - } - - public static VariablePredicate height(Seed seed, Levels levels, int min, int max, int size, int octaves) { - float bias = levels.scale(min); - float scale = levels.scale(max - min); - Module source = Source.perlin(seed.next(), size, 1).scale(scale).bias(bias); - return new VariablePredicate(source, (cell, height) -> cell.value < height); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/Disposable.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/Disposable.java deleted file mode 100644 index 3907b7d..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/Disposable.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.terraforged.core.util.concurrent; - -public interface Disposable { - - void dispose(); - - interface Listener { - - void onDispose(T t); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ObjectPool.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ObjectPool.java deleted file mode 100644 index 033c12c..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ObjectPool.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.concurrent; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; - -public class ObjectPool { - - private final int capacity; - private final List> pool; - private final Supplier supplier; - - public ObjectPool(int size, Supplier supplier) { - this.capacity = size; - this.pool = new ArrayList<>(size); - this.supplier = supplier; - } - - public Item get() { - synchronized (pool) { - if (pool.size() > 0) { - return pool.remove(pool.size() - 1).retain(); - } - } - return new Item<>(supplier.get(), this); - } - - public int size() { - synchronized (pool) { - return pool.size(); - } - } - - private boolean restore(Item item) { - synchronized (pool) { - int size = pool.size(); - if (size < capacity) { - pool.add(item); - return true; - } - } - return false; - } - - public static class Item implements AutoCloseable { - - private final T value; - private final ObjectPool pool; - - private boolean released = false; - - private Item(T value, ObjectPool pool) { - this.value = value; - this.pool = pool; - } - - public T getValue() { - return value; - } - - public void release() { - if (!released) { - released = true; - released = pool.restore(this); - } - } - - private Item retain() { - released = false; - return this; - } - - @Override - public void close() { - release(); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java deleted file mode 100644 index 11690e9..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.concurrent; - -import com.terraforged.core.util.concurrent.batcher.AsyncBatcher; -import com.terraforged.core.util.concurrent.batcher.Batcher; -import com.terraforged.core.util.concurrent.batcher.SyncBatcher; - -import java.util.concurrent.Callable; -import java.util.concurrent.Executor; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ForkJoinTask; - -public class ThreadPool implements Executor { - - private static final ThreadPool instance = create("TF", defaultPoolSize()); - - private final ForkJoinPool service; - - private ThreadPool(ForkJoinPool service) { - this.service = service; - } - - @Override - public void execute(Runnable command) { - service.submit(command); - } - - public ForkJoinTask submit(Runnable runnable) { - return service.submit(runnable); - } - - public ForkJoinTask submit(Callable callable) { - return service.submit(callable); - } - - public Batcher batcher(int size) { - return new AsyncBatcher(service, size); - } - - public static ThreadPool getPool() { - return instance; - } - - public static ThreadPool create(String name, int size) { - if (size < 2) { - return new SingleThreadExecutor(); - } - return new ThreadPool(createPool(name, size)); - } - - public static ForkJoinPool createPool(String name, int size) { - return new ForkJoinPool(size, new WorkerFactory.ForkJoin(name), null, true); - } - - private static int defaultPoolSize() { - int threads = Runtime.getRuntime().availableProcessors(); - return Math.max(1, (int) ((threads / 3F) * 2F)); - } - - private static class SingleThreadExecutor extends ThreadPool { - - private SingleThreadExecutor() { - super(null); - } - - @Override - public void execute(Runnable command) { - command.run(); - } - - @Override - public ForkJoinTask submit(Runnable runnable) { - ForkJoinTask task = ForkJoinTask.adapt(runnable); - task.invoke(); - return task; - } - - @Override - public ForkJoinTask submit(Callable callable) { - ForkJoinTask task = ForkJoinTask.adapt(callable); - task.invoke(); - return task; - } - - @Override - public Batcher batcher(int size) { - return new SyncBatcher(); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/WorkerFactory.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/WorkerFactory.java deleted file mode 100644 index f04ec6c..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/WorkerFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.terraforged.core.util.concurrent; - -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ForkJoinWorkerThread; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.atomic.AtomicInteger; - -// As DefaultThreadPool but with custom thread names -public class WorkerFactory implements ThreadFactory { - - protected final String prefix; - protected final ThreadGroup group; - protected final AtomicInteger threadNumber = new AtomicInteger(1); - - public WorkerFactory(String name) { - group = Thread.currentThread().getThreadGroup(); - prefix = name + "-Worker-"; - } - - @Override - public Thread newThread(Runnable task) { - Thread thread = new Thread(group, task); - thread.setDaemon(true); - thread.setName(prefix + threadNumber.getAndIncrement()); - return thread; - } - - public static class ForkJoin extends WorkerFactory implements ForkJoinPool.ForkJoinWorkerThreadFactory { - - public ForkJoin(String name) { - super(name); - } - - @Override - public ForkJoinWorkerThread newThread(ForkJoinPool pool) { - ForkJoinWorkerThread thread = new ForkJoinWorkerThread(pool) {}; - thread.setDaemon(true); - thread.setName(prefix + threadNumber.getAndIncrement()); - return thread; - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/batcher/AsyncBatcher.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/batcher/AsyncBatcher.java deleted file mode 100644 index f97947c..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/batcher/AsyncBatcher.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.concurrent.batcher; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -public class AsyncBatcher implements Batcher { - - private final List> tasks; - private final ExecutorService executor; - - public AsyncBatcher(ExecutorService executor, int size) { - this.executor = executor; - this.tasks = new ArrayList<>(size); - } - - @Override - public void submit(Runnable task) { - tasks.add(executor.submit(task)); - } - - @Override - public void submit(Callable task) { - tasks.add(executor.submit(task)); - } - - @Override - public void close() { - boolean hasMore = true; - while (hasMore) { - hasMore = false; - for (Future future : tasks) { - if (!future.isDone()) { - hasMore = true; - } - } - } - tasks.clear(); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/batcher/Batcher.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/batcher/Batcher.java deleted file mode 100644 index 2661b81..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/batcher/Batcher.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.concurrent.batcher; - -import java.util.concurrent.Callable; - -public interface Batcher extends AutoCloseable { - - void submit(Runnable task); - - void submit(Callable task); - - @Override - void close(); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/batcher/SyncBatcher.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/batcher/SyncBatcher.java deleted file mode 100644 index b8feb51..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/batcher/SyncBatcher.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.concurrent.batcher; - -import java.util.concurrent.Callable; - -public class SyncBatcher implements Batcher { - - @Override - public void submit(Runnable task) { - task.run(); - } - - @Override - public void submit(Callable task) { - try { - task.call(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void close() { - - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/Cache.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/Cache.java deleted file mode 100644 index 1b2d32c..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/Cache.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.terraforged.core.util.concurrent.cache; - -import com.terraforged.core.util.concurrent.ThreadPool; - -import java.util.concurrent.TimeUnit; -import java.util.function.LongFunction; - -public class Cache implements Runnable { - - private final long expireMS; - private final long intervalMS; - private final SynchronizedLongMap map; - private final ThreadPool threadPool = ThreadPool.getPool(); - - private volatile long timestamp = 0L; - - public Cache(long expireTime, long interval, TimeUnit unit) { - this.expireMS = unit.toMillis(expireTime); - this.intervalMS = unit.toMillis(interval); - this.map = new SynchronizedLongMap<>(100); - } - - public void remove(long key) { - map.remove(key); - } - - public V computeIfAbsent(long key, LongFunction func) { - V v = map.computeIfAbsent(key, func); - queueUpdate(); - return v; - } - - private void queueUpdate() { - long now = System.currentTimeMillis(); - if (now - timestamp > intervalMS) { - timestamp = now; - threadPool.submit(this); - } - } - - @Override - public void run() { - final long now = timestamp; - map.removeIf(val -> now - val.getTimestamp() > expireMS); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/CacheEntry.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/CacheEntry.java deleted file mode 100644 index 4177126..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/CacheEntry.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.terraforged.core.util.concurrent.cache; - -import com.terraforged.core.util.concurrent.ThreadPool; - -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ForkJoinTask; -import java.util.concurrent.Future; - -public class CacheEntry implements ExpiringEntry { - - private volatile long timestamp; - private final Future task; - - public CacheEntry(Future task) { - this.task = task; - this.timestamp = System.currentTimeMillis(); - } - - @Override - public long getTimestamp() { - return timestamp; - } - - public boolean isDone() { - return task.isDone(); - } - - public T get() { - if (task instanceof ForkJoinTask) { - return ((ForkJoinTask) task).join(); - } - - try { - return task.get(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - } - - public static CacheEntry supply(Future future) { - return new CacheEntry<>(future); - } - - public static CacheEntry supplyAsync(Callable callable, ThreadPool executor) { - return new CacheEntry<>(executor.submit(callable)); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/ExpiringEntry.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/ExpiringEntry.java deleted file mode 100644 index e780212..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/ExpiringEntry.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.terraforged.core.util.concurrent.cache; - -public interface ExpiringEntry { - - long getTimestamp(); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/SynchronizedLongMap.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/SynchronizedLongMap.java deleted file mode 100644 index 5f92ad9..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/cache/SynchronizedLongMap.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.terraforged.core.util.concurrent.cache; - -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.objects.ObjectIterator; - -import java.util.function.LongFunction; -import java.util.function.Predicate; - -public class SynchronizedLongMap { - - private final Object lock; - private final Long2ObjectOpenHashMap map; - - public SynchronizedLongMap(int size) { - this.map = new Long2ObjectOpenHashMap<>(size); - this.lock = this; - } - - public void remove(long key) { - synchronized (lock) { - map.remove(key); - } - } - - public void put(long key, V v) { - synchronized (lock) { - map.put(key, v); - } - } - - public V get(long key) { - synchronized (lock) { - return map.get(key); - } - } - - public V computeIfAbsent(long key, LongFunction func) { - synchronized (lock) { - return map.computeIfAbsent(key, func); - } - } - - public void removeIf(Predicate predicate) { - synchronized (lock) { - ObjectIterator> iterator = map.long2ObjectEntrySet().fastIterator(); - while (iterator.hasNext()) { - if (predicate.test(iterator.next().getValue())) { - iterator.remove(); - } - } - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedGrid.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedGrid.java deleted file mode 100644 index aa298a8..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedGrid.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.grid; - -import me.dags.noise.util.NoiseUtil; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.function.Supplier; - -public class FixedGrid implements Iterable>> { - - private final MappedList>> grid; - - private FixedGrid(MappedList>> grid) { - this.grid = grid; - } - - public int size() { - return grid.size(); - } - - public FixedList get(float x, float y) { - return grid.get(y).get(x); - } - - public T get(float x, float y, float z) { - MappedList> row = grid.get(y); - FixedList cell = row.get(x); - return cell.get(z); - } - - @Override - public Iterator>> iterator() { - return grid.iterator(); - } - - public static FixedGrid create(List>> grid, float minX, float minY, float rangeX, float rangeY) { - List>> list = new ArrayList<>(); - for (List> src : grid) { - List> row = new ArrayList<>(src.size()); - for (List cell : src) { - row.add(FixedList.of(cell)); - } - list.add(MappedList.of(row, minX, rangeX)); - } - return new FixedGrid<>(MappedList.of(list, minY, rangeY)); - } - - public static FixedGrid generate(int size, List values, Function xFunc, Function yFunc) { - List>> src = createList(size, () -> createList(size, ArrayList::new)); - List>> dest = createList(size, () -> createList(size, ArrayList::new)); - - float minX = 1F; - float maxX = 0F; - float minY = 1F; - float maxY = 0F; - for (T value : values) { - float x = xFunc.apply(value); - float y = yFunc.apply(value); - minX = Math.min(minX, x); - maxX = Math.max(maxX, x); - minY = Math.min(minY, y); - maxY = Math.max(maxY, y); - } - - int maxIndex = size - 1; - float rangeX = maxX - minX; - float rangeY = maxY - minY; - for (T value : values) { - float colVal = (xFunc.apply(value) - minX) / rangeX; - float rowVal = (yFunc.apply(value) - minY) / rangeY; - int colIndex = NoiseUtil.round(maxIndex * colVal); - int rowIndex = NoiseUtil.round(maxIndex * rowVal); - List> row = src.get(rowIndex); - List group = row.get(colIndex); - group.add(value); - } - - for (int y = 0; y < size; y++) { - List> srcRow = src.get(y); - List> destRow = dest.get(y); - for (int x = 0; x < size; x++) { - List srcGroup = srcRow.get(x); - List destGroup = destRow.get(x); - if (srcGroup.isEmpty()) { - float fx = minX + (x / (float) maxIndex) * rangeX; - float fy = minY + (x / (float) maxIndex) * rangeY; - addClosest(values, destGroup, fx, fy, xFunc, yFunc); - } else { - destGroup.addAll(srcGroup); - } - } - } - - return create(dest, minX, minY, rangeX, rangeY); - } - - private static void addClosest(List source, List dest, float fx, float fy, Function xFunc, Function yFunc) { - float dist2 = Float.MAX_VALUE; - Map distances = new HashMap<>(); - for (T t : source) { - if (!distances.containsKey(t)) { - float dx = fx - xFunc.apply(t); - float dy = fy - yFunc.apply(t); - float d2 = dx * dx + dy * dy; - distances.put(t, d2); - if (d2 < dist2) { - dist2 = d2; - } - } - } - - if (dist2 <= 0) { - dist2 = 1F; - } - - List sorted = new ArrayList<>(distances.keySet()); - sorted.sort((o1, o2) -> Float.compare(distances.getOrDefault(o1, Float.MAX_VALUE), distances.getOrDefault(o2, Float.MAX_VALUE))); - - for (T t : sorted) { - float d2 = distances.get(t); - if (d2 / dist2 < 1.025F) { - dest.add(t); - } - } - } - - private static List createList(int size, Supplier supplier) { - List list = new ArrayList<>(); - while (list.size() < size) { - list.add(supplier.get()); - } - return list; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedList.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedList.java deleted file mode 100644 index 5224db5..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedList.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.grid; - -import me.dags.noise.util.NoiseUtil; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class FixedList implements Iterable { - - private final int maxIndex; - private final T[] elements; - - FixedList(T[] elements) { - this.maxIndex = elements.length - 1; - this.elements = elements; - } - - public T get(int index) { - if (index < 0) { - return elements[0]; - } - if (index > maxIndex) { - return elements[maxIndex]; - } - return elements[index]; - } - - public T get(float value) { - return get(indexOf(value)); - } - - public int size() { - return elements.length; - } - - public int indexOf(float value) { - return NoiseUtil.round(value * maxIndex); - } - - public Set uniqueValues() { - Set set = new HashSet<>(); - Collections.addAll(set, elements); - return set; - } - - @Override - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - @Override - public boolean hasNext() { - return index < elements.length; - } - - @Override - public T next() { - return elements[index++]; - } - }; - } - - @SuppressWarnings("unchecked") - public static FixedList of(List list) { - return new FixedList<>((T[]) list.toArray()); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/MappedList.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/MappedList.java deleted file mode 100644 index 1548782..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/MappedList.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.grid; - -import java.util.List; - -public class MappedList extends FixedList { - - private final float min; - private final float range; - - public MappedList(T[] elements, float min, float range) { - super(elements); - this.min = min; - this.range = range; - } - - @Override - public int indexOf(float value) { - return super.indexOf((value - min) / range); - } - - @SuppressWarnings("unchecked") - public static MappedList of(List list, float min, float range) { - return new MappedList<>((T[]) list.toArray(), min, range); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/points/Poisson.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/points/Poisson.java deleted file mode 100644 index cb277e6..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/points/Poisson.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.terraforged.core.util.points; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.region.Region; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.util.Vec2i; - -import javax.swing.*; -import java.awt.*; -import java.awt.image.BufferedImage; - -public class Poisson { - - public static void main(String[] args) { - Region region = new Region(0, 0, 5, 2); - BufferedImage image = new BufferedImage(region.getBlockSize().size, region.getBlockSize().size, BufferedImage.TYPE_INT_RGB); - points(region, 123,8, 20F, 0.8F); - render(region, image); - - JFrame frame = new JFrame(); - frame.add(new JLabel(new ImageIcon(image))); - frame.pack(); - frame.setVisible(true); - frame.setResizable(false); - frame.setLocationRelativeTo(null); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - } - - private static void points(Region region, int seed, int scale, float radius, float threshold) { - region.generate(chunk -> chunk.generate((cell, dx, dz) -> {})); - - Module noise = Source.simplex(seed, scale, 1); - - int gridSize = (int) Math.ceil(region.getBlockSize().size / radius); - Vec2i[][] grid = new Vec2i[gridSize][gridSize]; - - for (int dz = 0; dz < region.getBlockSize().size; dz++) { - for (int dx = 0; dx < region.getBlockSize().size; dx++) { - int x = region.getBlockX() + dx; - int z = region.getBlockZ() + dz; - float value = noise.getValue(x, z); - region.getCell(dx, dz).value = value; - if (true) continue; - - if (value > threshold) { - continue; - } - - int gridX = (int) (dx / radius); - int gridZ = (int) (dz / radius); - Vec2i point = grid[gridZ][gridX]; - - if (point != null) { - Cell current = region.getCell(point.x, point.y); - if (current.value > value) { - continue; - } - } - - region.getCell(dx, dz).value = value; - grid[gridZ][gridX] = new Vec2i(dx, dz); - } - } - } - - private static void render(Region region, BufferedImage image) { - region.iterate((cell, dx, dz) -> { - if (cell.value == 0) { - return; - } - int w = (int) (cell.value * 255); - image.setRGB(dx, dz, new Color(w, w, w).getRGB()); - }); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Comment.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Comment.java deleted file mode 100644 index e339c0c..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Comment.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.serialization.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Comment { - - String[] value(); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Name.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Name.java deleted file mode 100644 index ef32732..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Name.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.serialization.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Name { - - String value(); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Option.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Option.java deleted file mode 100644 index a1fc6d7..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Option.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.serialization.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Option { - -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Range.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Range.java deleted file mode 100644 index 44a0086..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Range.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.serialization.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Range { - - float min(); - - float max(); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Serializable.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Serializable.java deleted file mode 100644 index 3fd81ba..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/annotation/Serializable.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.serialization.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Serializable { -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Deserializer.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Deserializer.java deleted file mode 100644 index 49f899c..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Deserializer.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.serialization.serializer; - -import com.terraforged.core.util.serialization.annotation.Serializable; - -import java.lang.reflect.Array; -import java.lang.reflect.Field; - -public class Deserializer { - - public void deserialize(Reader reader, Object object) throws Throwable { - Class type = object.getClass(); - for (String name : reader.getKeys()) { - if (name.charAt(0) == '#') { - continue; - } - - try { - Reader child = reader.getChild(name); - Field field = type.getField(name); - if (Serializer.isSerializable(field)) { - field.setAccessible(true); - fromValue(child, object, field); - } - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } - } - } - - private void fromValue(Reader reader, Object object, Field field) throws Throwable { - if (field.getType() == int.class) { - field.set(object, reader.getInt("value")); - return; - } - if (field.getType() == float.class) { - field.set(object, reader.getFloat("value")); - return; - } - if (field.getType() == boolean.class) { - field.set(object, reader.getString("value").equals("true")); - return; - } - if (field.getType() == String.class) { - field.set(object, reader.getString("value")); - return; - } - if (field.getType().isEnum()) { - String name = reader.getString("value"); - for (Enum e : field.getType().asSubclass(Enum.class).getEnumConstants()) { - if (e.name().equals(name)) { - field.set(object, e); - return; - } - } - } - if (field.getType().isAnnotationPresent(Serializable.class)) { - Reader child = reader.getChild("value"); - Object value = field.getType().newInstance(); - deserialize(child, value); - field.set(object, value); - return; - } - if (field.getType().isArray()) { - Class type = field.getType().getComponentType(); - if (type.isAnnotationPresent(Serializable.class)) { - Reader child = reader.getChild("value"); - Object array = Array.newInstance(type, child.getSize()); - for (int i = 0; i < child.getSize(); i++) { - Object value = type.newInstance(); - deserialize(child.getChild(i), value); - Array.set(array, i, value); - } - field.set(object, array); - } - } - } - - private static String getName(String name) { - StringBuilder sb = new StringBuilder(name.length()); - for (int i = 0; i < name.length(); i++) { - char c = name.charAt(i); - if (i == 0) { - c = Character.toLowerCase(c); - } else if (c == ' ' && i + 1 < name.length()) { - c = Character.toUpperCase(name.charAt(++i)); - } - sb.append(c); - } - return sb.toString(); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Reader.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Reader.java deleted file mode 100644 index f7ff240..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Reader.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.serialization.serializer; - -import java.util.Collection; - -public interface Reader { - - int getSize(); - - Reader getChild(String key); - - Reader getChild(int index); - - Collection getKeys(); - - String getString(); - - boolean getBool(); - - float getFloat(); - - int getInt(); - - default String getString(String key) { - return getChild(key).getString(); - } - - default boolean getBool(String key) { - return getChild(key).getBool(); - } - - default float getFloat(String key) { - return getChild(key).getFloat(); - } - - default int getInt(String key) { - return getChild(key).getInt(); - } - - default String getString(int index) { - return getChild(index).getString(); - } - - default boolean getBool(int index) { - return getChild(index).getBool(); - } - - default float getFloat(int index) { - return getChild(index).getFloat(); - } - - default int getInt(int index) { - return getChild(index).getInt(); - } - - default void writeTo(Object object) throws Throwable { - new Deserializer().deserialize(this, object); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Serializer.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Serializer.java deleted file mode 100644 index 9891b89..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Serializer.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.serialization.serializer; - -import com.terraforged.core.util.serialization.annotation.Comment; -import com.terraforged.core.util.serialization.annotation.Name; -import com.terraforged.core.util.serialization.annotation.Range; -import com.terraforged.core.util.serialization.annotation.Serializable; - -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -public class Serializer { - - public void serialize(Object object, Writer writer) throws IllegalAccessException { - if (object.getClass().isArray()) { - writer.beginArray(); - int length = Array.getLength(object); - for (int i = 0; i < length; i++) { - Object element = Array.get(object, i); - serialize(element, writer); - } - writer.endArray(); - } else if (!object.getClass().isPrimitive()) { - int order = 0; - writer.beginObject(); - for (Field field : object.getClass().getFields()) { - if (Serializer.isSerializable(field)) { - field.setAccessible(true); - write(object, field, order, writer); - order++; - } - } - writer.endObject(); - } - } - - private void write(Object object, Field field, int order, Writer writer) throws IllegalAccessException { - if (field.getType() == int.class) { - writer.name(field.getName()); - writer.beginObject(); - writer.name("value").value((int) field.get(object)); - writeMeta(field, order, writer); - writer.endObject(); - return; - } - if (field.getType() == float.class) { - writer.name(field.getName()); - writer.beginObject(); - writer.name("value").value((float) field.get(object)); - writeMeta(field, order, writer); - writer.endObject(); - return; - } - if (field.getType() == String.class) { - writer.name(field.getName()); - writer.beginObject(); - writer.name("value").value((String) field.get(object)); - writeMeta(field, order, writer); - writer.endObject(); - return; - } - if (field.getType() == boolean.class) { - writer.name(field.getName()); - writer.beginObject(); - writer.name("value").value("" + (field.get(object))); - writeMeta(field, order, writer); - writer.endObject(); - } - if (field.getType().isEnum()) { - writer.name(field.getName()); - writer.beginObject(); - writer.name("value").value(((Enum) field.get(object)).name()); - writeMeta(field, order, writer); - writer.endObject(); - return; - } - if (field.getType().isArray()) { - if (field.getType().getComponentType().isAnnotationPresent(Serializable.class)) { - writer.name(field.getName()); - writer.beginObject(); - writer.name("value"); - serialize(field.get(object), writer); - writeMeta(field, order, writer); - writer.endObject(); - } - return; - } - if (field.getType().isAnnotationPresent(Serializable.class)) { - writer.name(field.getName()); - writer.beginObject(); - writer.name("value"); - serialize(field.get(object), writer); - writeMeta(field, order, writer); - writer.endObject(); - } - } - - private void writeMeta(Field field, int order, Writer writer) { - writer.name("#display").value(getName(field)); - writer.name("#order").value(order); - - Range range = field.getAnnotation(Range.class); - if (range != null) { - if (field.getType() == int.class) { - writer.name("#min").value((int) range.min()); - writer.name("#max").value((int) range.max()); - } else { - writer.name("#min").value(range.min()); - writer.name("#max").value(range.max()); - } - } - - Comment comment = field.getAnnotation(Comment.class); - if (comment != null) { - writer.name("#comment"); - writer.beginArray(); - for (String line : comment.value()) { - writer.value(line); - } - writer.endArray(); - } - - if (field.getType() == boolean.class) { - writer.name("#options"); - writer.beginArray(); - writer.value("true"); - writer.value("false"); - writer.endArray(); - } - - if (field.getType().isEnum()) { - writer.name("#options"); - writer.beginArray(); - for (Enum o : field.getType().asSubclass(Enum.class).getEnumConstants()) { - writer.value(o.name()); - } - writer.endArray(); - } - } - - private static String getName(Field field) { - Name nameMeta = field.getAnnotation(Name.class); - - String name = nameMeta == null ? field.getName() : nameMeta.value(); - StringBuilder sb = new StringBuilder(name.length() * 2); - for (int i = 0; i < name.length(); i++) { - char c = name.charAt(i); - if (i == 0) { - c = Character.toUpperCase(c); - } else if (Character.isUpperCase(c)) { - sb.append(' '); - } - - sb.append(c); - } - return sb.toString(); - } - - protected static boolean isSerializable(Field field) { - int modifiers = field.getModifiers(); - return Modifier.isPublic(modifiers) - && !Modifier.isFinal(modifiers) - && !Modifier.isStatic(modifiers) - && !Modifier.isTransient(modifiers); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Writer.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Writer.java deleted file mode 100644 index c9a566f..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/serialization/serializer/Writer.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.util.serialization.serializer; - -public interface Writer { - - Writer name(String name); - - Writer beginObject(); - - Writer endObject(); - - Writer beginArray(); - - Writer endArray(); - - Writer value(String value); - - Writer value(float value); - - Writer value(int value); - - default void readFrom(Object value) throws IllegalAccessException { - new Serializer().serialize(value, this); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/GeneratorContext.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/GeneratorContext.java deleted file mode 100644 index 832dacb..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/GeneratorContext.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world; - -import com.terraforged.core.settings.Settings; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrains; -import com.terraforged.core.world.terrain.provider.StandardTerrainProvider; -import com.terraforged.core.world.terrain.provider.TerrainProviderFactory; - -public class GeneratorContext { - - public final Seed seed; - public final Levels levels; - public final Terrains terrain; - public final Settings settings; - public final TerrainProviderFactory terrainFactory; - - public GeneratorContext(Terrains terrain, Settings settings) { - this(terrain, settings, StandardTerrainProvider::new); - } - - public GeneratorContext(Terrains terrain, Settings settings, TerrainProviderFactory terrainFactory) { - this.terrain = terrain; - this.settings = settings; - this.seed = new Seed(settings.generator.seed); - this.levels = new Levels(settings.generator); - this.terrainFactory = terrainFactory; - } - - private GeneratorContext(GeneratorContext src) { - seed = new Seed(src.seed.get()); - levels = src.levels; - terrain = src.terrain; - settings = src.settings; - terrainFactory = src.terrainFactory; - } - - public GeneratorContext copy() { - return new GeneratorContext(this); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java deleted file mode 100644 index 382300c..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world; - -import com.terraforged.core.world.decorator.Decorator; -import com.terraforged.core.world.decorator.DesertStacks; -import com.terraforged.core.world.decorator.Wetlands; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class WorldDecorators { - - private final List decorators; - - public WorldDecorators(GeneratorContext context) { - context = context.copy(); - List list = new ArrayList<>(); - list.add(new DesertStacks(context.seed, context.levels)); - list.add(new Wetlands(context.seed, context.terrain, context.levels)); - decorators = Collections.unmodifiableList(list); - } - - public List getDecorators() { - return decorators; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldFilters.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldFilters.java deleted file mode 100644 index b5f4d32..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldFilters.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world; - -import com.terraforged.core.filter.Erosion; -import com.terraforged.core.filter.Filterable; -import com.terraforged.core.filter.Smoothing; -import com.terraforged.core.filter.Steepness; -import com.terraforged.core.region.Region; -import com.terraforged.core.settings.FilterSettings; -import com.terraforged.core.world.terrain.Terrain; - -public class WorldFilters { - - private final Erosion erosion; - private final Smoothing smoothing; - private final Steepness steepness; - private final FilterSettings settings; - - public WorldFilters(GeneratorContext context) { - context = context.copy(); - this.settings = context.settings.filters; - this.erosion = new Erosion(context.settings, context.levels); - this.smoothing = new Smoothing(context.settings, context.levels); - this.steepness = new Steepness(1, 10F, context.terrain, context.levels); - } - - public void apply(Region region) { - Filterable map = region.filterable(); - erosion.apply(map, region.getRegionX(), region.getRegionZ(), settings.erosion.iterations); - smoothing.apply(map, region.getRegionX(), region.getRegionZ(), settings.smoothing.iterations); - steepness.apply(map, region.getRegionX(), region.getRegionZ(), 1); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldGenerator.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldGenerator.java deleted file mode 100644 index f750fb2..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldGenerator.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world; - -import com.terraforged.core.world.heightmap.Heightmap; - -public class WorldGenerator { - - private final Heightmap heightmap; - private final WorldFilters filters; - private final WorldDecorators decorators; - - public WorldGenerator(Heightmap heightmap, WorldDecorators decorators, WorldFilters filters) { - this.filters = filters; - this.heightmap = heightmap; - this.decorators = decorators; - } - - public Heightmap getHeightmap() { - return heightmap; - } - - public WorldFilters getFilters() { - return filters; - } - - public WorldDecorators getDecorators() { - return decorators; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldGeneratorFactory.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldGeneratorFactory.java deleted file mode 100644 index a0500ca..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldGeneratorFactory.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world; - -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.heightmap.Heightmap; -import com.terraforged.core.world.heightmap.WorldHeightmap; - -import java.util.function.Supplier; - -public class WorldGeneratorFactory implements Supplier { - - private final GeneratorContext context; - - private final Heightmap heightmap; - private final WorldDecorators decorators; - - public WorldGeneratorFactory(GeneratorContext context) { - this.context = context; - this.heightmap = new WorldHeightmap(context); - this.decorators = new WorldDecorators(context); - } - - public WorldGeneratorFactory(GeneratorContext context, Heightmap heightmap) { - this.context = context; - this.heightmap = heightmap; - this.decorators = new WorldDecorators(context); - } - - public Heightmap getHeightmap() { - return heightmap; - } - - public Climate getClimate() { - return getHeightmap().getClimate(); - } - - public WorldDecorators getDecorators() { - return decorators; - } - - public WorldFilters getFilters() { - return new WorldFilters(context); - } - - @Override - public WorldGenerator get() { - return new WorldGenerator(heightmap, decorators, getFilters()); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeData.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeData.java deleted file mode 100644 index 05d9682..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeData.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.biome; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class BiomeData implements Comparable { - - private static float[] bounds = {0, 1 / 3F, 2 / 3F, 1F}; - - public static final List BIOMES = new ArrayList<>(); - public static BiomeData DEFAULT = new BiomeData("none", "", 1, 0.5F, 0.5F); - - public final String name; - - public final Object reference; - public final float color; - public final float rainfall; - public final float temperature; - - public BiomeData(String name, Object reference, float color, float rainfall, float temperature) { - this.reference = reference; - this.name = name; - this.rainfall = rainfall; - this.temperature = temperature; - this.color = color; - } - - public BiomeData(String name, Object reference, int color, float rainfall, float temperature) { - Color c = new Color(color); - this.reference = reference; - this.name = name; - this.rainfall = rainfall; - this.temperature = temperature; - this.color = getHue(c.getRed(), c.getGreen(), c.getBlue()); - } - - @Override - public int compareTo(BiomeData o) { - return name.compareTo(o.name); - } - - public static Collection getBiomes(float temperature, float rainfall) { - int temp = Math.min(3, (int) (bounds.length * temperature)); - int rain = Math.min(3, (int) (bounds.length * rainfall)); - return getBiomes(temp, rain); - } - - public static Collection getBiomes(int tempLower, int rainLower) { - int temp0 = tempLower; - int temp1 = temp0 + 1; - int rain0 = rainLower; - int rain1 = rain0 + 1; - - float tempMin = bounds[temp0]; - float tempMax = bounds[temp1]; - float rainMin = bounds[rain0]; - float rainMax = bounds[rain1]; - - List biomes = new ArrayList<>(); - for (BiomeData biome : BIOMES) { - if (biome.temperature >= tempMin && biome.temperature <= tempMax - && biome.rainfall >= rainMin && biome.rainfall <= rainMax) { - biomes.add(biome); - } - } - - if (biomes.isEmpty()) { - biomes.add(DEFAULT); - } - - return biomes; - } - - public static Collection getTempBiomes(float temperature) { - int lower = Math.min(3, (int) (bounds.length * temperature)); - int upper = lower + 1; - - float min = bounds[lower]; - float max = bounds[upper]; - - List biomes = new ArrayList<>(); - for (BiomeData data : BIOMES) { - if (data.temperature >= min && data.temperature <= max) { - biomes.add(data); - } - } - - return biomes; - } - - public static Collection getRainBiomes(float rainfall) { - int lower = Math.min(3, (int) (bounds.length * rainfall)); - int upper = lower + 1; - - float min = bounds[lower]; - float max = bounds[upper]; - - List biomes = new ArrayList<>(); - for (BiomeData data : BIOMES) { - if (data.rainfall >= min && data.rainfall <= max) { - biomes.add(data); - } - } - - return biomes; - } - - private static float getHue(int red, int green, int blue) { - float min = Math.min(Math.min(red, green), blue); - float max = Math.max(Math.max(red, green), blue); - - if (min == max) { - return 0; - } - - float hue; - if (max == red) { - hue = (green - blue) / (max - min); - - } else if (max == green) { - hue = 2f + (blue - red) / (max - min); - - } else { - hue = 4f + (red - green) / (max - min); - } - - hue = hue * 60; - if (hue < 0) hue = hue + 360; - - return (Math.round(hue) / 360F) * 100F; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeManager.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeManager.java deleted file mode 100644 index 75e6310..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeManager.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.biome; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class BiomeManager { - - private final Map> biomes = new HashMap<>(); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeType.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeType.java deleted file mode 100644 index 9e04d36..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeType.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.biome; - -import com.terraforged.core.cell.Cell; -import me.dags.noise.util.NoiseUtil; - -import java.awt.*; - -public enum BiomeType { - - TROPICAL_RAINFOREST(7, 83, 48, new Color(7, 83, 48)), - SAVANNA(151, 165, 39, new Color(151, 165, 39)), - DESERT(200, 113, 55, new Color(200, 113, 55)), - TEMPERATE_RAINFOREST(10, 84, 109, new Color(10, 160, 65)), - TEMPERATE_FOREST(44, 137, 160, new Color(50, 200, 80)), - GRASSLAND(179, 124, 6, new Color(100, 220, 60)), - COLD_STEPPE(131, 112, 71, new Color(175, 180, 150)), - STEPPE(199, 155, 60, new Color(200, 200, 120)), - TAIGA(91, 143, 82, new Color(91, 143, 82)), - TUNDRA(147, 167, 172, new Color(147, 167, 172)), - ALPINE(0, 0, 0, new Color(160, 120, 170)); - - public static final int RESOLUTION = 256; - public static final int MAX = RESOLUTION - 1; - - private final Color lookup; - private final Color color; - - BiomeType(int r, int g, int b, Color color) { - this(new Color(r, g, b), color); - } - - BiomeType(Color lookup, Color color) { - this.lookup = lookup; - this.color = BiomeTypeColors.getInstance().getColor(name(), color); - } - - Color getLookup() { - return lookup; - } - - public Color getColor() { - return color; - } - - public boolean isExtreme() { - return this == TUNDRA || this == DESERT; - } - - public static BiomeType get(float temperature, float moisture) { - return getCurve(temperature, moisture); - } - - public static BiomeType getLinear(float temperature, float moisture) { - int x = NoiseUtil.round(MAX * temperature); - int y = getYLinear(x, temperature, moisture); - return getType(x, y); - } - - public static BiomeType getCurve(float temperature, float moisture) { - int x = NoiseUtil.round(MAX * temperature); - int y = getYCurve(x, temperature, moisture); - return getType(x, y); - } - - public static float getEdge(float temperature, float moisture) { - return getEdgeCurve(temperature, moisture); - } - - public static float getEdgeLinear(float temperature, float moisture) { - int x = NoiseUtil.round(MAX * temperature); - int y = getYLinear(x, temperature, moisture); - return getEdge(x, y); - } - - public static float getEdgeCurve(float temperature, float moisture) { - int x = NoiseUtil.round(MAX * temperature); - int y = getYCurve(x, temperature, moisture); - return getEdge(x, y); - } - - public static void apply(Cell cell) { - applyCurve(cell); - } - - public static void applyLinear(Cell cell) { - cell.biomeType = get(cell.biomeTemperature, cell.biomeMoisture); - cell.biomeTypeMask = getEdge(cell.temperature, cell.moisture); - } - - public static void applyCurve(Cell cell) { - cell.biomeType = get(cell.biomeTemperature, cell.biomeMoisture); - cell.biomeTypeMask = getEdge(cell.temperature, cell.moisture); - } - - private static BiomeType getType(int x, int y) { - return BiomeTypeLoader.getInstance().getTypeMap()[y][x]; - } - - private static float getEdge(int x, int y) { - return BiomeTypeLoader.getInstance().getEdgeMap()[y][x]; - } - - private static int getYLinear(int x, float temperature, float moisture) { - if (moisture > temperature) { - return x; - } - return NoiseUtil.round(MAX * moisture); - } - - private static int getYCurve(int x, float temperature, float moisture) { - int max = x + ((MAX - x) / 2); - int y = NoiseUtil.round(max * moisture); - return Math.min(x, y); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeTypeColors.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeTypeColors.java deleted file mode 100644 index 60b72d3..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeTypeColors.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.biome; - -import java.awt.*; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -public class BiomeTypeColors { - - private static BiomeTypeColors instance = new BiomeTypeColors(); - - private final Map colors = new HashMap<>(); - - private BiomeTypeColors() { - try (InputStream inputStream = BiomeType.class.getResourceAsStream("/biomes.txt")) { - Properties properties = new Properties(); - properties.load(inputStream); - for (Map.Entry entry : properties.entrySet()) { - Color color = Color.decode("#" + entry.getValue().toString()); - colors.put(entry.getKey().toString(), color); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - public Color getColor(String name, Color defaultColor) { - return colors.getOrDefault(name, defaultColor); - } - - public static BiomeTypeColors getInstance() { - return instance; - } - - public static void main(String[] args) throws Throwable { - try (FileWriter writer = new FileWriter("biome_colors.properties")) { - Properties properties = new Properties(); - for (BiomeType type : BiomeType.values()) { - int r = type.getColor().getRed(); - int g = type.getColor().getGreen(); - int b = type.getColor().getBlue(); - properties.setProperty(type.name(), String.format("%02x%02x%02x", r, g, b)); - } - properties.store(writer, "TerraForged BiomeType Hex Colors (do not include hash/pound character)"); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeTypeLoader.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeTypeLoader.java deleted file mode 100644 index 010855e..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/biome/BiomeTypeLoader.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.biome; - -import me.dags.noise.util.NoiseUtil; - -import javax.imageio.ImageIO; -import javax.swing.*; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; - -public class BiomeTypeLoader { - - private static BiomeTypeLoader instance; - - private final float[][] edges = new float[BiomeType.RESOLUTION][BiomeType.RESOLUTION]; - private final BiomeType[][] map = new BiomeType[BiomeType.RESOLUTION][BiomeType.RESOLUTION]; - - public BiomeTypeLoader() { - generateTypeMap(); - generateEdgeMap(); - } - - public BiomeType[][] getTypeMap() { - return map; - } - - public float[][] getEdgeMap() { - return edges; - } - - private BiomeType getType(int x, int y) { - return map[y][x]; - } - - private void generateTypeMap() { - try { - BufferedImage image = ImageIO.read(BiomeType.class.getResourceAsStream("/biomes.png")); - float xf = image.getWidth() / (float) BiomeType.RESOLUTION; - float yf = image.getHeight() / (float) BiomeType.RESOLUTION; - for (int y = 0; y < BiomeType.RESOLUTION; y++) { - for (int x = 0; x < BiomeType.RESOLUTION; x++) { - if (BiomeType.MAX - y > x) { - map[BiomeType.MAX - y][x] = BiomeType.ALPINE; - continue; - } - int ix = NoiseUtil.round(x * xf); - int iy = NoiseUtil.round(y * yf); - int argb = image.getRGB(ix, iy); - Color color = fromARGB(argb); - map[BiomeType.MAX - y][x] = forColor(color); - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private void generateEdgeMap() { - int[] distances = new int[BiomeType.values().length]; - for (int y = 0; y < BiomeType.RESOLUTION; y++) { - for (int x = 0; x < BiomeType.RESOLUTION; x++) { - if (y > x) continue; - BiomeType type = getType(x, y); - if (type == BiomeType.ALPINE) { - continue; - } - int distance2 = getEdge(x, y, type); - edges[y][x] = distance2; - distances[type.ordinal()] = Math.max(distances[type.ordinal()], distance2); - } - } - - for (int y = 0; y < BiomeType.RESOLUTION; y++) { - for (int x = 0; x < BiomeType.RESOLUTION; x++) { - BiomeType type = getType(x, y); - int max = distances[type.ordinal()]; - float distance = edges[y][x]; - float value = NoiseUtil.pow(distance / max, 0.33F); - edges[y][x] = NoiseUtil.clamp(value, 0, 1); - } - } - } - - private int getEdge(int cx, int cy, BiomeType type) { - int radius = BiomeType.RESOLUTION / 4; - int distance2 = Integer.MAX_VALUE; - int x0 = Math.max(0, cx - radius); - int x1 = Math.min(BiomeType.MAX, cx + radius); - int y0 = Math.max(0, cy - radius); - int y1 = Math.min(BiomeType.MAX, cy + radius); - for (int y = y0; y <= y1; y++) { - for (int x = x0; x <= x1; x++) { - BiomeType neighbour = getType(x, y); - - if (neighbour == BiomeType.ALPINE) { - continue; - } - - if (neighbour != type) { - int dist2 = dist2(cx, cy, x, y); - if (dist2 < distance2) { - distance2 = dist2; - } - } - } - } - return distance2; - } - - private static BiomeType forColor(Color color) { - BiomeType type = null; - int closest = Integer.MAX_VALUE; - for (BiomeType t : BiomeType.values()) { - int distance2 = getDistance2(color, t.getLookup()); - if (distance2 < closest) { - closest = distance2; - type = t; - } - } - if (type == null) { - return BiomeType.GRASSLAND; - } - return type; - } - - private static int getDistance2(Color a, Color b) { - int dr = a.getRed() - b.getRed(); - int dg = a.getGreen() - b.getGreen(); - int db = a.getBlue() - b.getBlue(); - return dr * dr + dg * dg + db * db; - } - - private static Color fromARGB(int argb) { - int b = (argb) & 0xFF; - int g = (argb >> 8) & 0xFF; - int r = (argb >> 16) & 0xFF; - return new Color(r, g, b); - } - - private static int dist2(int x1, int y1, int x2, int y2) { - int dx = x1 - x2; - int dy = y1 - y2; - return dx * dx + dy * dy; - } - - private static BufferedImage generateEdgeMapImage() { - BufferedImage image = new BufferedImage(BiomeType.RESOLUTION, BiomeType.RESOLUTION, BufferedImage.TYPE_INT_RGB); - for (int y = 0; y < BiomeType.RESOLUTION; y++) { - for (int x = 0; x < BiomeType.RESOLUTION; x++) { - float temperature = x / (float) BiomeType.RESOLUTION; - float moisture = y / (float) BiomeType.RESOLUTION; - float value = BiomeType.getEdge(temperature, moisture); - int color = Color.HSBtoRGB(0, 0, value); - image.setRGB(x, image.getHeight() - 1 - y, color); - } - } - return image; - } - - public static BiomeTypeLoader getInstance() { - if (instance == null) { - instance = new BiomeTypeLoader(); - } - return instance; - } - - public static void main(String[] args) throws Throwable { - BufferedImage img = generateEdgeMapImage(); - ImageIO.write(img, "png", new File("biomes_dist.png")); - JLabel label = new JLabel(new ImageIcon(img)); - JFrame frame = new JFrame(); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.add(label); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/Climate.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/Climate.java deleted file mode 100644 index 4a52538..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/Climate.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.climate; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.source.Rand; - -public class Climate { - - private final float seaLevel; - private final float lowerHeight; - private final float midHeight = 0.45F; - private final float upperHeight = 0.75F; - - private final float moistureModifier = 0.1F; - private final float temperatureModifier = 0.05F; - - private final Rand rand; - private final Module treeLine; - private final Module offsetX; - private final Module offsetY; - - private final ClimateModule biomeNoise; - - public Climate(GeneratorContext context) { - this.biomeNoise = new ClimateModule(context.seed, context.settings); - - this.treeLine = Source.perlin(context.seed.next(), context.settings.generator.biome.biomeSize * 2, 1) - .scale(context.levels.scale(25)) // 30 units worth of variance - .bias(context.levels.ground(40)) // start at-least 30 units above ground level - .clamp(0, 1); - - this.rand = new Rand(Source.builder().seed(context.seed.next())); - this.offsetX = context.settings.generator.biomeEdgeNoise.build(context.seed.next()); - this.offsetY = context.settings.generator.biomeEdgeNoise.build(context.seed.next()); - this.seaLevel = context.levels.water; - this.lowerHeight = context.levels.ground; - } - - public Rand getRand() { - return rand; - } - - public float getOffsetX(float x, float z, int distance) { - return offsetX.getValue(x, z) * distance; - } - - public float getOffsetZ(float x, float z, int distance) { - return offsetY.getValue(x, z) * distance; - } - - public float getTreeLine(float x, float z) { - return treeLine.getValue(x, z); - } - - public void apply(Cell cell, float x, float z, boolean mask) { - biomeNoise.apply(cell, x, z, mask); - - modifyTemp(cell, x, z); - } - - private void modifyTemp(Cell cell, float x, float z) { - float height = cell.value; - if (height > upperHeight) { - cell.temperature = Math.max(0, cell.temperature - temperatureModifier); - return; - } - - // temperature decreases away from 'midHeight' towards 'upperHeight' - if (height > midHeight) { - float delta = (height - midHeight) / (upperHeight - midHeight); - cell.temperature = Math.max(0, cell.temperature - (delta * temperatureModifier)); - return; - } - - height = Math.max(lowerHeight, height); - - // temperature increases away from 'midHeight' towards 'lowerHeight' - if (height >= lowerHeight) { - float delta = 1 - ((height - lowerHeight) / (midHeight - lowerHeight)); - cell.temperature = Math.min(1, cell.temperature + (delta * temperatureModifier)); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java deleted file mode 100644 index 4530609..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.climate; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.settings.Settings; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.biome.BiomeType; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.func.DistanceFunc; -import me.dags.noise.func.EdgeFunc; -import me.dags.noise.util.NoiseUtil; -import me.dags.noise.util.Vec2f; - -public class ClimateModule { - - private final int seed; - - private final float edgeClamp; - private final float edgeScale; - private final float biomeFreq; - private final float warpStrength; - - private final Module warpX; - private final Module warpZ; - private final Module moisture; - private final Module temperature; - - public ClimateModule(Seed seed, Settings settings) { - int biomeSize = settings.generator.biome.biomeSize; - - // todo - better solution (reduces the amount that temp/moist grows with biome size) - int tempScaler = biomeSize > 500 ? 8 : 10; - int moistScaler = biomeSize > 500 ? 20 : 40; - - float biomeFreq = 1F / biomeSize; - int moistureSize = moistScaler * biomeSize; - int temperatureSize = tempScaler * biomeSize; - int moistScale = NoiseUtil.round(moistureSize * biomeFreq); - int tempScale = NoiseUtil.round(temperatureSize * biomeFreq); - int warpScale = settings.generator.biome.biomeWarpScale; - - this.seed = seed.next(); - this.edgeClamp = 1F; - this.edgeScale = 1 / edgeClamp; - this.biomeFreq = 1F / biomeSize; - this.warpStrength = settings.generator.biome.biomeWarpStrength; - this.warpX = Source.perlin(seed.next(), warpScale, 2).bias(-0.5); - this.warpZ = Source.perlin(seed.next(), warpScale, 2).bias(-0.5); - - Module moisture = Source.simplex(seed.next(), moistScale, 2).clamp(0.15, 0.85).map(0, 1); - this.moisture = settings.climate.moisture.clamp(moisture) - .warp(seed.next(), moistScale / 2, 1, moistScale / 4D) - .warp(seed.next(), moistScale / 6, 2, moistScale / 12D); - - Module temperature = Source.sin(tempScale, Source.constant(0.9)) - .clamp(0.05, 0.95).map(0, 1); - - this.temperature = new Compressor(settings.climate.temperature.clamp(temperature), 0.1F, 0.2F) - .warp(seed.next(), tempScale * 4, 2, tempScale * 4) - .warp(seed.next(), tempScale, 1, tempScale) - .warp(seed.next(), tempScale / 8, 1, tempScale / 8D); - } - - public void apply(Cell cell, float x, float y, boolean mask) { - float ox = warpX.getValue(x, y) * warpStrength; - float oz = warpZ.getValue(x, y) * warpStrength; - - x += ox; - y += oz; - - x *= biomeFreq; - y *= biomeFreq; - - int cellX = 0; - int cellY = 0; - - Vec2f vec2f = null; - int xr = NoiseUtil.round(x); - int yr = NoiseUtil.round(y); - float edgeDistance = 999999.0F; - float edgeDistance2 = 999999.0F; - float valueDistance = 3.4028235E38F; - DistanceFunc dist = DistanceFunc.NATURAL; - - for (int dy = -1; dy <= 1; dy++) { - for (int dx = -1; dx <= 1; dx++) { - int xi = xr + dx; - int yi = yr + dy; - Vec2f vec = NoiseUtil.CELL_2D[NoiseUtil.hash2D(seed, xi, yi) & 255]; - - float vecX = xi - x + vec.x; - float vecY = yi - y + vec.y; - float distance = dist.apply(vecX, vecY); - - if (distance < valueDistance) { - valueDistance = distance; - vec2f = vec; - cellX = xi; - cellY = yi; - } - - if (distance < edgeDistance2) { - edgeDistance2 = Math.max(edgeDistance, distance); - } else { - edgeDistance2 = Math.max(edgeDistance, edgeDistance2); - } - - edgeDistance = Math.min(edgeDistance, distance); - } - } - - if (mask) { - cell.biomeEdge = edgeValue(edgeDistance, edgeDistance2); - } else { - cell.biome = cellValue(seed, cellX, cellY); - cell.biomeEdge = edgeValue(edgeDistance, edgeDistance2); - cell.biomeMoisture = moisture.getValue(cellX + vec2f.x, cellY + vec2f.y); - cell.biomeTemperature = temperature.getValue(cellX + vec2f.x, cellY + vec2f.y); - cell.moisture = moisture.getValue(x, y); - cell.temperature = temperature.getValue(x, y); - - BiomeType.apply(cell); - } - } - - private float cellValue(int seed, int cellX, int cellY) { - float value = NoiseUtil.valCoord2D(seed, cellX, cellY); - return NoiseUtil.map(value, -1, 1, 2); - } - - private float edgeValue(float distance, float distance2) { - EdgeFunc edge = EdgeFunc.DISTANCE_2_DIV; - float value = edge.apply(distance, distance2); - value = 1 - NoiseUtil.map(value, edge.min(), edge.max(), edge.range()); - if (value > edgeClamp) { - return 1F; - } - return value * edgeScale; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/Compressor.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/Compressor.java deleted file mode 100644 index 6c14475..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/Compressor.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.climate; - -import me.dags.noise.Module; - -public class Compressor implements Module { - - private final float lowerStart; - private final float lowerEnd; - private final float lowerRange; - private final float lowerExpandRange; - - private final float upperStart; - private final float upperEnd; - private final float upperRange; - private final float upperExpandedRange; - - private final float compression; - private final float compressionRange; - - private final Module module; - - public Compressor(Module module, float inset, float amount) { - this(module, inset, inset + amount, 1 - inset - amount, 1 - inset); - } - - public Compressor(Module module, float lowerStart, float lowerEnd, float upperStart, float upperEnd) { - this.module = module; - this.lowerStart = lowerStart; - this.lowerEnd = lowerEnd; - this.lowerRange = lowerStart; - this.lowerExpandRange = lowerEnd; - this.upperStart = upperStart; - this.upperEnd = upperEnd; - this.upperRange = 1 - upperEnd; - this.upperExpandedRange = 1 - upperStart; - this.compression = upperStart - lowerEnd; - this.compressionRange = upperEnd - lowerStart; - } - - @Override - public float getValue(float x, float y) { - float value = module.getValue(x, y); - if (value <= lowerStart) { - float alpha = value / lowerRange; - return alpha * lowerExpandRange; - } else if (value >= upperEnd) { - float delta = value - upperEnd; - float alpha = delta / upperRange; - return upperStart + alpha * upperExpandedRange; - } else { - float delta = value - lowerStart; - float alpha = delta / compressionRange; - return lowerEnd + alpha * compression; - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentLerper2.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentLerper2.java deleted file mode 100644 index 0d7954e..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentLerper2.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.continent; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.func.Interpolation; -import me.dags.noise.util.NoiseUtil; - -public class ContinentLerper2 implements Populator { - - private final Populator lower; - private final Populator upper; - - private final float blendLower; - private final float blendUpper; - private final float blendRange; - private final float midpoint; - private final float tagThreshold; - - public ContinentLerper2(Populator lower, Populator upper, float min, float max, float split, float tagThreshold) { - this.lower = lower; - this.upper = upper; - this.blendLower = min; - this.blendUpper = max; - this.blendRange = blendUpper - blendLower; - this.midpoint = blendLower + (blendRange * split); - this.tagThreshold = tagThreshold; - } - - @Override - public void apply(Cell cell, float x, float y) { - float select = cell.continentEdge; - - if (select < blendLower) { - lower.apply(cell, x, y); - return; - } - - if (select > blendUpper) { - upper.apply(cell, x, y); - return; - } - - float alpha = Interpolation.LINEAR.apply((select - blendLower) / blendRange); - lower.apply(cell, x, y); - - float lowerVal = cell.value; - Terrain lowerType = cell.tag; - - upper.apply(cell, x, y); - float upperVal = cell.value; - - cell.value = NoiseUtil.lerp(lowerVal, upperVal, alpha); - if (select < midpoint) { - cell.tag = lowerType; - } - } - - @Override - public void tag(Cell cell, float x, float y) { - float select = cell.continentEdge; - if (select < blendLower) { - lower.tag(cell, x, y); - return; - } - - if (select > blendUpper) { - upper.tag(cell, x, y); - return; - } - - if (select < tagThreshold) { - lower.tag(cell, x, y); - } else { - upper.tag(cell, x, y); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentLerper3.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentLerper3.java deleted file mode 100644 index 06252dd..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentLerper3.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.continent; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.func.Interpolation; -import me.dags.noise.util.NoiseUtil; - -public class ContinentLerper3 implements Populator { - - private final Climate climate; - private final Populator lower; - private final Populator middle; - private final Populator upper; - private final float midpoint; - - private final float blendLower; - private final float blendUpper; - - private final float lowerRange; - private final float upperRange; - - public ContinentLerper3(Climate climate, Populator lower, Populator middle, Populator upper, float min, float mid, float max) { - this.climate = climate; - this.lower = lower; - this.upper = upper; - this.middle = middle; - - this.midpoint = mid; - this.blendLower = min; - this.blendUpper = max; - - this.lowerRange = midpoint - blendLower; - this.upperRange = blendUpper - midpoint; - } - - @Override - public void apply(Cell cell, float x, float y) { - float select = cell.continentEdge; - if (select < blendLower) { - lower.apply(cell, x, y); - return; - } - - if (select > blendUpper) { - upper.apply(cell, x, y); - return; - } - - if (select < midpoint) { - float alpha = Interpolation.CURVE3.apply((select - blendLower) / lowerRange); - - lower.apply(cell, x, y); - float lowerVal = cell.value; - Terrain lowerType = cell.tag; - - middle.apply(cell, x, y); - float upperVal = cell.value; - - cell.value = NoiseUtil.lerp(lowerVal, upperVal, alpha); - } else { - float alpha = Interpolation.CURVE3.apply((select - midpoint) / upperRange); - - middle.apply(cell, x, y); - float lowerVal = cell.value; - - upper.apply(cell, x, y); - cell.value = NoiseUtil.lerp(lowerVal, cell.value, alpha); - } - } - - @Override - public void tag(Cell cell, float x, float y) { - float select = cell.continentEdge; - if (select < blendLower) { - lower.tag(cell, x, y); - return; - } - - if (select > blendUpper) { - upper.tag(cell, x, y); - return; - } - - if (select < midpoint) { - lower.tag(cell, x, y); - if (cell.value > cell.tag.getMax(climate.getRand().getValue(x, y))) { - upper.tag(cell, x, y); - } - } else { - upper.tag(cell, x, y); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentModule.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentModule.java deleted file mode 100644 index 7773245..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentModule.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.continent; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; -import com.terraforged.core.settings.GeneratorSettings; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.domain.Domain; -import me.dags.noise.func.DistanceFunc; -import me.dags.noise.func.EdgeFunc; -import me.dags.noise.util.NoiseUtil; -import me.dags.noise.util.Vec2f; - -public class ContinentModule implements Populator { - - private static final float edgeClampMin = 0.05F; - private static final float edgeClampMax = 0.50F; - private static final float edgeClampRange = edgeClampMax - edgeClampMin; - - private final int seed; - private final float frequency; - - private final float edgeMin; - private final float edgeMax; - private final float edgeRange; - - private final Domain warp; - private final Module shape; - - public ContinentModule(Seed seed, GeneratorSettings settings) { - int tectonicScale = settings.land.continentScale * 4; - int continentScale = settings.land.continentScale / 2; - double oceans = Math.min(Math.max(settings.world.oceanSize, 0.01), 0.99); - double shapeMin = 0.15 + (oceans * 0.35); - this.seed = seed.next(); - - this.frequency = 1F / tectonicScale; - this.edgeMin = edgeClampMin; - this.edgeMax = (float) oceans; - this.edgeRange = edgeMax - edgeMin; - - this.warp = Domain.warp(Source.SIMPLEX, seed.next(), continentScale, 3, continentScale); - - this.shape = Source.perlin(seed.next(), settings.land.continentScale, 2) - .clamp(shapeMin, 0.7) - .map(0, 1) - .warp(Source.SIMPLEX, seed.next(), continentScale / 2, 1, continentScale / 4D) - .warp(seed.next(), 50, 1, 20D); - } - - @Override - public float getValue(float x, float y) { - if (true) { - throw new RuntimeException("no pls!"); - } else { - Cell cell = new Cell<>(); - apply(cell, x, y); - return cell.continentEdge; - } - } - - @Override - public void apply(Cell cell, final float x, final float y) { - float ox = warp.getOffsetX(x, y); - float oz = warp.getOffsetY(x, y); - - float px = x + ox; - float py = y + oz; - - px *= frequency; - py *= frequency; - - int cellX = 0; - int cellY = 0; - - int xr = NoiseUtil.round(px); - int yr = NoiseUtil.round(py); - float edgeDistance = 999999.0F; - float edgeDistance2 = 999999.0F; - float valueDistance = 3.4028235E38F; - DistanceFunc dist = DistanceFunc.NATURAL; - - for (int dy = -1; dy <= 1; dy++) { - for (int dx = -1; dx <= 1; dx++) { - int xi = xr + dx; - int yi = yr + dy; - Vec2f vec = NoiseUtil.CELL_2D[NoiseUtil.hash2D(seed, xi, yi) & 255]; - - float vecX = xi - px + vec.x; - float vecY = yi - py + vec.y; - float distance = dist.apply(vecX, vecY); - - if (distance < valueDistance) { - valueDistance = distance; - cellX = xi; - cellY = yi; - } - - if (distance < edgeDistance2) { - edgeDistance2 = Math.max(edgeDistance, distance); - } else { - edgeDistance2 = Math.max(edgeDistance, edgeDistance2); - } - - edgeDistance = Math.min(edgeDistance, distance); - } - } - - - float shapeNoise = shape.getValue(x, y); - float continentNoise = edgeValue(edgeDistance, edgeDistance2); - - cell.continent = cellValue(seed, cellX, cellY); - cell.continentEdge = shapeNoise * continentNoise; - } - - @Override - public void tag(Cell cell, float x, float y) { - - } - - private float cellValue(int seed, int cellX, int cellY) { - float value = NoiseUtil.valCoord2D(seed, cellX, cellY); - return NoiseUtil.map(value, -1, 1, 2); - } - - private float edgeValue(float distance, float distance2) { - EdgeFunc edge = EdgeFunc.DISTANCE_2_DIV; - float value = edge.apply(distance, distance2); - float edgeValue = 1 - NoiseUtil.map(value, edge.min(), edge.max(), edge.range()); - if (edgeValue < edgeMin) { - return 0F; - } - if (edgeValue > edgeMax) { - return 1F; - } - return (edgeValue - edgeMin) / edgeRange; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/Decorator.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/Decorator.java deleted file mode 100644 index df92f3b..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/Decorator.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.decorator; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; - -public interface Decorator { - - boolean apply(Cell cell, float x, float y); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/DesertDunes.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/DesertDunes.java deleted file mode 100644 index 21ad1c8..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/DesertDunes.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.decorator; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.func.CellFunc; - -public class DesertDunes implements Decorator { - - private final Module module; - private final float climateMin; - private final float climateMax; - private final float climateRange; - - private final Levels levels; - private final Terrains terrains; - private final Terrain dunes = new Terrain("dunes", 100); - - public DesertDunes(GeneratorContext context) { - this.climateMin = 0.6F; - this.climateMax = 0.85F; - this.climateRange = climateMax - climateMin; - this.levels = context.levels; - this.terrains = context.terrain; - this.module = Source.cell(context.seed.next(), 80, CellFunc.DISTANCE) - .warp(context.seed.next(), 70, 1, 70) - .scale(30 / 255D); - } - - @Override - public boolean apply(Cell cell, float x, float y) { - float temp = cell.temperature; - float moisture = 1 - cell.moisture; - float climate = temp * moisture; - if (climate < climateMin) { - return false; - } - - float duneHeight = module.getValue(x, y); - float climateMask = climate > climateMax ? 1F : (climate - climateMin) / climateRange; - float regionMask = cell.mask(0.4F, 0.5F, 0,0.8F); - - float height = duneHeight * climateMask * regionMask; - cell.value += height; - cell.tag = dunes; - - return height >= levels.unit; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/DesertStacks.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/DesertStacks.java deleted file mode 100644 index 8896675..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/DesertStacks.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.decorator; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.biome.BiomeType; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.Module; -import me.dags.noise.Source; - -public class DesertStacks implements Decorator { - - private final float minY; - private final float maxY; - private final Levels levels; - private final Module module; - - public DesertStacks(Seed seed, Levels levels) { - Module mask = Source.perlin(seed.next(), 500, 1).clamp(0.7, 1).map(0, 1); - - Module shape = Source.perlin(seed.next(), 25, 1).clamp(0.6, 1).map(0, 1) - .mult(Source.perlin(seed.next(), 8, 1).alpha(0.1)); - - Module top = Source.perlin(seed.next(), 4, 1).alpha(0.25); - - Module scale = Source.perlin(seed.next(), 400, 1) - .clamp(levels.scale(20), levels.scale(35)); - - Module stack = (x, y) -> { - float value = shape.getValue(x, y); - if (value > 0.3) { - return top.getValue(x, y); - } - return value * 0.95F; - }; - - this.minY = levels.water(0); - this.maxY = levels.water(50); - this.levels = levels; - this.module = stack.scale(scale).mult(mask); - } - - @Override - public boolean apply(Cell cell, float x, float y) { - if (BiomeType.DESERT != cell.biomeType) { - return false; - } - - if (cell.value <= minY || cell.value > maxY) { - return false; - } - - float value = module.getValue(x, y); - value *= cell.biomeEdge; - cell.value += value; - - return value > levels.unit; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/Wetlands.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/Wetlands.java deleted file mode 100644 index 661d3cc..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/decorator/Wetlands.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.decorator; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.util.NoiseUtil; - -public class Wetlands implements Decorator { - - private final Module module; - private final float poolBase; - private final float bankHeight; - - private final Terrain wetlands; - - public Wetlands(Seed seed, Terrains terrain, Levels levels) { - this.wetlands = terrain.wetlands; - this.poolBase = levels.water(-3); - this.bankHeight = levels.water(2); - this.module = Source.perlin(seed.next(), 12, 1).clamp(0.35, 0.65).map(0, 1); - } - - @Override - public boolean apply(Cell cell, float x, float y) { - if (cell.value < poolBase) { - return false; - } - - float tempAlpha = getAlpha(cell.temperature, 0.3F, 0.7F); - if (tempAlpha == 0) { - return false; - } - - float moistAlpha = getAlpha(cell.moisture, 0.7F, 1F); - if (moistAlpha == 0) { - return false; - } - - float riverAlpha = getAlpha(1 - cell.riverMask, 0.85F, 0.95F); - if (riverAlpha == 0) { - return false; - } - - float alpha = tempAlpha * moistAlpha * riverAlpha; - float value1 = NoiseUtil.lerp(cell.value, bankHeight, alpha); - cell.value = Math.min(cell.value, value1); - - float poolAlpha = getAlpha(alpha, 0.35F, 0.55F); - float shape = module.getValue(x, y); - float value2 = NoiseUtil.lerp(cell.value, poolBase, shape * poolAlpha); - cell.value = Math.min(cell.value, value2); - - if (poolAlpha > 0.5) { - cell.tag = wetlands; - } - - return true; - } - - private static float getAlpha(float value, float min, float max) { - return getAlpha(value, min, max, false); - } - - private static float getAlpha(float value, float min, float max, boolean inverse) { - if (value < min) { - return 0F; - } - if (value >= max) { - return 1F; - } - float alpha = (value - min) / (max - min); - if (inverse) { - return 1F - alpha; - } - return alpha; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/DepthBuffer.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/DepthBuffer.java deleted file mode 100644 index 3188790..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/DepthBuffer.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.terraforged.core.world.geology; - -public class DepthBuffer { - - private float sum; - private float[] buffer; - - public void init(int size) { - sum = 0F; - if (buffer == null || buffer.length < size) { - buffer = new float[size]; - } - } - - public float getSum() { - return sum; - } - - public float get(int index) { - return buffer[index]; - } - - public float getDepth(int index) { - return buffer[index] / sum; - } - - public void set(int index, float value) { - sum += value; - buffer[index] = value; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Geology.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Geology.java deleted file mode 100644 index fd7345c..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Geology.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.geology; - -import me.dags.noise.Module; - -import java.util.ArrayList; -import java.util.List; - -public class Geology { - - private final Module selector; - private final List> backing = new ArrayList<>(); - - public Geology(Module selector) { - this.selector = selector; - } - - public Geology add(Geology geology) { - backing.addAll(geology.backing); - return this; - } - - public Geology add(Strata strata) { - backing.add(strata); - return this; - } - - public Strata getStrata(float x, int y) { - float noise = selector.getValue(x, y); - return getStrata(noise); - } - - public Strata getStrata(float value) { - int index = (int) (value * backing.size()); - index = Math.min(backing.size() - 1, index); - return backing.get(index); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Strata.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Strata.java deleted file mode 100644 index 1ba7be4..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Strata.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.geology; - -import com.terraforged.core.util.Seed; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.util.NoiseUtil; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -public class Strata { - - private final Module heightMod; - private final List> strata; - - private Strata(Module heightMod, List> strata) { - this.strata = strata; - this.heightMod = heightMod; - } - - public boolean downwards(final int x, final int y, final int z, final Stratum.Visitor visitor) { - DepthBuffer buffer = new DepthBuffer(); - initBuffer(buffer, x, z); - return downwards(x, y, z, buffer, visitor); - } - - public boolean downwards(final int x, final int y, final int z, final DepthBuffer buffer, Stratum.Visitor visitor) { - initBuffer(buffer, x, z); - - int py = y; - T last = null; - for (int i = 0; i < strata.size(); i++) { - float depth = buffer.getDepth(i); - int height = NoiseUtil.round(depth * y); - T value = strata.get(i).getValue(); - last = value; - for (int dy = 0; dy < height; dy++) { - if (py <= y) { - boolean cont = visitor.visit(py, value); - if (!cont) { - return false; - } - } - if (--py < 0) { - return false; - } - } - } - if (last != null) { - while (py > 0) { - visitor.visit(py, last); - py--; - } - } - return true; - } - - private int getYOffset(int x, int z) { - return (int) (64 * heightMod.getValue(x, z)); - } - - private void initBuffer(DepthBuffer buffer, int x, int z) { - buffer.init(strata.size()); - for (int i = 0; i < strata.size(); i++) { - float depth = strata.get(i).getDepth(x, z); - buffer.set(i, depth); - } - } - - public static Builder builder(int seed, me.dags.noise.source.Builder noise) { - return new Builder<>(seed, noise); - } - - public static class Builder { - - private final Seed seed; - private final me.dags.noise.source.Builder noise; - private final List> strata = new LinkedList<>(); - - public Builder(int seed, me.dags.noise.source.Builder noise) { - this.seed = new Seed(seed); - this.noise = noise; - } - - public Builder add(T material, double depth) { - Module module = noise.seed(seed.next()).perlin().scale(depth); - strata.add(Stratum.of(material, module)); - return this; - } - - public Builder add(Source type, T material, double depth) { - Module module = noise.seed(seed.next()).build(type).scale(depth); - strata.add(Stratum.of(material, module)); - return this; - } - - public Strata build() { - Module height = Source.cell(seed.next(), 100); - return new Strata<>(height, new ArrayList<>(strata)); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Stratum.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Stratum.java deleted file mode 100644 index c51ab6e..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Stratum.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.geology; - -import me.dags.noise.Module; -import me.dags.noise.Source; - -public class Stratum { - - private final T value; - private final Module depth; - - public Stratum(T value, double depth) { - this(value, Source.constant(depth)); - } - - public Stratum(T value, Module depth) { - this.depth = depth; - this.value = value; - } - - public T getValue() { - return value; - } - - public float getDepth(float x, float z) { - return depth.getValue(x, z); - } - - public static Stratum of(T t, double depth) { - return new Stratum<>(t, depth); - } - - public static Stratum of(T t, Module depth) { - return new Stratum<>(t, depth); - } - - public interface Visitor { - - boolean visit(int y, T value); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Heightmap.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Heightmap.java deleted file mode 100644 index a9c176f..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Heightmap.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.heightmap; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Extent; -import com.terraforged.core.cell.Populator; -import com.terraforged.core.region.Size; -import com.terraforged.core.util.concurrent.ObjectPool; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.rivermap.RiverMap; -import com.terraforged.core.world.rivermap.RiverRegionList; -import com.terraforged.core.world.terrain.Terrain; - -public interface Heightmap extends Populator, Extent { - - Climate getClimate(); - - RiverMap getRiverMap(); - - void visit(Cell cell, float x, float z); - - void applyBase(Cell cell, float x, float z); - - void applyRivers(Cell cell, float x, float z, RiverRegionList rivers); - - void applyClimate(Cell cell, float x, float z); - - @Override - default void visit(int minX, int minZ, int maxX, int maxZ, Cell.Visitor visitor) { - int chunkSize = Size.chunkToBlock(1); - - int chunkMinX = Size.blockToChunk(minX); - int chunkMinZ = Size.blockToChunk(minZ); - int chunkMaxX = Size.blockToChunk(maxX); - int chunkMaxZ = Size.blockToChunk(maxZ); - - try (ObjectPool.Item> cell = Cell.pooled()) { - for (int chunkZ = chunkMinZ; chunkZ <= chunkMaxZ; chunkZ++) { - for (int chunkX = chunkMinX; chunkX <= chunkMaxX; chunkX++) { - int chunkStartX = Size.chunkToBlock(chunkX); - int chunkStartZ = Size.chunkToBlock(chunkZ); - for (int dz = 0; dz < chunkSize; dz++) { - for (int dx = 0; dx < chunkSize; dx++) { - int x = chunkStartX + dx; - int z = chunkStartZ + dz; - apply(cell.getValue(), x, z); - if (x >= minX && x < maxX && z >= minZ && z < maxZ) { - int relX = x - minX; - int relZ = z - minZ; - visitor.visit(cell.getValue(), relX, relZ); - } - } - } - } - } - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Levels.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Levels.java deleted file mode 100644 index bc1f6a6..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Levels.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.heightmap; - -import com.terraforged.core.settings.GeneratorSettings; -import me.dags.noise.util.NoiseUtil; - -public class Levels { - - public final int worldHeight; - - public final float unit; - - // y index of the top-most water block - public final int waterY; - private final int groundY; - - // top of the first ground block (ie 1 above ground index) - public final int groundLevel; - // top of the top-most water block (ie 1 above water index) - public final int waterLevel; - - // ground index mapped between 0-1 (default 63 / 256) - public final float ground; - // water index mapped between 0-1 (default 62 / 256) - public final float water; - - public Levels(GeneratorSettings settings) { - worldHeight = Math.max(1, settings.world.worldHeight); - unit = NoiseUtil.div(1, worldHeight); - - waterLevel = settings.world.seaLevel; - groundLevel = waterLevel + 1; - - waterY = Math.min(waterLevel - 1, worldHeight); - groundY = Math.min(groundLevel - 1, worldHeight); - - ground = NoiseUtil.div(groundY, worldHeight); - water = NoiseUtil.div(waterY, worldHeight); - } - - public int scale(float value) { - if (value >= 1F) { - return worldHeight - 1; - } - return (int) (value * worldHeight); - } - - public float scale(int level) { - return NoiseUtil.div(level, worldHeight); - } - - public float water(int amount) { - return NoiseUtil.div(waterY + amount, worldHeight); - } - - public float ground(int amount) { - return NoiseUtil.div(groundY + amount, worldHeight); - } - - public static float getSeaLevel(GeneratorSettings settings) { - int worldHeight = Math.max(1, settings.world.worldHeight); - int waterLevel = Math.min(settings.world.seaLevel, worldHeight); - return NoiseUtil.div(waterLevel, worldHeight); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/RegionConfig.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/RegionConfig.java deleted file mode 100644 index 800bd95..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/RegionConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.heightmap; - -import me.dags.noise.Module; - -public class RegionConfig { - - public final int seed; - public final int scale; - public final Module warpX; - public final Module warpZ; - public final double warpStrength; - - public RegionConfig(int seed, int scale, Module warpX, Module warpZ, double warpStrength) { - this.seed = seed; - this.scale = scale; - this.warpX = warpX; - this.warpZ = warpZ; - this.warpStrength = warpStrength; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/RegionExtent.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/RegionExtent.java deleted file mode 100644 index 78134ac..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/RegionExtent.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.heightmap; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Extent; -import com.terraforged.core.region.Region; -import com.terraforged.core.region.Size; -import com.terraforged.core.region.chunk.ChunkReader; -import com.terraforged.core.world.terrain.Terrain; - -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -public interface RegionExtent extends Extent { - - int chunkToRegion(int coord); - - Region getRegion(int regionX, int regionZ); - - CompletableFuture getRegionAsync(int regionX, int regionZ); - - default ChunkReader getChunk(int chunkX, int chunkZ) { - int regionX = chunkToRegion(chunkX); - int regionZ = chunkToRegion(chunkZ); - Region region = getRegion(regionX, regionZ); - return region.getChunk(chunkX, chunkZ); - } - - default List> getRegions(int minRegionX, int minRegionZ, int maxRegionX, int maxRegionZ) { - List> regions = new LinkedList<>(); - for (int rz = minRegionZ; rz <= maxRegionZ; rz++) { - for (int rx = minRegionX; rx <= maxRegionX; rx++) { - regions.add(getRegionAsync(rx, rz)); - } - } - return regions; - } - - @Override - default void visit(int minX, int minZ, int maxX, int maxZ, Cell.Visitor visitor) { - int minRegionX = chunkToRegion(Size.blockToChunk(minX)); - int minRegionZ = chunkToRegion(Size.blockToChunk(minZ)); - int maxRegionX = chunkToRegion(Size.blockToChunk(maxX)); - int maxRegionZ = chunkToRegion(Size.blockToChunk(maxZ)); - List> regions = getRegions(minRegionX, minRegionZ, maxRegionX, maxRegionZ); - while (!regions.isEmpty()) { - regions.removeIf(future -> { - if (!future.isDone()) { - return false; - } - Region region = future.join(); - region.visit(minX, minZ, maxX, maxZ, visitor); - return true; - }); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java deleted file mode 100644 index 2ecdb4c..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.heightmap; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; -import com.terraforged.core.module.Blender; -import com.terraforged.core.settings.GeneratorSettings; -import com.terraforged.core.settings.Settings; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.continent.ContinentLerper2; -import com.terraforged.core.world.continent.ContinentLerper3; -import com.terraforged.core.world.continent.ContinentModule; -import com.terraforged.core.world.rivermap.RiverMap; -import com.terraforged.core.world.rivermap.RiverRegionList; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.TerrainPopulator; -import com.terraforged.core.world.terrain.Terrains; -import com.terraforged.core.world.terrain.provider.TerrainProvider; -import com.terraforged.core.world.terrain.region.RegionLerper; -import com.terraforged.core.world.terrain.region.RegionModule; -import com.terraforged.core.world.terrain.region.RegionSelector; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.func.EdgeFunc; -import me.dags.noise.func.Interpolation; - -public class WorldHeightmap implements Heightmap { - - private static final float DEEP_OCEAN_VALUE = 0.2F; - private static final float OCEAN_VALUE = 0.3F; - private static final float BEACH_VALUE = 0.34F; - private static final float COAST_VALUE = 0.4F; - private static final float INLAND_VALUE = 0.6F; - - private final Levels levels; - private final Terrains terrain; - private final Settings settings; - - private final Populator continentModule; - private final Populator regionModule; - - private final Climate climate; - private final Populator root; - private final RiverMap riverMap; - private final TerrainProvider terrainProvider; - - public WorldHeightmap(GeneratorContext context) { - context = context.copy(); - - this.levels = context.levels; - this.terrain = context.terrain; - this.settings = context.settings; - this.climate = new Climate(context); - - Seed seed = context.seed; - Levels levels = context.levels; - GeneratorSettings genSettings = context.settings.generator; - - Seed regionSeed = seed.nextSeed(); - Seed regionWarp = seed.nextSeed(); - - int regionWarpScale = 400; - int regionWarpStrength = 200; - RegionConfig regionConfig = new RegionConfig( - regionSeed.get(), - context.settings.generator.land.regionSize, - Source.simplex(regionWarp.next(), regionWarpScale, 1), - Source.simplex(regionWarp.next(), regionWarpScale, 1), - regionWarpStrength - ); - - regionModule = new RegionModule(regionConfig); - - // controls where mountain chains form in the world - Module mountainShapeBase = Source.cellEdge(seed.next(), genSettings.land.mountainScale, EdgeFunc.DISTANCE_2_ADD) - .add(Source.cubic(seed.next(), genSettings.land.mountainScale, 1).scale(-0.05)); - - // sharpens the transition to create steeper mountains - Module mountainShape = mountainShapeBase - .curve(Interpolation.CURVE3) - .clamp(0, 0.9) - .map(0, 1); - - terrainProvider = context.terrainFactory.create(context, regionConfig, this); - - // the voronoi controlled terrain regions - Populator terrainRegions = new RegionSelector(terrainProvider.getPopulators()); - // the terrain type at region edges - Populator terrainRegionBorders = new TerrainPopulator(terrainProvider.getLandforms().plains(seed), context.terrain.steppe); - - // transitions between the unique terrain regions and the common border terrain - Populator terrain = new RegionLerper(terrainRegionBorders, terrainRegions); - - // mountain populator - Populator mountains = register(terrainProvider.getLandforms().mountains(seed), context.terrain.mountains); - - // controls what's ocean and what's land - continentModule = new ContinentModule(seed, settings.generator); - - // blends between normal terrain and mountain chains - Populator land = new Blender( - mountainShape, - terrain, - mountains, - 0.1F, - 0.9F, - 0.6F - ); - - // uses the continent noise to blend between deep ocean, to ocean, to coast - ContinentLerper3 oceans = new ContinentLerper3( - climate, - register(terrainProvider.getLandforms().deepOcean(seed.next()), context.terrain.deepOcean), - register(Source.constant(levels.water(-7)), context.terrain.ocean), - register(Source.constant(levels.water), context.terrain.coast), - DEEP_OCEAN_VALUE, // below == deep, above == transition to shallow - OCEAN_VALUE, // below == transition to deep, above == transition to coast - COAST_VALUE // below == transition to shallow, above == coast - ); - - // blends between the ocean/coast terrain and land terrains - root = new ContinentLerper2( - oceans, - land, - OCEAN_VALUE, // below == pure ocean - INLAND_VALUE, // above == pure land - COAST_VALUE, // split point - COAST_VALUE - 0.05F - ); - - riverMap = new RiverMap(this, context); - } - - @Override - public void visit(Cell cell, float x, float z) { - continentModule.apply(cell, x, z); - regionModule.apply(cell, x, z); - root.apply(cell, x, z); - } - - @Override - public void apply(Cell cell, float x, float z) { - applyBase(cell, x, z); - applyRivers(cell, x, z, riverMap.getRivers((int) x, (int) z)); - applyClimate(cell, x, z); - } - - @Override - public void applyBase(Cell cell, float x, float z) { - // initial type - cell.tag = terrain.steppe; - // basic shapes - continentModule.apply(cell, x, z); - regionModule.apply(cell, x, z); - // apply actual heightmap - root.apply(cell, x, z); - } - - @Override - public void applyRivers(Cell cell, float x, float z, RiverRegionList rivers) { - rivers.apply(cell, x, z); - } - - @Override - public void applyClimate(Cell cell, float x, float z) { - // apply climate data - if (cell.value <= levels.water) { - climate.apply(cell, x, z, false); - if (cell.tag == terrain.coast) { - cell.tag = terrain.ocean; - } - } else { - int range = settings.generator.biomeEdgeNoise.strength; - float dx = climate.getOffsetX(x, z, range); - float dz = climate.getOffsetZ(x, z, range); - float px = x + dx; - float pz = z + dz; - tag(cell, px, pz); - climate.apply(cell, px, pz, false); - climate.apply(cell, x, z, true); - } - } - - @Override - public void tag(Cell cell, float x, float z) { - continentModule.apply(cell, x, z); - regionModule.apply(cell, x, z); - root.tag(cell, x, z); - } - - public Climate getClimate() { - return climate; - } - - @Override - public RiverMap getRiverMap() { - return riverMap; - } - - public Populator getPopulator(Terrain terrain) { - return terrainProvider.getPopulator(terrain); - } - - private TerrainPopulator register(Module module, Terrain terrain) { - TerrainPopulator populator = new TerrainPopulator(module, terrain); - terrainProvider.registerMixable(populator); - return populator; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldLookup.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldLookup.java deleted file mode 100644 index 5d629d7..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldLookup.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.terraforged.core.world.heightmap; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.WorldDecorators; -import com.terraforged.core.world.WorldGeneratorFactory; -import com.terraforged.core.world.decorator.Decorator; -import com.terraforged.core.world.terrain.Terrain; - -public class WorldLookup { - - private final float waterLevel; - private final float beachLevel; - private final Heightmap heightmap; - private final WorldDecorators decorators; - private final GeneratorContext context; - - public WorldLookup(WorldGeneratorFactory factory, GeneratorContext context) { - this.context = context; - this.heightmap = factory.getHeightmap(); - this.decorators = factory.getDecorators(); - this.waterLevel = context.levels.water; - this.beachLevel = context.levels.water(5); - } - - public Cell getCell(int x, int z) { - Cell cell = new Cell<>(); - applyCell(cell, x, z); - return cell; - } - - public void applyCell(Cell cell, int x, int z) { - heightmap.apply(cell, x, z); - - // approximation - actual beaches depend on steepness but that's too expensive to calculate - if (cell.tag == context.terrain.coast && cell.value > waterLevel && cell.value <= beachLevel) { - cell.tag = context.terrain.beach; - } - - for (Decorator decorator : decorators.getDecorators()) { - if (decorator.apply(cell, x, z)) { - break; - } - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/PosGenerator.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/PosGenerator.java deleted file mode 100644 index fba5b62..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/PosGenerator.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.rivermap; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.heightmap.Heightmap; -import com.terraforged.core.world.rivermap.river.RiverNode; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.domain.Domain; -import me.dags.noise.util.Vec2i; - -import java.util.Random; - -/** - * Generates random positions within (length / 4) of one of the 4 corners of a region. - * The first position generated will be near any of the four corners - * The second position generated will be near any of the 3 remaining corners to ensure a reasonable distance to the first - */ -public class PosGenerator { - - private final int size; - private final int quadSize; - private final Vec2i[] quads = new Vec2i[4]; - - private final int padding; - private final Domain domain; - private final Cell lookup; - private final Heightmap heightmap; - - private int i; - private int dx; - private int dz; - - public PosGenerator(Heightmap heightmap, Domain domain, Cell lookup, int size, int padding) { - this.domain = domain; - this.lookup = lookup; - this.padding = padding; - this.heightmap = heightmap; - this.size = size; - this.quadSize = (size - (padding * 2)) / 4; - int x1 = 0; - int y1 = 0; - int x2 = 3 * quadSize; - int y2 = 3 * quadSize; - quads[index(0, 0)] = new Vec2i(x1, y1); - quads[index(1, 0)] = new Vec2i(x2, y1); - quads[index(0, 1)] = new Vec2i(x1, y2); - quads[index(1, 1)] = new Vec2i(x2, y2); - } - - private void nextSeed(Random random) { - int index = random.nextInt(4); - Vec2i vec = quads[index]; - i = index; - dx = padding + vec.x + random.nextInt(quadSize); - dz = padding + vec.y + random.nextInt(quadSize); - } - - private void nextPos(Random random) { - int steps = 1 + random.nextInt(3); - int index = (i + steps) & 3; - Vec2i vec = quads[index]; - i = index; - dx = padding + vec.x + random.nextInt(quadSize); - dz = padding + vec.y + random.nextInt(quadSize); - } - - public RiverNode next(int x, int z, Random random, int attempts) { - for (int i = 0; i < attempts; i++) { - nextSeed(random); - int px = x + dx; - int pz = z + dz; - int wx = (int) domain.getX(px, pz); - int wz = (int) domain.getY(px, pz); - float value1 = getHeight(px, pz); - float value2 = getHeight(wx, wz); - RiverNode.Type type1 = RiverNode.getType(value1); - RiverNode.Type type2 = RiverNode.getType(value2); - if (type1 == type2 && type1 != RiverNode.Type.NONE) { - if (type1 == RiverNode.Type.END) { - return new RiverNode(wx, wz, type1); - } - return new RiverNode(px, pz, type1); - } - } - return null; - } - - public RiverNode nextFrom(int x, int z, Random random, int attempts, RiverNode point, int mindDist2) { - for (int i = 0; i < attempts; i++) { - nextPos(random); - int px = x + dx; - int pz = z + dz; - if (dist2(px, pz, point.x, point.z) < mindDist2) { - continue; - } - int wx = (int) domain.getX(px, pz); - int wz = (int) domain.getY(px, pz); - float value1 = getHeight(px, pz); - float value2 = getHeight(wx, wz); - RiverNode.Type type1 = RiverNode.getType(value1); - RiverNode.Type type2 = RiverNode.getType(value2); - if (type1 == type2 && type1 == point.type.opposite()) { - if (type1 == RiverNode.Type.END) { - return new RiverNode(wx, wz, type1); - } - return new RiverNode(px, pz, type1); - } - } - return null; - } - - public RiverNode nextRelaxed(int x, int z, Random random, int attempts) { - for (int i = 0; i < attempts; i++) { - int px = x + random.nextInt(size); - int pz = z + random.nextInt(size); - int wx = (int) domain.getX(px, pz); - int wz = (int) domain.getY(px, pz); - float value1 = getHeight(px, pz); - float value2 = getHeight(wx, wz); - RiverNode.Type type1 = RiverNode.getType(value1); - RiverNode.Type type2 = RiverNode.getType(value2); - if (type1 == type2 && type1 != RiverNode.Type.NONE) { - if (type1 == RiverNode.Type.END) { - return new RiverNode(wx, wz, type1); - } - return new RiverNode(px, pz, type1); - } - } - return null; - } - - public RiverNode nextFromRelaxed(int x, int z, Random random, int attempts, RiverNode point, int mindDist2) { - for (int i = 0; i < attempts; i++) { - int px = x + random.nextInt(size); - int pz = z + random.nextInt(size); - if (dist2(px, pz, point.x, point.z) < mindDist2) { - continue; - } - int wx = (int) domain.getX(px, pz); - int wz = (int) domain.getY(px, pz); - float value1 = getHeight(px, pz); - float value2 = getHeight(wx, wz); - RiverNode.Type type1 = RiverNode.getType(value1); - RiverNode.Type type2 = RiverNode.getType(value2); - if (type1 == type2 && type1 == point.type.opposite()) { - if (type1 == RiverNode.Type.END) { - return new RiverNode(wx, wz, type1); - } - return new RiverNode(px, pz, type1); - } - } - return null; - } - - public RiverNode nextType(int x, int z, Random random, int attempts, RiverNode.Type match) { - for (int i = 0; i < attempts; i++) { - nextSeed(random); - int px = x + dx; - int pz = z + dz; - int wx = (int) domain.getX(px, pz); - int wz = (int) domain.getY(px, pz); - float value1 = getHeight(px, pz); - float value2 = getHeight(wx, wz); - RiverNode.Type type1 = RiverNode.getType(value1); - RiverNode.Type type2 = RiverNode.getType(value2); - if (type1 == type2 && type1 == match) { - return new RiverNode(px, pz, type1); - } - } - return null; - } - - public RiverNode nextMinHeight(int x, int z, Random random, int attempts, float minHeight) { - for (int i = 0; i < attempts; i++) { - nextPos(random); - int px = x + dx; - int pz = z + dz; - int wx = (int) domain.getX(px, pz); - int wz = (int) domain.getY(px, pz); - float value1 = getHeight(px, pz); - float value2 = getHeight(wx, wz); - if (value1 > minHeight && value2 > minHeight) { - return new RiverNode(px, pz, RiverNode.Type.START); - } - } - return null; - } - - public float getHeight(int x, int z) { - heightmap.visit(lookup, x, z); - return lookup.value; - } - - private static int index(int x, int z) { - return z * 2 + x; - } - - private static float dist2(int x1, int y1, int x2, int y2) { - float dx = x2 - x1; - float dy = y2 - y1; - return dx * dx + dy * dy; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/RiverMap.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/RiverMap.java deleted file mode 100644 index c79f54a..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/RiverMap.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.rivermap; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.region.Region; -import com.terraforged.core.util.concurrent.ThreadPool; -import com.terraforged.core.util.concurrent.cache.Cache; -import com.terraforged.core.util.concurrent.cache.CacheEntry; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.heightmap.Heightmap; -import com.terraforged.core.world.rivermap.lake.LakeConfig; -import com.terraforged.core.world.rivermap.river.RiverConfig; -import com.terraforged.core.world.rivermap.river.RiverRegion; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.util.NoiseUtil; - -import java.util.concurrent.TimeUnit; - -public class RiverMap { - - private static final int QUAD_SIZE = (1 << RiverRegion.SCALE) / 2; - - private final Heightmap heightmap; - private final GeneratorContext context; - private final RiverMapConfig riverMapConfig; - private final Cache> cache; - private final ThreadPool threadPool = ThreadPool.getPool(); - - public RiverMap(Heightmap heightmap, GeneratorContext context) { - RiverConfig primary = RiverConfig.builder(context.levels) - .bankHeight(context.settings.rivers.primaryRivers.minBankHeight, context.settings.rivers.primaryRivers.maxBankHeight) - .bankWidth(context.settings.rivers.primaryRivers.bankWidth) - .bedWidth(context.settings.rivers.primaryRivers.bedWidth) - .bedDepth(context.settings.rivers.primaryRivers.bedDepth) - .fade(context.settings.rivers.primaryRivers.fade) - .length(2500) - .main(true) - .build(); - RiverConfig secondary = RiverConfig.builder(context.levels) - .bankHeight(context.settings.rivers.secondaryRiver.minBankHeight, context.settings.rivers.secondaryRiver.maxBankHeight) - .bankWidth(context.settings.rivers.secondaryRiver.bankWidth) - .bedWidth(context.settings.rivers.secondaryRiver.bedWidth) - .bedDepth(context.settings.rivers.secondaryRiver.bedDepth) - .fade(context.settings.rivers.secondaryRiver.fade) - .length(1000) - .build(); - RiverConfig tertiary = RiverConfig.builder(context.levels) - .bankHeight(context.settings.rivers.tertiaryRivers.minBankHeight, context.settings.rivers.tertiaryRivers.maxBankHeight) - .bankWidth(context.settings.rivers.tertiaryRivers.bankWidth) - .bedWidth(context.settings.rivers.tertiaryRivers.bedWidth) - .bedDepth(context.settings.rivers.tertiaryRivers.bedDepth) - .fade(context.settings.rivers.tertiaryRivers.fade) - .length(500) - .build(); - LakeConfig lakes = LakeConfig.of(context.settings.rivers.lake, context.levels); - - this.heightmap = heightmap; - this.context = context; - this.riverMapConfig = new RiverMapConfig(context.settings.rivers.riverFrequency, primary, secondary, tertiary, lakes); - this.cache = new Cache<>(3, 1, TimeUnit.MINUTES); - } - - public RiverRegionList getRivers(Region region) { - RiverRegionList rivers = new RiverRegionList(); - getRivers(region.getBlockX(), region.getBlockZ(), rivers); - return rivers; - } - - public RiverRegionList getRivers(int blockX, int blockZ) { - RiverRegionList rivers = new RiverRegionList(); - getRivers(blockX, blockZ, rivers); - return rivers; - } - - public void getRivers(Region region, RiverRegionList rivers) { - getRivers(region.getBlockX(), region.getBlockZ(), rivers); - } - - public void getRivers(int blockX, int blockZ, RiverRegionList rivers) { - int rx = RiverRegion.blockToRegion(blockX); - int rz = RiverRegion.blockToRegion(blockZ); - - // check which quarter of the region pos (x,y) is in & get the neighbouring regions' relative coords - int qx = blockX < RiverRegion.regionToBlock(rx) + QUAD_SIZE ? -1 : 1; - int qz = blockZ < RiverRegion.regionToBlock(rz) + QUAD_SIZE ? -1 : 1; - - // relative positions of neighbouring regions - int minX = Math.min(0, qx); - int minZ = Math.min(0, qz); - int maxX = Math.max(0, qx); - int maxZ = Math.max(0, qz); - - rivers.reset(); - for (int dz = minZ; dz <= maxZ; dz++) { - for (int dx = minX; dx <= maxX; dx++) { - rivers.add(getRegion(rx + dx, rz + dz)); - } - } - } - - public void apply(Cell cell, float x, float z) { - RiverRegionList rivers = new RiverRegionList(); - getRivers((int) x, (int) z, rivers); - rivers.apply(cell, x, z); - } - - private CacheEntry getRegion(int rx, int rz) { - long id = NoiseUtil.seed(rx, rz); - return cache.computeIfAbsent(id, l -> generateRegion(rx, rz)); - } - - private CacheEntry generateRegion(int rx, int rz) { - return CacheEntry.supplyAsync(() -> new RiverRegion(rx, rz, heightmap, context, riverMapConfig), threadPool); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/RiverMapConfig.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/RiverMapConfig.java deleted file mode 100644 index 957fedc..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/RiverMapConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.terraforged.core.world.rivermap; - -import com.terraforged.core.world.rivermap.lake.LakeConfig; -import com.terraforged.core.world.rivermap.river.RiverConfig; - -public class RiverMapConfig { - - public final float frequency; - public final RiverConfig primary; - public final RiverConfig secondary; - public final RiverConfig tertiary; - public final LakeConfig lakes; - - public RiverMapConfig(float frequency, RiverConfig primary, RiverConfig secondary, RiverConfig tertiary, LakeConfig lakes) { - this.frequency = frequency; - this.primary = primary; - this.secondary = secondary; - this.tertiary = tertiary; - this.lakes = lakes; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/RiverRegionList.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/RiverRegionList.java deleted file mode 100644 index 9cdbc1c..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/RiverRegionList.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.terraforged.core.world.rivermap; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.util.concurrent.cache.CacheEntry; -import com.terraforged.core.world.rivermap.river.RiverRegion; -import com.terraforged.core.world.terrain.Terrain; - -import java.util.Arrays; - -public class RiverRegionList { - - private int index = 0; - private final CacheEntry[] regions = new CacheEntry[4]; - - protected void add(CacheEntry entry) { - if (index < regions.length) { - regions[index] = entry; - index++; - } - } - - protected void reset() { - index = 0; - } - - public void clear() { - Arrays.fill(regions, null); - } - - public void apply(Cell cell, float x, float z) { - for (CacheEntry entry : regions) { - entry.get().apply(cell, x, z); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/lake/Lake.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/lake/Lake.java deleted file mode 100644 index c41b639..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/lake/Lake.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.rivermap.lake; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.rivermap.river.River; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.TerrainPopulator; -import com.terraforged.core.world.terrain.Terrains; -import me.dags.noise.Source; -import me.dags.noise.util.NoiseUtil; -import me.dags.noise.util.Vec2f; - -public class Lake extends TerrainPopulator { - - private static final int VALLEY_2 = River.VALLEY_WIDTH * River.VALLEY_WIDTH; - - private final float lakeDistance2; - private final float valleyDistance2; - private final float bankAlphaMin; - private final float bankAlphaMax; - private final float bankAlphaRange; - private final Vec2f center; - private final LakeConfig config; - private final Terrains terrains; - - public Lake(Vec2f center, float radius, LakeConfig config, Terrains terrains) { - super(Source.ZERO, terrains.lake); - this.center = center; - this.config = config; - this.bankAlphaMin = config.bankMin; - this.bankAlphaMax = Math.min(1, bankAlphaMin + 0.275F); - this.bankAlphaRange = bankAlphaMax - bankAlphaMin; - this.lakeDistance2 = radius * radius; - this.valleyDistance2 = VALLEY_2 - lakeDistance2; - this.terrains = terrains; - } - - @Override - public void apply(Cell cell, float x, float z) { - float distance2 = getDistance2(x, z); - if (distance2 > VALLEY_2) { - return; - } - - float bankHeight = getBankHeight(cell); - if (distance2 > lakeDistance2) { - if (cell.value < bankHeight) { - return; - } - float valleyAlpha = 1F - ((distance2 - lakeDistance2) / valleyDistance2); - cell.value = NoiseUtil.lerp(cell.value, bankHeight, valleyAlpha); - return; - } - - cell.value = Math.min(bankHeight, cell.value); - - if (distance2 < lakeDistance2) { - float depthAlpha = 1F - (distance2 / lakeDistance2); - float lakeDepth = Math.min(cell.value, config.depth); - cell.value = NoiseUtil.lerp(cell.value, lakeDepth, depthAlpha); - cell.tag = terrains.lake; - } - } - - @Override - public void tag(Cell cell, float x, float z) { - cell.tag = terrains.lake; - } - - private float getDistance2(float x, float z) { - float dx = center.x - x; - float dz = center.y - z; - return (dx * dx + dz * dz); - } - - private float getBankHeight(Cell cell) { - // scale bank height based on elevation of the terrain (higher terrain == taller banks) - float bankHeightAlpha = NoiseUtil.map(cell.value, bankAlphaMin, bankAlphaMax, bankAlphaRange); - // lerp between the min and max heights - return NoiseUtil.lerp(config.bankMin, config.bankMax, bankHeightAlpha); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/lake/LakeConfig.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/lake/LakeConfig.java deleted file mode 100644 index 49c7f82..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/lake/LakeConfig.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.rivermap.lake; - -import com.terraforged.core.settings.RiverSettings; -import com.terraforged.core.world.heightmap.Levels; - -public class LakeConfig { - - public final float depth; - public final float chance; - public final float sizeMin; - public final float sizeMax; - public final float bankMin; - public final float bankMax; - public final float distanceMin; - public final float distanceMax; - - private LakeConfig(Builder builder) { - depth = builder.depth; - chance = builder.chance; - sizeMin = builder.sizeMin; - sizeMax = builder.sizeMax; - bankMin = builder.bankMin; - bankMax = builder.bankMax; - distanceMin = builder.distanceMin; - distanceMax = builder.distanceMax; - } - - public static LakeConfig of(RiverSettings.Lake settings, Levels levels) { - Builder builder = new Builder(); - builder.chance = settings.chance; - builder.sizeMin = settings.sizeMin; - builder.sizeMax = settings.sizeMax; - builder.depth = levels.water(-settings.depth); - builder.distanceMin = settings.minStartDistance; - builder.distanceMax = settings.maxStartDistance; - builder.bankMin = levels.water(settings.minBankHeight); - builder.bankMax = levels.water(settings.maxBankHeight); - return new LakeConfig(builder); - } - - public static class Builder { - public float chance; - public float depth = 10; - public float sizeMin = 30; - public float sizeMax = 100; - public float bankMin = 1; - public float bankMax = 8; - public float distanceMin = 0.025F; - public float distanceMax = 0.05F; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/River.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/River.java deleted file mode 100644 index 6ff08c9..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/River.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.rivermap.river; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.TerrainPopulator; -import com.terraforged.core.world.terrain.Terrains; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.source.Line; -import me.dags.noise.util.NoiseUtil; - -public class River extends TerrainPopulator { - - public static final int VALLEY_WIDTH = 275; - protected static final float DEPTH_FADE_STRENGTH = 0.5F; - - public final boolean main; - private final boolean connecting; - - private final float bedHeight; - - private final float minBankHeight; - private final float maxBankHeight; - private final float bankAlphaMin; - private final float bankAlphaMax; - private final float bankAlphaRange; - private final Module bankVariance; - - private final Line bed; - private final Line banks; - private final Line valley; - public final RiverConfig config; - public final RiverBounds bounds; - - private final Terrains terrains; - - private final float depthFadeBias; - - public River(RiverBounds bounds, RiverConfig config, Terrains terrains, double fadeIn, double fadeOut) { - this(bounds, config, terrains, fadeIn, fadeOut, false); - } - - public River(RiverBounds bounds, RiverConfig config, Terrains terrains, double fadeIn, double fadeOut, boolean connecting) { - super(Source.ZERO, terrains.river); - Module in = Source.constant(fadeIn); - Module out = Source.constant(fadeOut); - Module bedWidth = Source.constant(config.bedWidth * config.bedWidth); - Module bankWidth = Source.constant(config.bankWidth * config.bankWidth); - Module valleyWidth = Source.constant(VALLEY_WIDTH * VALLEY_WIDTH); - this.bounds = bounds; - this.config = config; - this.main = config.main; - this.terrains = terrains; - this.connecting = connecting; - this.bedHeight = config.bedHeight; - this.minBankHeight = config.minBankHeight; - this.maxBankHeight = config.maxBankHeight; - this.bankAlphaMin = minBankHeight; - this.bankAlphaMax = Math.min(1, minBankHeight + 0.35F); - this.bankAlphaRange = bankAlphaMax - bankAlphaMin; - this.bankVariance = Source.perlin(1234, 150, 1); - this.depthFadeBias = 1 - DEPTH_FADE_STRENGTH; - this.bed = Source.line(bounds.x1(), bounds.y1(), bounds.x2(), bounds.y2(), bedWidth, in, out, 0.1F); - this.banks = Source.line(bounds.x1(), bounds.y1(), bounds.x2(), bounds.y2(), bankWidth, in, out, 0.1F); - this.valley = Source.line(bounds.x1(), bounds.y1(), bounds.x2(), bounds.y2(), valleyWidth, Source.ZERO, Source.ZERO, 0.33F); - } - - @Override - public void apply(Cell cell, float x, float z) { - if (cell.value <= bedHeight) { - return; - } - carve(cell, x, z); - } - - @Override - public void tag(Cell cell, float x, float z) { - if (!terrains.overridesRiver(cell.tag)) { - cell.tag = terrains.river; - } - } - - private void carve(Cell cell, float x, float z) { - float valleyAlpha = valley.getValue(x, z); - if (valleyAlpha == 0) { - return; - } - - // riverMask decreases the closer to the river the position gets - cell.riverMask *= (1 - valleyAlpha); - - float bankHeight = getBankHeight(cell, x, z); - if (!carveValley(cell, valleyAlpha, bankHeight)) { - return; - } - - // is a branching river and x,z is past the connecting point - if (connecting && banks.clipEnd(x, z)) { - return; - } - - float widthModifier = banks.getWidthModifier(x, z); - float banksAlpha = banks.getValue(x, z, widthModifier); - if (banksAlpha == 0) { - return; - } - - float bedHeight = getBedHeight(bankHeight, widthModifier); - if (!carveBanks(cell, banksAlpha, bedHeight)) { - return; - } - - float bedAlpha = bed.getValue(x, z); - if (bedAlpha == 0) { - return; - } - - carveBed(cell, bedHeight); - } - - private float getBankHeight(Cell cell, float x, float z) { - // scale bank height based on elevation of the terrain (higher terrain == taller banks) - float bankHeightAlpha = NoiseUtil.map(cell.value, bankAlphaMin, bankAlphaMax, bankAlphaRange); - // use perlin noise to add a little extra variance to the bank height - float bankHeightVariance = bankVariance.getValue(x, z); - // lerp between the min and max heights - return NoiseUtil.lerp(minBankHeight, maxBankHeight, bankHeightAlpha * bankHeightVariance); - } - - private float getBedHeight(float bankHeight, float widthModifier) { - // scale depth of river by with it's width (wider == deeper) - // depthAlpha changes the river depth up ${DEPTH_FADE_STRENGTH} % - float depthAlpha = depthFadeBias + (DEPTH_FADE_STRENGTH * widthModifier); - return NoiseUtil.lerp(bankHeight, this.bedHeight, depthAlpha); - } - - private boolean carveValley(Cell cell, float valleyAlpha, float bankHeight) { - // lerp the position's height to the riverbank height - if (cell.value > bankHeight) { - cell.value = NoiseUtil.lerp(cell.value, bankHeight, valleyAlpha); - } - return true; - } - - private boolean carveBanks(Cell cell, float banksAlpha, float bedHeight) { - // lerp the position's height to the riverbed height (ie the riverbank slopes) - if (cell.value > bedHeight) { - cell.value = NoiseUtil.lerp(cell.value, bedHeight, banksAlpha); - tag(cell, terrains.riverBanks); - return true; - } - return false; - } - - private void carveBed(Cell cell, float bedHeight) { - if (cell.value > bedHeight) { - cell.value = bedHeight; - } - tag(cell, terrains.river); - } - - - private void tag(Cell cell, Terrain tag) { - if (!terrains.overridesRiver(cell.tag)) { - cell.tag = tag; - } - } - - public static boolean validStart(float value) { - return value > (70F / 256F); - } - - public static boolean validEnd(float value) { - return value < (60F / 256F); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverBounds.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverBounds.java deleted file mode 100644 index 9b78bc7..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverBounds.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.rivermap.river; - -import me.dags.noise.util.Vec2f; - -public class RiverBounds { - - private final int x1; - private final int y1; - private final int x2; - private final int y2; - private final int minX; - private final int minY; - private final int maxX; - private final int maxY; - - public RiverBounds(int x1, int y1, int x2, int y2, int radius) { - this.x1 = x1; - this.y1 = y1; - this.x2 = x2; - this.y2 = y2; - this.minX = Math.min(x1, x2) - radius; - this.minY = Math.min(y1, y2) - radius; - this.maxX = Math.max(x1, x2) + radius; - this.maxY = Math.max(y1, y2) + radius; - } - - public int x1() { - return x1; - } - - public int y1() { - return y1; - } - - public int x2() { - return x2; - } - - public int y2() { - return y2; - } - - public boolean overlaps(RiverBounds other) { - if (minX > other.maxX || maxX < other.minX) { - return false; - } - if (minY > other.maxY || maxY < other.minY) { - return false; - } - return true; - } - - public Vec2f pos(float distance) { - int dx = x2() - x1(); - int dy = y2() - y1(); - return new Vec2f(x1() + dx * distance, y1() + dy * distance); - } - - public static RiverBounds fromNodes(RiverNode p1, RiverNode p2) { - if (p1.type == RiverNode.Type.START) { - return new RiverBounds(p1.x, p1.z, p2.x, p2.z, 300); - } else { - return new RiverBounds(p2.x, p2.z, p1.x, p1.z, 300); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverConfig.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverConfig.java deleted file mode 100644 index 3f9b70e..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverConfig.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.rivermap.river; - -import com.terraforged.core.world.heightmap.Levels; -import me.dags.noise.util.NoiseUtil; - -public class RiverConfig { - - public final boolean main; - public final int bedWidth; - public final int bankWidth; - public final float bedHeight; - public final float minBankHeight; - public final float maxBankHeight; - public final int length2; - public final double fade; - - private RiverConfig(Builder builder) { - main = builder.main; - bedWidth = builder.bedWidth; - bankWidth = builder.bankWidth; - bedHeight = builder.levels.water(-builder.bedDepth); - minBankHeight = builder.levels.water(builder.minBankHeight); - maxBankHeight = builder.levels.water(builder.maxBankHeight); - length2 = builder.length * builder.length; - fade = builder.fade; - } - - private RiverConfig(boolean main, int bedWidth, int bankWidth, float bedHeight, float minBankHeight, float maxBankHeight, int length2, double fade) { - this.main = main; - this.bedWidth = bedWidth; - this.bankWidth = bankWidth; - this.bedHeight = bedHeight; - this.minBankHeight = minBankHeight; - this.maxBankHeight = maxBankHeight; - this.length2 = length2; - this.fade = fade; - } - - public RiverConfig createFork(float connectWidth) { - if (bankWidth < connectWidth) { - return this; - } - - float scale = bankWidth / connectWidth; - return new RiverConfig( - false, - NoiseUtil.round(bedWidth / scale), - NoiseUtil.round(bankWidth / scale), - bedHeight, - minBankHeight, - maxBankHeight, - length2, - fade - ); - } - - public static Builder builder(Levels levels) { - return new Builder(levels); - } - - public static class Builder { - - private boolean main = false; - private int bedWidth = 4; - private int bankWidth = 15; - private int bedDepth = 5; - private int maxBankHeight = 1; - private int minBankHeight = 1; - private int length = 1000; - private double fade = 0.2; - private final Levels levels; - - private Builder(Levels levels) { - this.levels = levels; - } - - public Builder main(boolean value) { - this.main = value; - return this; - } - - public Builder bedWidth(int value) { - this.bedWidth = value; - return this; - } - - public Builder bankWidth(int value) { - this.bankWidth = value; - return this; - } - - public Builder bedDepth(int depth) { - this.bedDepth = depth; - return this; - } - - public Builder bankHeight(int min, int max) { - this.minBankHeight = Math.min(min, max); - this.maxBankHeight = Math.max(min, max); - return this; - } - - public Builder length(int value) { - this.length = value; - return this; - } - - public Builder fade(double value) { - this.fade = value; - return this; - } - - public RiverConfig build() { - return new RiverConfig(this); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverNode.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverNode.java deleted file mode 100644 index 52b3952..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverNode.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.rivermap.river; - -public class RiverNode { - - public final int x; - public final int z; - public final Type type; - - public RiverNode(int x, int z, Type type) { - this.x = x; - this.z = z; - this.type = type; - } - - public static Type getType(float value) { - if (River.validStart(value)) { - return Type.START; - } - if (River.validEnd(value)) { - return Type.END; - } - return Type.NONE; - } - - public enum Type { - NONE { - @Override - public Type opposite() { - return this; - } - }, - START { - @Override - public Type opposite() { - return END; - } - }, - END { - @Override - public Type opposite() { - return START; - } - }, - ; - - public abstract Type opposite(); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverRegion.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverRegion.java deleted file mode 100644 index 585a705..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/rivermap/river/RiverRegion.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.rivermap.river; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.util.concurrent.ObjectPool; -import com.terraforged.core.util.concurrent.cache.ExpiringEntry; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.heightmap.Heightmap; -import com.terraforged.core.world.rivermap.PosGenerator; -import com.terraforged.core.world.rivermap.RiverMapConfig; -import com.terraforged.core.world.rivermap.lake.Lake; -import com.terraforged.core.world.rivermap.lake.LakeConfig; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; -import me.dags.noise.domain.Domain; -import me.dags.noise.util.NoiseUtil; -import me.dags.noise.util.Vec2f; -import me.dags.noise.util.Vec2i; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Random; -import java.util.concurrent.TimeUnit; - -public class RiverRegion implements ExpiringEntry { - - public static final int SCALE = 12; - private static final double MIN_FORK_ANGLE = 20D; - private static final double MAX_FORK_ANGLE = 60D; - private static final long EXPIRE_TIME = TimeUnit.SECONDS.toMillis(60); - - private final Domain domain; - private final Terrains terrains; - private final LakeConfig lake; - private final RiverConfig primary; - private final RiverConfig secondary; - private final RiverConfig tertiary; - - private final List rivers; - private final List lakes = new LinkedList<>(); - - private final int primaryLimit; - private final int secondaryLimit; - private final int secondaryRelaxedLimit; - private final int forkLimit; - private final int tertiaryLimit; - private final int primaryAttempts; - private final int secondaryAttempts; - private final int secondaryRelaxedAttempts; - private final int forkAttempts; - private final int tertiaryAttempts; - - private final long timestamp = System.currentTimeMillis() + EXPIRE_TIME; - - public RiverRegion(int regionX, int regionZ, Heightmap heightmap, GeneratorContext context, RiverMapConfig riverMapConfig) { - int seed = new Random(NoiseUtil.seed(regionX, regionZ)).nextInt(); - this.lake = riverMapConfig.lakes; - this.primary = riverMapConfig.primary; - this.secondary = riverMapConfig.secondary; - this.tertiary = riverMapConfig.tertiary; - this.terrains = context.terrain; - this.domain = Domain.warp(seed, 400, 1, 400) - .add(Domain.warp(seed + 1, 80, 1, 35)); - - this.primaryLimit = NoiseUtil.round(10 * riverMapConfig.frequency); - this.secondaryLimit = NoiseUtil.round(20 * riverMapConfig.frequency); - this.secondaryRelaxedLimit = NoiseUtil.round(30 * riverMapConfig.frequency); - this.forkLimit = NoiseUtil.round(40 * riverMapConfig.frequency); - this.tertiaryLimit = NoiseUtil.round(50 * riverMapConfig.frequency); - - this.primaryAttempts = NoiseUtil.round(100 * riverMapConfig.frequency); - this.secondaryAttempts = NoiseUtil.round(100 * riverMapConfig.frequency); - this.secondaryRelaxedAttempts = NoiseUtil.round(50 * riverMapConfig.frequency); - this.forkAttempts = NoiseUtil.round(75 * riverMapConfig.frequency); - this.tertiaryAttempts = NoiseUtil.round(50 * riverMapConfig.frequency); - - try (ObjectPool.Item> cell = Cell.pooled()) { - PosGenerator pos = new PosGenerator(heightmap, domain, cell.getValue(),1 << SCALE, River.VALLEY_WIDTH); - this.rivers = generate(regionX, regionZ, pos); - } - } - - @Override - public long getTimestamp() { - return timestamp; - } - - public void apply(Cell cell, float x, float z) { - float px = domain.getX(x, z); - float pz = domain.getY(x, z); - for (River river : rivers) { - river.apply(cell, px, pz); - } - for (Lake lake : lakes) { - lake.apply(cell, px, pz); - } - } - - private List generate(int regionX, int regionZ, PosGenerator pos) { - int x = regionToBlock(regionX); - int z = regionToBlock(regionZ); - long regionSeed = NoiseUtil.seed(regionX, regionZ); - - Random random = new Random(regionSeed); - List rivers = new LinkedList<>(); - - for (int i = 0; rivers.size() < primaryLimit && i < primaryAttempts; i++) { - generateRiver(x, z, pos, primary, random, rivers); - } - - for (int i = 0; rivers.size() < secondaryLimit && i < secondaryAttempts; i++) { - generateRiver(x, z, pos, secondary, random, rivers); - } - - for (int i = 0; rivers.size() < secondaryRelaxedLimit && i < secondaryRelaxedAttempts; i++) { - generateRiverRelaxed(x, z, pos, secondary, random, rivers); - } - - for (int i = 0; rivers.size() < forkLimit && i < forkAttempts; i++) { - generateRiverFork(x, z, pos, tertiary, random, rivers); - } - - for (int i = 0; rivers.size() < tertiaryLimit && i < tertiaryAttempts; i++) { - generateRiver(x, z, pos, tertiary, random, rivers); - } - - Collections.reverse(rivers); - - return rivers; - } - - /** - * Attempts to generate a line that starts inland and reaches the ocean - */ - private boolean generateRiver(int x, int z, PosGenerator pos, RiverConfig config, Random random, List rivers) { - // generate either a river start or end node - RiverNode p1 = pos.next(x, z, random, 50); - if (p1 == null) { - return false; - } - - // generate a node with a min distance from p1 and that has the opposite node type to p1 - RiverNode p2 = pos.nextFrom(x, z, random,50, p1, config.length2); - if (p2 == null) { - return false; - } - - // avoid collisions with existing rivers - RiverBounds bounds = RiverBounds.fromNodes(p1, p2); - for (River river : rivers) { - if (bounds.overlaps(river.bounds)) { - return false; - } - } - - generateLake(bounds, random); - - return rivers.add(new River(bounds, config, terrains, config.fade, 0)); - } - - /** - * Attempts to generate an inland position (p1), finds the nearest river (AB) to it, and tries to connect - * a line from p1 to some position along AB - */ - private boolean generateRiverFork(int x, int z, PosGenerator pos, RiverConfig config, Random random, List rivers) { - // generate a river start node - RiverNode p1 = pos.nextType(x, z, random, 50, RiverNode.Type.START); - if (p1 == null) { - return false; - } - - // find closest river - River closest = null; - float startDist2 = Integer.MAX_VALUE; - for (River river : rivers) { - float d2 = dist2(p1.x, p1.z, river.bounds.x1(), river.bounds.y1()); - if (d2 < startDist2) { - startDist2 = d2; - closest = river; - } - } - - // no close rivers - if (closest == null) { - return false; - } - - // connection should occur no less than 20% along the river length and no greater than 40% - float distance = 0.3F + (random.nextFloat() * 0.3F); - Vec2i fork = closest.bounds.pos(distance).toInt(); - - // connection should not occur in the ocean - float height = pos.getHeight(fork.x, fork.y); - RiverNode.Type type = RiverNode.getType(height); - if (type == RiverNode.Type.END) { - return false; - } - - // calc angle between vector a (AB) & b (CB) - // A - existing river's start - // B - connection point - // C - new river's start - int ax = fork.x - closest.bounds.x1(); - int az = fork.y - closest.bounds.y1(); - int bx = fork.x - p1.x; - int bz = fork.y - p1.z; - - // radians = arccos(AB.BC / |AB||BC|) - int dotAB = ax * bx + az * bz; - double lenA = Math.sqrt(ax * ax + az * az); - double lenB = Math.sqrt(bx * bx + bz * bz); - double radians = Math.acos(dotAB / (lenA * lenB)); - double angle = Math.toDegrees(radians); - if (angle < MIN_FORK_ANGLE || angle > MAX_FORK_ANGLE) { - return false; - } - - RiverBounds bounds = new RiverBounds(p1.x, p1.z, fork.x, fork.y, 300); - // check that the new river does not clash/overlap any other nearby rivers - for (River river : rivers) { - if (river == closest) { - continue; - } - if (river.bounds.overlaps(bounds)) { - return false; - } - } - - generateLake(bounds, random); - - // scale the connecting river's width down so that it's narrower than the one it's connecting to - float forkWidth = closest.config.bankWidth * distance * 0.6F; - RiverConfig forkConfig = config.createFork(forkWidth); - - return rivers.add(new River(bounds, forkConfig, terrains, forkConfig.fade, 0, true)); - } - - private boolean generateRiverRelaxed(int x, int z, PosGenerator pos, RiverConfig config, Random random, List rivers) { - // generate either a river start or end node - RiverNode p1 = pos.nextRelaxed(x, z, random, 50); - if (p1 == null) { - return false; - } - - // generate a node with a min distance from p1 and that has the opposite node type to p1 - RiverNode p2 = pos.nextFromRelaxed(x, z, random,50, p1, config.length2); - if (p2 == null) { - return false; - } - - // avoid collisions with existing rivers - RiverBounds bounds = RiverBounds.fromNodes(p1, p2); - for (River river : rivers) { - if (bounds.overlaps(river.bounds)) { - return false; - } - } - - generateLake(bounds, random); - - return rivers.add(new River(bounds, config, terrains, config.fade, 0)); - } - - private void generateLake(RiverBounds bounds, Random random) { - if (random.nextFloat() < lake.chance) { - float size = lake.sizeMin + (random.nextFloat() * lake.sizeMax); - float distance = lake.distanceMin + (random.nextFloat() * lake.distanceMax); - Vec2f center = bounds.pos(distance); - lakes.add(new Lake(center, size, lake, terrains)); - } - } - - private static float dist2(float x1, float y1, float x2, float y2) { - float dx = x2 - x1; - float dy = y2 - y1; - return dx * dx + dy * dy; - } - - public static int regionToBlock(int value) { - return value << SCALE; - } - - public static int blockToRegion(int value) { - return value >> SCALE; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/LandForms.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/LandForms.java deleted file mode 100644 index f3bb2fa..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/LandForms.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain; - -import com.terraforged.core.settings.TerrainSettings; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.heightmap.Levels; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.func.EdgeFunc; - -public class LandForms { - - private static final int PLAINS_H = 250; - private static final double PLAINS_V = 0.24; - - public static final int PLATEAU_H = 500; - public static final double PLATEAU_V = 0.475; - - private static final int HILLS_H = 500; - private static final double HILLS1_V = 0.6; - private static final double HILLS2_V = 0.55; - - private static final int MOUNTAINS_H = 410; - private static final double MOUNTAINS_V = 0.7; - - private static final int MOUNTAINS2_H = 400; - private static final double MOUNTAINS2_V = 0.645; - - private final TerrainSettings settings; - private final float terrainHorizontalScale; - private final float terrainVerticalScale; - private final float groundLevel; - private final float seaLevel; - - public LandForms(TerrainSettings settings, Levels levels) { - this.settings = settings; - terrainHorizontalScale = settings.globalHorizontalScale; - terrainVerticalScale = settings.globalVerticalScale; - groundLevel = levels.ground; - seaLevel = levels.water; - } - - public Module deepOcean(int seed) { - Module hills = Source.perlin(++seed, 150, 3) - .scale(seaLevel * 0.7) - .bias(Source.perlin(++seed, 200, 1).scale(seaLevel * 0.2F)); - - Module canyons = Source.perlin(++seed, 150, 4) - .powCurve(0.2) - .invert() - .scale(seaLevel * 0.7) - .bias(Source.perlin(++seed, 170, 1).scale(seaLevel * 0.15F)); - - return Source.perlin(++seed, 500, 1) - .blend(hills, canyons, 0.6, 0.65) - .warp(++seed, 50, 2, 50); - } - - public Module steppe(Seed seed) { - int scaleH = Math.round(PLAINS_H * terrainHorizontalScale * settings.steppe.horizontalScale); - - double erosionAmount = 0.45; - - Module erosion = Source.build(seed.next(), scaleH * 2, 3).lacunarity(3.75).perlin().alpha(erosionAmount); - Module warpX = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3).perlin(); - Module warpY = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3).perlin(); - Module module = Source.perlin(seed.next(), scaleH, 1) - .mult(erosion) - .warp(warpX, warpY, Source.constant(scaleH / 4F)) - .warp(seed.next(), 256, 1, 200); - - return settings.steppe.apply(groundLevel, 0.125 * terrainVerticalScale, module); - } - - public Module plains(Seed seed) { - int scaleH = Math.round(PLAINS_H * terrainHorizontalScale * settings.plains.horizontalScale); - - double erosionAmount = 0.45; - - Module erosion = Source.build(seed.next(), scaleH * 2, 3).lacunarity(3.75).perlin().alpha(erosionAmount); - Module warpX = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3.5).perlin(); - Module warpY = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3.5).perlin(); - - Module module = Source.perlin(seed.next(), scaleH, 1) - .mult(erosion) - .warp(warpX, warpY, Source.constant(scaleH / 4F)) - .warp(seed.next(), 256, 1, 256); - - return settings.plains.apply(groundLevel, PLAINS_V * terrainVerticalScale, module); - } - - public Module plateau(Seed seed) { - Module valley = Source.ridge(seed.next(), 500, 1).invert() - .warp(seed.next(), 100, 1, 150) - .warp(seed.next(), 20, 1, 15); - - Module top = Source.build(seed.next(), 150, 3).lacunarity(2.45).ridge() - .warp(seed.next(), 300, 1, 150) - .warp(seed.next(), 40, 2, 20) - .scale(0.15) - .mult(valley.clamp(0.02, 0.1).map(0, 1)); - - Module surface = Source.perlin(seed.next(), 20, 3).scale(0.05) - .warp(seed.next(), 40, 2, 20); - - return settings.plateau.apply(groundLevel, PLATEAU_V * terrainVerticalScale, - valley - .mult(Source.cubic(seed.next(), 500, 1).scale(0.6).bias(0.3)) - .add(top) - .terrace( - Source.perlin(seed.next(), 20, 1).scale(0.3).bias(0.2), - Source.perlin(seed.next(), 20, 2).scale(0.1).bias(0.2), - 4, - 0.4 - ) - .add(surface)); - } - - public Module hills1(Seed seed) { - return settings.hills.apply(groundLevel, HILLS1_V * terrainVerticalScale, Source.perlin(seed.next(), 200, 3) - .mult(Source.billow(seed.next(), 400, 3).alpha(0.5)) - .warp(seed.next(), 30, 3, 20) - .warp(seed.next(), 400, 3, 200)); - } - - public Module hills2(Seed seed) { - return settings.hills.apply(groundLevel, HILLS2_V * terrainVerticalScale, Source.cubic(seed.next(), 128, 2) - .mult(Source.perlin(seed.next(), 32, 4).alpha(0.075)) - .warp(seed.next(), 30, 3, 20) - .warp(seed.next(), 400, 3, 200) - .mult(Source.ridge(seed.next(), 512, 2).alpha(0.8))); - } - - public Module dales(Seed seed) { - Module hills1 = Source.build(seed.next(), 300, 4).gain(0.8).lacunarity(4).billow().powCurve(0.5).scale(0.75); - Module hills2 = Source.build(seed.next(), 350, 3).gain(0.8).lacunarity(4).billow().pow(1.25); - Module combined = Source.perlin(seed.next(), 400, 1).clamp(0.3, 0.6).map(0, 1).blend( - hills1, - hills2, - 0.4, - 0.75 - ); - Module hills = combined - .pow(1.125) - .warp(seed.next(), 300, 1, 100); - - return settings.dales.apply(groundLevel, 0.4, hills); - } - - public Module mountains(Seed seed) { - int scaleH = Math.round(MOUNTAINS_H * terrainHorizontalScale * settings.mountains.horizontalScale); - - Module module = Source.build(seed.next(), scaleH, 4).gain(1.15).lacunarity(2.35).ridge() - .mult(Source.perlin(seed.next(), 24, 4).alpha(0.075)) - .warp(seed.next(), 350, 1, 150); - - return settings.mountains.apply(groundLevel, MOUNTAINS_V * terrainVerticalScale, module); - } - - public Module mountains2(Seed seed) { - double scale = MOUNTAINS2_V * terrainVerticalScale; - Module cell = Source.cellEdge(seed.next(), 360, EdgeFunc.DISTANCE_2).scale(1.2).clamp(0, 1) - .warp(seed.next(), 200, 2, 100); - Module blur = Source.perlin(seed.next(), 10, 1).alpha(0.025); - Module surface = Source.ridge(seed.next(), 125, 4).alpha(0.37); - Module mountains = cell.clamp(0, 1).mult(blur).mult(surface).pow(1.1); - return settings.mountains.apply(groundLevel, scale, mountains); - } - - public Module mountains3(Seed seed) { - double scale = MOUNTAINS2_V * terrainVerticalScale; - - Module cell = Source.cellEdge(seed.next(), MOUNTAINS2_H, EdgeFunc.DISTANCE_2).scale(1.2).clamp(0, 1) - .warp(seed.next(), 200, 2, 100); - Module blur = Source.perlin(seed.next(), 10, 1).alpha(0.025); - Module surface = Source.ridge(seed.next(), 125, 4).alpha(0.37); - Module mountains = cell.clamp(0, 1).mult(blur).mult(surface).pow(1.1); - - Module terraced = mountains.terrace( - Source.perlin(seed.next(), 50, 1).scale(0.5), - Source.perlin(seed.next(), 100, 1).clamp(0.5, 0.95).map(0, 1), - Source.constant(0.45), - 0.2F, - 0.45F, - 24, - 1 - ); - - return settings.mountains.apply(groundLevel, scale, terraced); - } - - public Module badlands(Seed seed) { - Module mask = Source.perlin(seed.next(), 800, 1).clamp(0.35, 0.65).map(0, 1); - Module hills = Source.ridge(seed.next(), 500, 4) - .warp(seed.next(), 400, 2, 100) - .mult(mask); - - double modulation = 0.4; - double alpha = 1 - modulation; - Module mod1 = hills.warp(seed.next(), 100, 1, 50).scale(modulation); - - Module lowFreq = hills.steps(4).scale(alpha).add(mod1); - Module highFreq = hills.steps(10).scale(alpha).add(mod1); - Module detail = lowFreq.add(highFreq); - - Module mod2 = hills.mult(Source.perlin(seed.next(), 400, 3).scale(modulation)); - Module shape = hills.terrace(0.1, 1, 4, 0.01) - .scale(alpha) - .add(mod2) - .scale(alpha); - - return settings.badlands.apply(groundLevel, 0.7, shape.mult(detail.alpha(0.5))); - } - - public Module torridonian(Seed seed) { - Module plains = Source.perlin(seed.next(), 100, 3) - .warp(seed.next(), 300, 1, 150) - .warp(seed.next(), 20, 1, 40) - .scale(0.15); - - Module hills = Source.perlin(seed.next(), 150, 4) - .warp(seed.next(), 300, 1, 200) - .warp(seed.next(), 20, 2, 20) - .boost(); - - Module test = Source.perlin(seed.next(), 200, 3) - .blend(plains, hills, 0.6, 0.6) - .terrace( - Source.perlin(seed.next(), 120, 1).scale(0.25), - Source.perlin(seed.next(), 200, 1).scale(0.5).bias(0.5), - Source.constant(0.5), - 0, - 0.3, - 6, - 1 - ).boost(); - - return settings.torridonian.apply(groundLevel, 0.5, test); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java deleted file mode 100644 index fb1d3e5..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain; - -import com.terraforged.core.cell.Tag; -import com.terraforged.core.settings.Settings; -import com.terraforged.core.world.heightmap.Levels; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.atomic.AtomicInteger; - -public class Terrain implements Tag { - - private static final AtomicInteger MAX_ID = new AtomicInteger(0); - private static final Map register = Collections.synchronizedMap(new HashMap<>()); - - public static final int ID_START = 10; - public static final Terrain NONE = new Terrain("none", -1); - - private final String name; - private final int id; - private final float weight; - - public Terrain(String name, int id) { - this(name, id, 1F); - } - - public Terrain(String name, int id, double weight) { - this.name = name; - this.id = id; - this.weight = (float) weight; - register.put(name, this); - MAX_ID.set(Math.max(MAX_ID.get(), id)); - } - - public int getId() { - return id; - } - - @Override - public String getName() { - return name; - } - - public float getMax(float noise) { - return 1F; - } - - public float getWeight() { - return weight; - } - - public float getHue() { - return id / (float) MAX_ID.get(); - } - - @Override - public String toString() { - return getName(); - } - - public static Terrain ocean(Settings settings) { - return new Terrain("ocean", 0) { - - private final float max = new Levels(settings.generator).water; - - @Override - public float getMax(float noise) { - return max; - } - }; - } - - public static Terrain deepOcean(Settings settings) { - return new Terrain("deep_ocean", 1) { - - private final float max = new Levels(settings.generator).water / 2F; - - @Override - public float getMax(float noise) { - return max; - } - }; - } - - public static Terrain coast(Settings settings) { - return new Terrain("coast", 2) { - - private final float max = new Levels(settings.generator).ground(1); - - @Override - public float getMax(float noise) { - return max + (noise * (1 / 255F)); - } - }; - } - - public static Terrain beach(Settings settings) { - return new Terrain("beach", 2) { - - private final float max = new Levels(settings.generator).ground(1); - - @Override - public float getMax(float noise) { - return max + (noise * (1 / 255F)); - } - }; - } - - public static Terrain lake(Settings settings) { - return new Terrain("lake", 3); - } - - public static Terrain river(Settings settings) { - return new Terrain("river", 3); - } - - public static Terrain riverBank(Settings settings) { - return new Terrain("river_banks", 4); - } - - public static Terrain wetlands(Settings settings) { - return new Terrain("wetlands", 5); - } - - public static Terrain steppe(Settings settings) { - return new Terrain("steppe", 6, settings.terrain.steppe.weight); - } - - public static Terrain plains(Settings settings) { - return new Terrain("plains", 7, settings.terrain.plains.weight); - } - - public static Terrain plateau(Settings settings) { - return new Terrain("plateau", 8, settings.terrain.plateau.weight); - } - - public static Terrain badlands(Settings settings) { - return new Terrain("badlands", 9, settings.terrain.badlands.weight); - } - - public static Terrain hills(Settings settings) { - return new Terrain("hills", 10, settings.terrain.hills.weight); - } - - public static Terrain dales(Settings settings) { - return new Terrain("dales", 11, settings.terrain.dales.weight); - } - - public static Terrain torridonian(Settings settings) { - return new Terrain("torridonian_fells", 12, settings.terrain.torridonian.weight); - } - - public static Terrain mountains(Settings settings) { - return new Terrain("mountains", 13, settings.terrain.mountains.weight); - } - - public static Terrain volcano(Settings settings) { - return new Terrain("volcano", 14, settings.terrain.volcano.weight); - } - - public static Terrain volcanoPipe(Settings settings) { - return new Terrain("volcano_pipe", 15, settings.terrain.volcano.weight); - } - - public static Optional get(String name) { - return Optional.ofNullable(register.get(name)); - } - - public static List getRegistered() { - return new ArrayList<>(register.values()); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/TerrainPopulator.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/TerrainPopulator.java deleted file mode 100644 index 3d7db53..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/TerrainPopulator.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; -import me.dags.noise.Module; - -public class TerrainPopulator implements Populator { - - private final Terrain type; - private final Module source; - - public TerrainPopulator(Module source, Terrain type) { - this.type = type; - this.source = clamp(source); - } - - public Module getSource() { - return source; - } - - public Terrain getType() { - return type; - } - - @Override - public void apply(Cell cell, float x, float z) { - cell.value = source.getValue(x, z); - cell.tag = type; - } - - @Override - public void tag(Cell cell, float x, float y) { - cell.tag = type; - } - - public static Module clamp(Module module) { - if (module.minValue() < 0 || module.maxValue() > 1) { - return module.clamp(0, 1); - } - return module; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrains.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrains.java deleted file mode 100644 index 3198969..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrains.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain; - -import com.terraforged.core.settings.Settings; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class Terrains { - - public final Terrain ocean; - public final Terrain deepOcean; - public final Terrain coast; - public final Terrain beach; - public final Terrain lake; - public final Terrain river; - public final Terrain riverBanks; - public final Terrain wetlands; - public final Terrain badlands; - public final Terrain steppe; - public final Terrain plains; - public final Terrain plateau; - public final Terrain hills; - public final Terrain dales; - public final Terrain torridonian; - public final Terrain mountains; - public final Terrain volcano; - public final Terrain volcanoPipe; - public final List index; - - private Terrains(Mutable mutable) { - List index = new ArrayList<>(); - Collections.addAll( - index, - ocean = mutable.ocean, - deepOcean = mutable.deepOcean, - coast = mutable.coast, - beach = mutable.beach, - lake = mutable.lake, - river = mutable.river, - torridonian = mutable.torridonian, - riverBanks = mutable.riverbanks, - wetlands = mutable.wetlands, - badlands = mutable.badlands, - plateau = mutable.plateau, - steppe = mutable.steppe, - plains = mutable.plains, - hills = mutable.hills, - dales = mutable.dales, - mountains = mutable.mountains, - volcano = mutable.volcanoes, - volcanoPipe = mutable.volcanoPipe - ); - this.index = Collections.unmodifiableList(index); - } - - public int getId(Terrain landForm) { - return landForm.getId(); - } - - public boolean overridesRiver(Terrain terrain) { - return isOcean(terrain) || terrain == coast; - } - - public boolean isOcean(Terrain terrain) { - return terrain == ocean || terrain == deepOcean; - } - - public boolean isRiver(Terrain terrain) { - return terrain == river || terrain == riverBanks; - } - - public static Terrains create(Settings settings) { - Mutable terrain = new Mutable(); - terrain.ocean = Terrain.ocean(settings); - terrain.deepOcean = Terrain.deepOcean(settings); - terrain.coast = Terrain.coast(settings); - terrain.beach = Terrain.beach(settings); - terrain.lake = Terrain.lake(settings); - terrain.river = Terrain.river(settings); - terrain.riverbanks = Terrain.riverBank(settings); - terrain.wetlands = Terrain.wetlands(settings); - terrain.badlands = Terrain.badlands(settings); - terrain.plateau = Terrain.plateau(settings); - terrain.steppe = Terrain.steppe(settings); - terrain.plains = Terrain.plains(settings); - terrain.hills = Terrain.hills(settings); - terrain.dales = Terrain.dales(settings); - terrain.torridonian = Terrain.torridonian(settings); - terrain.mountains = Terrain.mountains(settings); - terrain.volcanoes = Terrain.volcano(settings); - terrain.volcanoPipe = Terrain.volcanoPipe(settings); - return terrain.create(); - } - - public static final class Mutable { - public Terrain ocean = Terrain.NONE; - public Terrain deepOcean = Terrain.NONE; - public Terrain coast = Terrain.NONE; - public Terrain beach = Terrain.NONE; - public Terrain lake = Terrain.NONE; - public Terrain river = Terrain.NONE; - public Terrain riverbanks = Terrain.NONE; - public Terrain wetlands = Terrain.NONE; - public Terrain badlands = Terrain.NONE; - public Terrain plateau = Terrain.NONE; - public Terrain steppe = Terrain.NONE; - public Terrain plains = Terrain.NONE; - public Terrain hills = Terrain.NONE; - public Terrain dales = Terrain.NONE; - public Terrain torridonian = Terrain.NONE; - public Terrain mountains = Terrain.NONE; - public Terrain volcanoes = Terrain.NONE; - public Terrain volcanoPipe = Terrain.NONE; - public Terrains create() { - return new Terrains(this); - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/VolcanoPopulator.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/VolcanoPopulator.java deleted file mode 100644 index 82a93e7..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/VolcanoPopulator.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.heightmap.RegionConfig; -import me.dags.noise.Module; -import me.dags.noise.Source; -import me.dags.noise.func.EdgeFunc; - -public class VolcanoPopulator extends TerrainPopulator { - - private static final float throat_value = 0.925F; - - private final Module cone; - private final Module height; - private final Module lowlands; - private final float inversionPoint; - private final float blendLower; - private final float blendUpper; - private final float blendRange; - private final float bias; - - private final Terrain inner; - private final Terrain outer; - - public VolcanoPopulator(Seed seed, RegionConfig region, Levels levels, Terrains terrains) { - super(Source.ZERO, terrains.volcano); - float midpoint = 0.3F; - float range = 0.3F; - - Module heightNoise = Source.perlin(seed.next(), 2, 1).map(0.45, 0.65); - - this.height = Source.cellNoise(region.seed, region.scale, heightNoise) - .warp(region.warpX, region.warpZ, region.warpStrength); - - this.cone = Source.cellEdge(region.seed, region.scale, EdgeFunc.DISTANCE_2_DIV).invert() - .warp(region.warpX, region.warpZ, region.warpStrength) - .powCurve(11) - .clamp(0.475, 1) - .map(0, 1) - .grad(0, 0.5, 0.5) - .warp(seed.next(), 15, 2, 10) - .scale(height); - - this.lowlands = Source.ridge(seed.next(), 150, 3) - .warp(seed.next(), 30, 1, 30) - .scale(0.1); - - this.inversionPoint = 0.94F; - this.blendLower = midpoint - (range / 2F); - this.blendUpper = blendLower + range; - this.blendRange = blendUpper - blendLower; - this.outer = terrains.volcano; - this.inner = terrains.volcanoPipe; - this.bias = levels.ground; - } - - @Override - public void apply(Cell cell, float x, float z) { - float value = cone.getValue(x, z); - float limit = height.getValue(x, z); - float maxHeight = limit * inversionPoint; - - // as value passes the inversion point we start calculating the inner-cone of the volcano - if (value > maxHeight) { - // modifies the steepness of the volcano inner-cone (larger == steeper) - float steepnessModifier = 1F; - - // as alpha approaches 1.0, position is closer to center of volcano - float delta = (value - maxHeight) * steepnessModifier; - float range = (limit - maxHeight); - float alpha = delta / range; - - // calculate height inside volcano - if (alpha > throat_value) { - cell.tag = inner; - } - - value = maxHeight - ((maxHeight / 5F) * alpha); - } else if (value < blendLower) { - value += lowlands.getValue(x, z); - cell.tag = outer; - } else if (value < blendUpper) { - float alpha = 1 - ((value - blendLower) / blendRange); - value += (lowlands.getValue(x, z) * alpha); - cell.tag = outer; - } - - cell.value = bias + value; - } - - @Override - public void tag(Cell cell, float x, float z) { - float value = cone.getValue(x, z); - float limit = height.getValue(x, z); - float maxHeight = limit * inversionPoint; - if (value > maxHeight) { - float steepnessModifier = 1; - - // as alpha approaches 1.0, position is closer to center of volcano - float delta = (value - maxHeight) * steepnessModifier; - float range = (limit - maxHeight); - float alpha = delta / range; - - // calculate height inside volcano - if (alpha > throat_value) { - cell.tag = inner; - } else { - cell.tag = outer; - } - } else { - cell.tag = outer; - } - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/StandardTerrainProvider.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/StandardTerrainProvider.java deleted file mode 100644 index 64419c1..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/StandardTerrainProvider.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain.provider; - -import com.terraforged.core.cell.Populator; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.heightmap.RegionConfig; -import com.terraforged.core.world.terrain.LandForms; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.TerrainPopulator; -import com.terraforged.core.world.terrain.VolcanoPopulator; -import me.dags.noise.Module; -import me.dags.noise.Source; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.BiFunction; - -public class StandardTerrainProvider implements TerrainProvider { - - private final List mixable = new ArrayList<>(); - private final List unmixable = new ArrayList<>(); - private final Map populators = new HashMap<>(); - - private final LandForms landForms; - private final RegionConfig config; - private final GeneratorContext context; - private final Populator defaultPopulator; - - public StandardTerrainProvider(GeneratorContext context, RegionConfig config, Populator defaultPopulator) { - this.config = config; - this.context = context; - this.landForms = new LandForms(context.settings.terrain, context.levels); - this.defaultPopulator = defaultPopulator; - init(); - } - - public void init() { - registerMixable(context.terrain.steppe, landForms.steppe(context.seed)); - registerMixable(context.terrain.plains, landForms.plains(context.seed)); - registerMixable(context.terrain.hills, landForms.hills1(context.seed)); - registerMixable(context.terrain.hills, landForms.hills2(context.seed)); - registerMixable(context.terrain.dales, landForms.dales(context.seed)); - registerMixable(context.terrain.badlands, landForms.badlands(context.seed)); - registerMixable(context.terrain.plateau, landForms.plateau(context.seed)); - registerMixable(context.terrain.torridonian, landForms.torridonian(context.seed)); - - registerUnMixable(new VolcanoPopulator(context.seed, config, context.levels, context.terrain)); - registerUnMixable(context.terrain.badlands, landForms.badlands(context.seed)); - registerUnMixable(context.terrain.mountains, landForms.mountains2(context.seed)); - registerUnMixable(context.terrain.mountains, landForms.mountains3(context.seed)); - } - - @Override - public void registerMixable(TerrainPopulator populator) { - populators.putIfAbsent(populator.getType(), populator); - mixable.add(populator); - } - - @Override - public void registerUnMixable(TerrainPopulator populator) { - populators.putIfAbsent(populator.getType(), populator); - unmixable.add(populator); - } - - @Override - public Populator getPopulator(Terrain terrain) { - return populators.getOrDefault(terrain, defaultPopulator); - } - - @Override - public LandForms getLandforms() { - return landForms; - } - - @Override - public List getPopulators() { - List mixed = combine(getMixable(mixable), this::combine); - List result = new ArrayList<>(mixed.size() + unmixable.size()); - result.addAll(mixed); - result.addAll(unmixable); - return result; - } - - protected GeneratorContext getContext() { - return context; - } - - private TerrainPopulator combine(TerrainPopulator tp1, TerrainPopulator tp2) { - return combine(tp1, tp2, context.seed, config.scale / 2); - } - - private static TerrainPopulator combine(TerrainPopulator tp1, TerrainPopulator tp2, Seed seed, int scale) { - float weight = Math.min(tp1.getType().getWeight(), tp2.getType().getWeight()); - - String name = tp1.getType().getName() + "-" + tp2.getType().getName(); - int id = Terrain.ID_START + 1 + tp1.getType().getId() * tp2.getType().getId(); - - Terrain type = new Terrain(name, id, weight); - Module combined = Source.perlin(seed.next(), scale, 1) - .warp(seed.next(), scale / 2, 2, scale / 2D) - .blend(tp1.getSource(), tp2.getSource(), 0.5, 0.25) - .clamp(0, 1); - - return new TerrainPopulator(combined, type); - } - - private static List combine(List input, BiFunction operator) { - int length = input.size(); - for (int i = 1; i < input.size(); i++) { - length += (input.size() - i); - } - - List result = new ArrayList<>(length); - for (int i = 0; i < length; i++) { - result.add(null); - } - - for (int i = 0, k = input.size(); i < input.size(); i++) { - T t1 = input.get(i); - result.set(i, t1); - for (int j = i + 1; j < input.size(); j++, k++) { - T t2 = input.get(j); - T t3 = operator.apply(t1, t2); - result.set(k, t3); - } - } - - return result; - } - - private static List getMixable(List input) { - List output = new ArrayList<>(input.size()); - for (TerrainPopulator populator : input) { - if (populator.getType().getWeight() > 0) { - output.add(populator); - } - } - return output; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/TerrainProvider.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/TerrainProvider.java deleted file mode 100644 index 58131e6..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/TerrainProvider.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain.provider; - -import com.terraforged.core.cell.Populator; -import com.terraforged.core.world.terrain.LandForms; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.TerrainPopulator; -import me.dags.noise.Module; - -import java.util.List; - -/** - * Provides the heightmap generator with terrain specific noise generation modules (TerrainPopulators) - */ -public interface TerrainProvider { - - LandForms getLandforms(); - - /** - * Returns the resulting set of TerrainPopulators - */ - List getPopulators(); - - /** - * Returns a populator for the provided Terrain, or the default if not registered - */ - Populator getPopulator(Terrain terrain); - - /** - * Add a TerrainPopulator to world generation. - * - * 'Mixable' TerrainPopulators are used to create additional terrain types, created by blending two - * different mixable TerrainPopulators together (this is in addition to the unmixed version of the populator) - */ - void registerMixable(TerrainPopulator populator); - - /** - * Add a TerrainPopulator to world generation - * - * 'UnMixable' TerrainPopulators are NOT blended together to create additional terrain types - */ - void registerUnMixable(TerrainPopulator populator); - - /** - * Add a TerrainPopulator to world generation. - * - * 'Mixable' TerrainPopulators are used to create additional terrain types, created by blending two - * different mixable TerrainPopulators together (this is in addition to the unmixed version of the populator) - */ - default void registerMixable(Terrain type, Module source) { - registerMixable(new TerrainPopulator(source, type)); - } - - /** - * Add a TerrainPopulator to world generation - * - * 'UnMixable' TerrainPopulators are NOT blended together to create additional terrain types - */ - default void registerUnMixable(Terrain type, Module source) { - registerUnMixable(new TerrainPopulator(source, type)); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/TerrainProviderFactory.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/TerrainProviderFactory.java deleted file mode 100644 index 4ff2842..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/TerrainProviderFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain.provider; - -import com.terraforged.core.cell.Populator; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.heightmap.RegionConfig; - -public interface TerrainProviderFactory { - - TerrainProvider create(GeneratorContext context, RegionConfig config, Populator defaultPopulator); -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionLerper.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionLerper.java deleted file mode 100644 index 5055e5b..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionLerper.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain.region; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.util.NoiseUtil; - -public class RegionLerper implements Populator { - - private final Populator lower; - private final Populator upper; - - public RegionLerper(Populator lower, Populator upper) { - this.lower = lower; - this.upper = upper; - } - - @Override - public void apply(Cell cell, float x, float y) { - float alpha = cell.regionEdge; - if (alpha == 0) { - lower.apply(cell, x, y); - return; - } - - if (alpha == 1) { - upper.apply(cell, x, y); - return; - } - - lower.apply(cell, x, y); - float lowerValue = cell.value; - - upper.apply(cell, x, y); - float upperValue = cell.value; - - cell.value = NoiseUtil.lerp(lowerValue, upperValue, alpha); - } - - @Override - public void tag(Cell cell, float x, float y) { - if (cell.regionEdge == 0) { - lower.tag(cell, x, y); - return; - } - upper.tag(cell, x, y); - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionModule.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionModule.java deleted file mode 100644 index 739823e..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionModule.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain.region; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; -import com.terraforged.core.world.heightmap.RegionConfig; -import com.terraforged.core.world.terrain.Terrain; -import me.dags.noise.Source; -import me.dags.noise.domain.Domain; -import me.dags.noise.func.DistanceFunc; -import me.dags.noise.func.EdgeFunc; -import me.dags.noise.util.NoiseUtil; -import me.dags.noise.util.Vec2f; - -public class RegionModule implements Populator { - - private final int seed; - private final float frequency; - - private final float edgeMin; - private final float edgeMax; - private final float edgeRange; - private final Domain warp; - - public RegionModule(RegionConfig regionConfig) { - seed = regionConfig.seed; - edgeMin = 0F; - edgeMax = 0.5F; - edgeRange = edgeMax - edgeMin; - frequency = 1F / regionConfig.scale; - warp = Domain.warp(regionConfig.warpX, regionConfig.warpZ, Source.constant(regionConfig.warpStrength)); - } - - @Override - public void apply(Cell cell, float x, float y) { - float ox = warp.getOffsetX(x, y); - float oz = warp.getOffsetY(x, y); - - float px = x + ox; - float py = y + oz; - - px *= frequency; - py *= frequency; - - int cellX = 0; - int cellY = 0; - - int xr = NoiseUtil.round(px); - int yr = NoiseUtil.round(py); - float edgeDistance = 999999.0F; - float edgeDistance2 = 999999.0F; - float valueDistance = 3.4028235E38F; - DistanceFunc dist = DistanceFunc.NATURAL; - - for (int dy = -1; dy <= 1; dy++) { - for (int dx = -1; dx <= 1; dx++) { - int xi = xr + dx; - int yi = yr + dy; - Vec2f vec = NoiseUtil.CELL_2D[NoiseUtil.hash2D(seed, xi, yi) & 255]; - - float vecX = xi - px + vec.x; - float vecY = yi - py + vec.y; - float distance = dist.apply(vecX, vecY); - - if (distance < valueDistance) { - valueDistance = distance; - cellX = xi; - cellY = yi; - } - - if (distance < edgeDistance2) { - edgeDistance2 = Math.max(edgeDistance, distance); - } else { - edgeDistance2 = Math.max(edgeDistance, edgeDistance2); - } - - edgeDistance = Math.min(edgeDistance, distance); - } - } - - cell.region = cellValue(seed, cellX, cellY); - cell.regionEdge = edgeValue(edgeDistance, edgeDistance2); - } - - @Override - public void tag(Cell cell, float x, float y) { - - } - - private float cellValue(int seed, int cellX, int cellY) { - float value = NoiseUtil.valCoord2D(seed, cellX, cellY); - return NoiseUtil.map(value, -1, 1, 2); - } - - private float edgeValue(float distance, float distance2) { - EdgeFunc edge = EdgeFunc.DISTANCE_2_DIV; - float value = edge.apply(distance, distance2); - float edgeValue = 1 - NoiseUtil.map(value, edge.min(), edge.max(), edge.range()); - - edgeValue = NoiseUtil.pow(edgeValue, 1.5F); - - if (edgeValue < edgeMin) { - return 0F; - } - if (edgeValue > edgeMax) { - return 1F; - } - - return (edgeValue - edgeMin) / edgeRange; - } -} diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionSelector.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionSelector.java deleted file mode 100644 index d967663..0000000 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionSelector.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.core.world.terrain.region; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.cell.Populator; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.TerrainPopulator; -import me.dags.noise.util.NoiseUtil; - -import java.util.LinkedList; -import java.util.List; - -public class RegionSelector implements Populator { - - private final int maxIndex; - private final Populator[] nodes; - - public RegionSelector(List populators) { - this.nodes = getWeightedArray(populators); - this.maxIndex = nodes.length - 1; - } - - @Override - public void apply(Cell cell, float x, float y) { - get(cell.region).apply(cell, x, y); - } - - @Override - public void tag(Cell cell, float x, float y) { - get(cell.region).tag(cell, x, y); - } - - public Populator get(float identity) { - int index = NoiseUtil.round(identity * maxIndex); - return nodes[index]; - } - - private static Populator[] getWeightedArray(List modules) { - float smallest = Float.MAX_VALUE; - for (Populator p : modules) { - if (p instanceof TerrainPopulator) { - TerrainPopulator tp = (TerrainPopulator) p; - if (tp.getType().getWeight() == 0F) { - continue; - } - smallest = Math.min(smallest, tp.getType().getWeight()); - } else { - smallest = Math.min(smallest, 1); - } - } - - if (smallest == Float.MAX_VALUE) { - return modules.toArray(new Populator[0]); - } - - List result = new LinkedList<>(); - for (Populator p : modules) { - int count; - if (p instanceof TerrainPopulator) { - TerrainPopulator tp = (TerrainPopulator) p; - if (tp.getType().getWeight() == 0F) { - continue; - } - count = Math.round(tp.getType().getWeight() / smallest); - } else { - count = Math.round(1 / smallest); - } - while (count-- > 0) { - result.add(p); - } - } - - if (result.isEmpty()) { - return modules.toArray(new Populator[0]); - } - - return result.toArray(new Populator[0]); - } -} diff --git a/TerraForgedCore/src/main/resources/biomes.png b/TerraForgedCore/src/main/resources/biomes.png deleted file mode 100644 index 131a9bf..0000000 Binary files a/TerraForgedCore/src/main/resources/biomes.png and /dev/null differ diff --git a/TerraForgedCore/src/main/resources/biomes.txt b/TerraForgedCore/src/main/resources/biomes.txt deleted file mode 100644 index 9622c92..0000000 --- a/TerraForgedCore/src/main/resources/biomes.txt +++ /dev/null @@ -1,13 +0,0 @@ -#TerraForgedCore BiomeType Hex Colors (do not include hash/pound character) -#Fri Jan 10 23:15:10 GMT 2020 -ALPINE=a078aa -TAIGA=5b8f52 -TEMPERATE_RAINFOREST=0aa041 -TUNDRA=93a7ac -TROPICAL_RAINFOREST=075330 -SAVANNA=97a527 -GRASSLAND=64dc3c -TEMPERATE_FOREST=32c850 -STEPPE=c8c878 -DESERT=c87137 -COLD_STEPPE=afb496 \ No newline at end of file diff --git a/TerraForgedCore/src/main/resources/license.txt b/TerraForgedCore/src/main/resources/license.txt deleted file mode 100644 index 0b31935..0000000 --- a/TerraForgedCore/src/main/resources/license.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 TerraForged - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/TerraForgedCore/src/main/resources/terraforged.png b/TerraForgedCore/src/main/resources/terraforged.png deleted file mode 100644 index ecedcf8..0000000 Binary files a/TerraForgedCore/src/main/resources/terraforged.png and /dev/null differ diff --git a/TerraForgedMod/README.md b/TerraForgedMod/README.md deleted file mode 100644 index 7f0dcfb..0000000 --- a/TerraForgedMod/README.md +++ /dev/null @@ -1,56 +0,0 @@ -![TerraForged Social](https://terraforged.com/curse/header.jpg) - -#### About: -TerraForged is an ambitious new terrain generator mod for Minecraft (Java Edition) attempting to - create more immersive, inspiring worlds to explore and build in. Featuring an overhaul of the - vanilla generation system, custom terrain shapes, simulated erosion, better rivers, custom - decorations, tonnes of configuration options, and more! - -#### Website(s): -[https://terraforged.com](https://terraforged.com) -[https://github.com/TerraForged](https://github.com/TerraForged) -[https://curseforge.com/../TerraForged](https://www.curseforge.com/minecraft/mc-mods/terraforged) - -#### Installation: -1. Install forge for the target version of Minecraft (ie 1.15.2) -2. Add the TerraForged mod jar to your profile's mods folder -3. Select the '`TerraForged`' world-type when creating a new world - -#### Features: -- Varied and immersive terrain -- Erosion and improved rivers -- Custom features and decoration -- Extensive configuration options & in-game GUI - -![TerraForged Gallery](https://terraforged.com/curse/gallery.jpg) - -#### FAQ: -1) "Is this compatible with mod xyz?" -_Probably! (to some degree) - TerraForged is designed to work with many of the same world-gen systems -that the majority of block & biome providing mods use. Certain biomes' terrain may not always look -exactly as their author designed but should otherwise be compatible. Feel free to report any other -compatibility issues on the issue tracker._ - -2) "How can I use this on my server?" -_When Forge supports it, you can simply set level-type=terraforged in your server.properties file. In -the meantime, you will need to create the world in single player and then copy that to your server -directory. (In both cases, TerraForged must be installed on the client and the server)._ - -3) "Will I need a super-computer to run this?!" -_No, not really - while this world generator will be a bit slower than vanilla's (on account of it -doing more work to make things look nice), it would only be apparent when first generating a chunk - -they might load in slower when moving to new parts of the world, but game performance should -otherwise be normal. A 4-core CPU should be able to handle this just fine._ - -4) "Can this be ported Fabric/Bukkit/Spigot/Sponge?" -_If someone would like to take this task on, yes - a large part of the TerraForged codebase is already -platform independent. There are certain client-side features in the forge-mod that would not translate -onto server-only APIs, but the core experience could certainly be ported. I don't intend to work on -this directly but others are very welcome._ - -5) "Will this be back-ported to older Forge versions?" -_Not by myself, no - My aim is to keep current with Forge. I'm simply not prolific enough a modder to -write and maintain for multiple versions (hats off to those who do!). Again though, others are welcome -to back-port it, if inclined to do so._ - -[View more questions on Github](https://github.com/TerraForged/TerraForged/issues?q=label:question) \ No newline at end of file diff --git a/TerraForgedMod/build.gradle b/TerraForgedMod/build.gradle deleted file mode 100644 index b165533..0000000 --- a/TerraForgedMod/build.gradle +++ /dev/null @@ -1,103 +0,0 @@ -buildscript { - repositories { - jcenter() - mavenCentral() - maven { url "https://files.minecraftforge.net/maven" } - } - dependencies { - classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "3.+", changing: true - } -} - -apply plugin: "net.minecraftforge.gradle" -apply plugin: "maven-publish" -apply plugin: "eclipse" - -version = "${mc_version}-${mod_version}${getClassifier()}" -archivesBaseName = "TerraForged" - -repositories { - jcenter() - mavenCentral() -} - -dependencies { - minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" - compile project(":Noise2D") - compile(project(":TerraForgedCore")) { transitive false } - compile(project(":FeatureManager")) { transitive false } - compile(project(":TerraForgedAPI")) { transitive false } -} - -minecraft { - mappings channel: mcp_channel, version: mcp_version - runs { - client { - workingDirectory project.file("run/client") - property "forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP" - property "forge.logging.console.level", "debug" - jvmArgs "-Xmx8G", "-Xms6G", "-Ddev" - mods { - terraforged { - source sourceSets.main - } - } - } - server { - workingDirectory project.file("run/server") - property "forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP" - property "forge.logging.console.level", "debug" - jvmArgs "-Xmx8G", "-Xms6G", "-Ddev" - mods { - terraforged { - source sourceSets.main - } - } - } - } -} - -task collectClasses(type: Copy) { - configurations.collectMany { it.allDependencies }.findAll { it instanceof ProjectDependency }.each { - ProjectDependency project = (ProjectDependency) it - from("$project.dependencyProject.buildDir/classes/java/main") - } - into("build/classes/java/main") -} - -task collectResources(type: Copy) { - configurations.collectMany { it.allDependencies }.findAll { it instanceof ProjectDependency }.each { - ProjectDependency project = (ProjectDependency) it - from("$project.dependencyProject.buildDir/resources/main") - } - into("build/resources/main") -} - -processResources { - dependsOn(collectResources) - filesMatching("**/mods.toml") { - expand( - "version": "${mod_version}${getClassifier()}", - "mc_version": mc_version - ) - } -} - -classes { - dependsOn(collectClasses) -} - -publish { - dependsOn("reobfJar") -} - -static def getClassifier() { - if (System.getenv("GIT_TAG_NAME") != null) { - return "" - } - def buildNumber = System.getenv("BUILD_NUMBER") - if (buildNumber != null) { - return "-${buildNumber}" - } - return "" -} \ No newline at end of file diff --git a/TerraForgedMod/gradlew b/TerraForgedMod/gradlew deleted file mode 100644 index cccdd3d..0000000 --- a/TerraForgedMod/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/TerraForgedMod/gradlew.bat b/TerraForgedMod/gradlew.bat deleted file mode 100644 index f955316..0000000 --- a/TerraForgedMod/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/TerraForgedMod/psd/biomes.psd b/TerraForgedMod/psd/biomes.psd deleted file mode 100644 index eedc297..0000000 Binary files a/TerraForgedMod/psd/biomes.psd and /dev/null differ diff --git a/TerraForgedMod/psd/icon.png b/TerraForgedMod/psd/icon.png deleted file mode 100644 index ecedcf8..0000000 Binary files a/TerraForgedMod/psd/icon.png and /dev/null differ diff --git a/TerraForgedMod/psd/terraforged.psd b/TerraForgedMod/psd/terraforged.psd deleted file mode 100644 index 8034e6d..0000000 Binary files a/TerraForgedMod/psd/terraforged.psd and /dev/null differ diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/TerraBiomeRegistry.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/TerraBiomeRegistry.java deleted file mode 100644 index 68219be..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/TerraBiomeRegistry.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.biome.provider; - -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.biome.Biome; -import net.minecraftforge.registries.ForgeRegistries; - -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; -import java.util.function.Predicate; - -public class TerraBiomeRegistry { - - private static final TerraBiomeRegistry instance = new TerraBiomeRegistry(); - - public Optional getBiome(ResourceLocation name) { - if (ForgeRegistries.BIOMES.containsKey(name)) { - return Optional.ofNullable(ForgeRegistries.BIOMES.getValue(name)); - } - return Optional.empty(); - } - - public Collection getAll(Predicate filter) { - List combined = new LinkedList<>(ForgeRegistries.BIOMES.getValues()); - combined.removeIf(filter); - return combined; - } - - public static TerraBiomeRegistry getInstance() { - return instance; - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ChunkProcessor.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ChunkProcessor.java deleted file mode 100644 index e9df107..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ChunkProcessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.terraforged.mod.chunk; - -import com.terraforged.api.chunk.column.DecoratorContext; -import com.terraforged.core.region.chunk.ChunkReader; -import net.minecraft.util.math.ChunkPos; - -public interface ChunkProcessor { - - void preProcess(ChunkPos pos, ChunkReader chunk, TerraContainer container); - - void postProcess(ChunkReader chunk, TerraContainer container, DecoratorContext context); -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ObfHelperChunkGenerator.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ObfHelperChunkGenerator.java deleted file mode 100644 index 5c9843c..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ObfHelperChunkGenerator.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.chunk; - -import com.terraforged.mod.chunk.fix.SpawnFix; -import com.terraforged.mod.util.annotation.Name; -import com.terraforged.mod.util.annotation.Ref; -import net.minecraft.entity.EntityClassification; -import net.minecraft.util.SharedSeedRandom; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.provider.BiomeProvider; -import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.GenerationSettings; -import net.minecraft.world.gen.Heightmap; -import net.minecraft.world.gen.INoiseGenerator; -import net.minecraft.world.gen.NoiseChunkGenerator; -import net.minecraft.world.gen.OverworldChunkGenerator; -import net.minecraft.world.gen.PerlinNoiseGenerator; -import net.minecraft.world.gen.WorldGenRegion; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.spawner.CatSpawner; -import net.minecraft.world.spawner.PatrolSpawner; -import net.minecraft.world.spawner.PhantomSpawner; -import net.minecraft.world.spawner.WorldEntitySpawner; - -import java.util.List; - -@Ref({OverworldChunkGenerator.class, NoiseChunkGenerator.class, ChunkGenerator.class}) -public abstract class ObfHelperChunkGenerator extends ChunkGenerator { - - private final CatSpawner catSpawner = new CatSpawner(); - private final PatrolSpawner patrolSpawner = new PatrolSpawner(); - private final PhantomSpawner phantomSpawner = new PhantomSpawner(); - private final INoiseGenerator surfaceNoise; - - public ObfHelperChunkGenerator(IWorld world, BiomeProvider biomeProvider, T settings) { - super(world, biomeProvider, settings); - SharedSeedRandom random = new SharedSeedRandom(world.getSeed()); - this.surfaceNoise = new PerlinNoiseGenerator(random, 3, 0); - } - - @Override - public final void generateStructureStarts(IWorld world, IChunk chunk) { - try { - super.generateStructureStarts(world, chunk); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - @Override - public final void makeBase(IWorld world, IChunk chunk) { - generateBase(world, chunk); - } - - @Override - public final void func_225551_a_(WorldGenRegion world, IChunk chunk) { - generateSurface(world, chunk); - } - - @Override - public final List getPossibleCreatures(EntityClassification type, BlockPos pos) { - if (Feature.SWAMP_HUT.func_202383_b(this.world, pos)) { - if (type == EntityClassification.MONSTER) { - return Feature.SWAMP_HUT.getSpawnList(); - } - - if (type == EntityClassification.CREATURE) { - return Feature.SWAMP_HUT.getCreatureSpawnList(); - } - } else if (type == EntityClassification.MONSTER) { - if (Feature.PILLAGER_OUTPOST.isPositionInStructure(this.world, pos)) { - return Feature.PILLAGER_OUTPOST.getSpawnList(); - } - - if (Feature.OCEAN_MONUMENT.isPositionInStructure(this.world, pos)) { - return Feature.OCEAN_MONUMENT.getSpawnList(); - } - } - return super.getPossibleCreatures(type, pos); - } - - @Override - public final void spawnMobs(WorldGenRegion region) { - // vanilla does NOT check the mobSpawning gamerule before calling this - if (SpawnFix.canSpawnMobs()) { - int chunkX = region.getMainChunkX(); - int chunkZ = region.getMainChunkZ(); - Biome biome = region.getChunk(chunkX, chunkZ).getBiomes().getNoiseBiome(0, 0, 0); - SharedSeedRandom sharedseedrandom = new SharedSeedRandom(); - sharedseedrandom.setDecorationSeed(region.getSeed(), chunkX << 4, chunkZ << 4); - WorldEntitySpawner.performWorldGenSpawning(region, biome, chunkX, chunkZ, sharedseedrandom); - } - } - - @Override - public final void spawnMobs(ServerWorld worldIn, boolean spawnHostileMobs, boolean spawnPeacefulMobs) { - // vanilla does check the mobSpawning gamerule before calling this - phantomSpawner.tick(worldIn, spawnHostileMobs, spawnPeacefulMobs); - patrolSpawner.tick(worldIn, spawnHostileMobs, spawnPeacefulMobs); - catSpawner.tick(worldIn, spawnHostileMobs, spawnPeacefulMobs); - } - - @Override - @Name("getSurfaceLevel") - public final int func_222529_a(int x, int z, Heightmap.Type type) { - int level = getTopBlockY(x, z, type) + 1; - if (type == Heightmap.Type.OCEAN_FLOOR || type == Heightmap.Type.OCEAN_FLOOR_WG) { - return level; - } - return Math.max(getSeaLevel(), level); - } - - public final double getSurfaceNoise(int x, int z) { - double scale = 0.0625D; - double noiseX = x * scale; - double noiseZ = z * scale; - double unusedValue1 = scale; - double unusedValue2 = (x & 15) * scale; - return surfaceNoise.noiseAt(noiseX, noiseZ, unusedValue1, unusedValue2); - } - - public abstract int getTopBlockY(int x, int z, Heightmap.Type type); - - public abstract void generateBase(IWorld world, IChunk chunk); - - public abstract void generateSurface(WorldGenRegion world, IChunk chunk); -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java deleted file mode 100644 index 45465db..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java +++ /dev/null @@ -1,407 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.chunk; - -import com.terraforged.api.chunk.column.ColumnDecorator; -import com.terraforged.api.chunk.column.DecoratorContext; -import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer; -import com.terraforged.api.chunk.surface.SurfaceContext; -import com.terraforged.api.chunk.surface.SurfaceManager; -import com.terraforged.api.material.layer.LayerManager; -import com.terraforged.core.cell.Cell; -import com.terraforged.core.region.Size; -import com.terraforged.core.region.chunk.ChunkReader; -import com.terraforged.core.region.gen.RegionCache; -import com.terraforged.core.region.gen.RegionGenerator; -import com.terraforged.core.util.concurrent.ThreadPool; -import com.terraforged.core.world.decorator.Decorator; -import com.terraforged.feature.FeatureManager; -import com.terraforged.feature.matcher.dynamic.DynamicMatcher; -import com.terraforged.feature.matcher.feature.FeatureMatcher; -import com.terraforged.feature.modifier.FeatureModifierLoader; -import com.terraforged.feature.modifier.FeatureModifiers; -import com.terraforged.feature.predicate.DeepWater; -import com.terraforged.feature.predicate.FeaturePredicate; -import com.terraforged.feature.predicate.MinDepth; -import com.terraforged.feature.predicate.MinHeight; -import com.terraforged.feature.template.type.FeatureTypes; -import com.terraforged.mod.Log; -import com.terraforged.mod.biome.provider.BiomeProvider; -import com.terraforged.mod.chunk.fix.ChunkCarverFix; -import com.terraforged.mod.chunk.fix.RegionFix; -import com.terraforged.mod.decorator.ChunkPopulator; -import com.terraforged.mod.decorator.base.BedrockDecorator; -import com.terraforged.mod.decorator.base.CoastDecorator; -import com.terraforged.mod.decorator.base.ErosionDecorator; -import com.terraforged.mod.decorator.base.GeologyDecorator; -import com.terraforged.mod.decorator.feature.LayerDecorator; -import com.terraforged.mod.decorator.feature.SnowEroder; -import com.terraforged.mod.decorator.surface.FrozenOcean; -import com.terraforged.mod.feature.Matchers; -import com.terraforged.mod.feature.TerrainHelper; -import com.terraforged.mod.feature.predicate.TreeLine; -import com.terraforged.mod.material.Materials; -import com.terraforged.mod.material.geology.GeoManager; -import com.terraforged.mod.util.Environment; -import com.terraforged.mod.util.setup.SetupHooks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeManager; -import net.minecraft.world.biome.Biomes; -import net.minecraft.world.chunk.ChunkPrimer; -import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.GenerationSettings; -import net.minecraft.world.gen.GenerationStage; -import net.minecraft.world.gen.Heightmap; -import net.minecraft.world.gen.WorldGenRegion; -import net.minecraft.world.gen.feature.AbstractTreeFeature; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.template.TemplateManager; - -import java.util.ArrayList; -import java.util.List; - -public class TerraChunkGenerator extends ObfHelperChunkGenerator implements ChunkProcessor { - - private final TerraContext context; - private final BiomeProvider biomeProvider; - private final TerrainHelper terrainHelper; - - private final GeoManager geologyManager; - private final FeatureManager featureManager; - private final SurfaceManager surfaceManager; - private final List baseDecorators; - private final List postProcessors; - - private final RegionCache regionCache; - - public TerraChunkGenerator(TerraContext context, BiomeProvider biomeProvider, GenerationSettings settings) { - super(context.world, biomeProvider, settings); - this.context = context; - this.biomeProvider = biomeProvider; - this.surfaceManager = SetupHooks.setup(createSurfaceManager(), context.copy()); - this.geologyManager = SetupHooks.setup(createGeologyManager(context), context.copy()); - this.baseDecorators = createBaseDecorators(context); - this.postProcessors = createFeatureDecorators(context); - this.terrainHelper = new TerrainHelper(0.75F); - this.featureManager = createFeatureManager(context); - this.regionCache = createRegionCache(context); - SetupHooks.setup(getLayerManager(), context.copy()); - SetupHooks.setup(baseDecorators, postProcessors, context.copy()); - } - - @Override - public void generateStructures(BiomeManager biomes, IChunk chunk, ChunkGenerator generator, TemplateManager templates) { - ChunkPos pos = chunk.getPos(); - int regionX = regionCache.chunkToRegion(pos.x); - int regionZ = regionCache.chunkToRegion(pos.z); - // start generating the heightmap as early as possible - regionCache.queueRegion(regionX, regionZ); - super.generateStructures(biomes, chunk, this, templates); - } - - @Override - public final void generateBiomes(IChunk chunk) { - ChunkPos pos = chunk.getPos(); - ChunkReader reader = getChunkReader(pos.x, pos.z); - TerraContainer container = getBiomeProvider().createBiomeContainer(reader); - ((ChunkPrimer) chunk).func_225548_a_(container); - // apply chunk-local heightmap modifications - preProcess(pos, reader, container); - } - - @Override - public final void preProcess(ChunkPos pos, ChunkReader chunk, TerraContainer container) { - chunk.iterate((cell, dx, dz) -> { - Biome biome = container.getBiome(dx, dz); - for (Decorator decorator : getBiomeProvider().getDecorators(biome)) { - if (decorator.apply(cell, pos.getXStart() + dx, pos.getZStart() + dz)) { - return; - } - } - }); - } - - @Override - public final void generateBase(IWorld world, IChunk chunk) { - TerraContainer container = getBiomeContainer(chunk); - DecoratorContext context = new DecoratorContext(FastChunk.wrap(chunk), getContext().levels, getContext().terrain, getContext().factory.getClimate()); - container.getChunkReader().iterate(context, (cell, dx, dz, ctx) -> { - int px = ctx.blockX + dx; - int pz = ctx.blockZ + dz; - int py = ctx.levels.scale(cell.value); - ctx.cell = cell; - ctx.biome = container.getBiome(dx, dz); - ChunkPopulator.INSTANCE.decorate(ctx.chunk, ctx, px, py, pz); - }); - terrainHelper.flatten(world, chunk); - } - - @Override - public final void generateSurface(WorldGenRegion world, IChunk chunk) { - TerraContainer container = getBiomeContainer(chunk); - ChunkSurfaceBuffer buffer = new ChunkSurfaceBuffer(FastChunk.wrap(chunk)); - SurfaceContext context = getContext().surface(buffer, getSettings()); - - container.getChunkReader().iterate(context, (cell, dx, dz, ctx) -> { - int px = ctx.blockX + dx; - int pz = ctx.blockZ + dz; - int top = ctx.chunk.getTopBlockY(Heightmap.Type.WORLD_SURFACE_WG, dx, dz) + 1; - - ctx.buffer.setSurfaceLevel(top); - - ctx.cell = cell; - ctx.biome = container.getBiome(dx, dz); - ctx.noise = getSurfaceNoise(px, pz) * 15D; - - getSurfaceManager().getSurface(ctx).buildSurface(px, pz, top, ctx); - - int py = ctx.levels.scale(cell.value); - for (ColumnDecorator processor : getBaseDecorators()) { - processor.decorate(ctx.buffer, ctx, px, py, pz); - } - }); - - FastChunk.updateWGHeightmaps(chunk, context.pos); - } - - @Override - public final void func_225550_a_(BiomeManager biomeManager, IChunk chunk, GenerationStage.Carving carving) { - - // World carvers have hardcoded 'carvable' blocks which can be problematic with modded blocks - // AirCarverFix shims the actual blockstates to an equivalent carvable type - super.func_225550_a_(biomeManager, new ChunkCarverFix(chunk, context.materials), carving); - } - - @Override - public void decorate(WorldGenRegion region) { - int chunkX = region.getMainChunkX(); - int chunkZ = region.getMainChunkZ(); - IChunk chunk = region.getChunk(chunkX, chunkZ); - TerraContainer container = getBiomeContainer(chunk); - Biome biome = container.getFeatureBiome(); - DecoratorContext context = getContext().decorator(chunk); - - IWorld regionFix = new RegionFix(region, this); - BlockPos pos = new BlockPos(context.blockX, 0, context.blockZ); - - // place biome features - featureManager.decorate(this, regionFix, chunk, biome, pos); - - // run post processes on chunk - postProcess(container.getChunkReader(), container, context); - - // bake biome array & discard gen data - ((ChunkPrimer) chunk).func_225548_a_(container.bakeBiomes(Environment.isVanillaBiomes())); - - // marks the heightmap data for this chunk for removal - container.getChunkReader().dispose(); - } - - @Override - public final void postProcess(ChunkReader chunk, TerraContainer container, DecoratorContext context) { - chunk.iterate(context, (cell, dx, dz, ctx) -> { - int px = ctx.blockX + dx; - int pz = ctx.blockZ + dz; - int py = ctx.chunk.getTopBlockY(Heightmap.Type.WORLD_SURFACE_WG, dx, dz); - ctx.cell = cell; - ctx.biome = container.getBiome(dx, dz); - for (ColumnDecorator decorator : getPostProcessors()) { - decorator.decorate(ctx.chunk, ctx, px, py, pz); - } - }); - } - - @Override - public int getTopBlockY(int x, int z, Heightmap.Type type) { - int chunkX = Size.blockToChunk(x); - int chunkZ = Size.blockToChunk(z); - ChunkReader chunk = getChunkReader(chunkX, chunkZ); - Cell cell = chunk.getCell(x, z); - return context.levels.scale(cell.value); - } - - @Override - public BiomeProvider getBiomeProvider() { - return biomeProvider; - } - - @Override - public final int getMaxHeight() { - return getContext().levels.worldHeight; - } - - @Override - public final int getSeaLevel() { - return getContext().levels.waterLevel; - } - - @Override - public final int getGroundHeight() { - return getContext().levels.groundLevel; - } - - public final TerraContext getContext() { - return context; - } - - public final Materials getMaterials() { - return context.materials; - } - - public final GeoManager getGeologyManager() { - return geologyManager; - } - - public final LayerManager getLayerManager() { - return context.materials.getLayerManager(); - } - - public final SurfaceManager getSurfaceManager() { - return surfaceManager; - } - - public final List getBaseDecorators() { - return baseDecorators; - } - - public final List getPostProcessors() { - return postProcessors; - } - - protected TerraContainer getBiomeContainer(IChunk chunk) { - if (chunk.getBiomes() instanceof TerraContainer) { - return (TerraContainer) chunk.getBiomes(); - } - - ChunkReader view = getChunkReader(chunk.getPos().x, chunk.getPos().z); - TerraContainer container = getBiomeProvider().createBiomeContainer(view); - if (chunk instanceof ChunkPrimer) { - ((ChunkPrimer) chunk).func_225548_a_(container); - } else if (chunk instanceof FastChunk) { - ((FastChunk) chunk).setBiomes(container); - } - - return container; - } - - protected FeatureManager createFeatureManager(TerraContext context) { - FeatureModifiers modifiers; - if (context.terraSettings.features.customBiomeFeatures) { - Log.info(" - Custom biome features enabled"); - modifiers = FeatureModifierLoader.load(); - } else { - modifiers = new FeatureModifiers(); - } - - if (context.terraSettings.features.strataDecorator) { - // block stone blobs if strata enabled - modifiers.getPredicates().add(Matchers.stoneBlobs(), FeaturePredicate.DENY); - } - - if (!context.terraSettings.features.vanillaWaterFeatures) { - // block lakes and springs if not enabled - modifiers.getPredicates().add(FeatureMatcher.of(Feature.LAKE), FeaturePredicate.DENY); - modifiers.getPredicates().add(FeatureMatcher.of(Feature.SPRING_FEATURE), FeaturePredicate.DENY); - } - - // block ugly features - modifiers.getPredicates().add(Matchers.sedimentDisks(), FeaturePredicate.DENY); - - // limit to deep oceans - modifiers.getPredicates().add(FeatureMatcher.of(Feature.SHIPWRECK), MinDepth.DEPTH55); - modifiers.getPredicates().add(FeatureMatcher.of(Feature.OCEAN_RUIN), DeepWater.INSTANCE); - modifiers.getPredicates().add(FeatureMatcher.of(Feature.OCEAN_MONUMENT), DeepWater.INSTANCE); - - // prevent mineshafts above ground - modifiers.getPredicates().add(FeatureMatcher.of(Feature.MINESHAFT), MinHeight.HEIGHT80); - - // prevent trees/bamboo growing too high up - TreeLine treeLine = new TreeLine(context); - modifiers.getPredicates().add(FeatureTypes.TREE.matcher(), treeLine); - modifiers.getPredicates().add(FeatureMatcher.of(Feature.BAMBOO), treeLine); - modifiers.getDynamic().add(DynamicMatcher.feature(AbstractTreeFeature.class), treeLine); - - return FeatureManager.create(context.world, SetupHooks.setup(modifiers, context.copy())); - } - - protected GeoManager createGeologyManager(TerraContext context) { - return new GeoManager(context); - } - - protected SurfaceManager createSurfaceManager() { - SurfaceManager manager = new SurfaceManager(); - manager.replace(Biomes.FROZEN_OCEAN, new FrozenOcean(context, 20, 15)); - manager.replace(Biomes.DEEP_FROZEN_OCEAN, new FrozenOcean(context, 30, 30)); - return manager; - } - - protected List createBaseDecorators(TerraContext context) { - List processors = new ArrayList<>(); - if (context.terraSettings.features.strataDecorator) { - Log.info(" - Geology decorator enabled"); - processors.add(new GeologyDecorator(geologyManager)); - } - - if (context.terraSettings.features.erosionDecorator) { - Log.info(" - Erosion decorator enabled"); - processors.add(new ErosionDecorator(context)); - } - processors.add(new CoastDecorator(context)); - processors.add(new BedrockDecorator(context)); - return processors; - } - - protected List createFeatureDecorators(TerraContext context) { - List processors = new ArrayList<>(); - if (context.terraSettings.features.naturalSnowDecorator) { - Log.info(" - Natural snow decorator enabled"); - processors.add(new SnowEroder(context)); - } - if (context.terraSettings.features.smoothLayerDecorator) { - Log.info(" - Smooth layer decorator enabled"); - processors.add(new LayerDecorator(context.materials.getLayerManager())); - } - return processors; - } - - protected RegionCache createRegionCache(TerraContext context) { - return RegionGenerator.builder() - .legacy(context.terraSettings.version == 0) - .pool(ThreadPool.getPool()) - .factory(context.factory) - .size(3, 2) - .build() - .toCache(false); - } - - public ChunkReader getChunkReader(int chunkX, int chunkZ) { - return regionCache.getChunk(chunkX, chunkZ); - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraGenSettings.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraGenSettings.java deleted file mode 100644 index b2c034a..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraGenSettings.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.chunk; - -import com.terraforged.mod.settings.StructureSettings; -import net.minecraft.world.gen.OverworldGenSettings; - -public class TerraGenSettings extends OverworldGenSettings { - - public TerraGenSettings(StructureSettings settings) { - super.villageDistance *= settings.villageDistance; - super.mansionDistance *= settings.mansionDistance; - super.strongholdDistance *= settings.strongholdDistance; - super.strongholdSpread *= settings.strongholdSpread; - super.biomeFeatureDistance *= settings.biomeStructureDistance; - super.oceanMonumentSpacing *= settings.oceanMonumentSpacing; - super.oceanMonumentSeparation *= settings.oceanMonumentSeparation; - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/command/Permissions.java b/TerraForgedMod/src/main/java/com/terraforged/mod/command/Permissions.java deleted file mode 100644 index a8a6926..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/command/Permissions.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.terraforged.mod.command; - -public class Permissions { - - public static final String QUERY = "terraforged.command.terra.query"; - public static final String DEBUG = "terraforged.command.terra.debug"; - public static final String DATA = "terraforged.command.terra.data"; - public static final String DEFAULTS = "terraforged.command.terra.defaults"; - public static final String LOCATE = "terraforged.command.terra.locate"; -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenFeatures.java b/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenFeatures.java deleted file mode 100644 index 4c1d082..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenFeatures.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.data; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.mojang.datafixers.Dynamic; -import com.mojang.datafixers.types.JsonOps; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.GenerationStage; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.IFeatureConfig; -import net.minecraft.world.gen.feature.jigsaw.JigsawManager; -import net.minecraft.world.gen.feature.jigsaw.JigsawPattern; -import net.minecraft.world.gen.feature.jigsaw.JigsawPatternRegistry; -import net.minecraft.world.gen.feature.jigsaw.JigsawPiece; -import net.minecraft.world.gen.feature.structure.Structure; -import net.minecraftforge.registries.ForgeRegistries; - -import java.io.File; -import java.lang.reflect.Field; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Random; - -public class WorldGenFeatures extends DataGen { - - public static void genBiomeFeatures(File dataDir) { - if (dataDir.exists() || dataDir.mkdirs()) { - for (Biome biome : ForgeRegistries.BIOMES) { - genBiomeFeatures(dataDir, biome); - genBiomeStructures(dataDir, biome); - } - genBiomeJigsaws(dataDir); - } - } - - private static void genBiomeFeatures(File dir, Biome biome) { - write(new File(dir, getJsonPath("features", biome.getRegistryName())), writer -> { - JsonObject root = new JsonObject(); - for (GenerationStage.Decoration type : GenerationStage.Decoration.values()) { - JsonArray features = new JsonArray(); - for (ConfiguredFeature feature : biome.getFeatures(type)) { - try { - Dynamic dynamic = feature.serialize(JsonOps.INSTANCE); - features.add(dynamic.getValue()); - } catch (NullPointerException e) { - new NullPointerException("Badly written feature: " + feature.feature.getRegistryName()).printStackTrace(); - } - } - root.add(type.getName(), features); - } - write(root, writer); - }); - } - - private static void genBiomeStructures(File dir, Biome biome) { - write(new File(dir, getJsonPath("structures", biome.getRegistryName())), writer -> { - JsonObject root = new JsonObject(); - for (Map.Entry> e : Structure.STRUCTURES.entrySet()) { - JsonArray array = new JsonArray(); - IFeatureConfig config = biome.getStructureConfig(e.getValue()); - if (config == null) { - continue; - } - JsonElement element = config.serialize(JsonOps.INSTANCE).getValue(); - JsonObject object = new JsonObject(); - object.addProperty("structure", e.getValue().getRegistryName() + ""); - object.add("config", element); - array.add(object); - } - write(root, writer); - }); - } - - private static void genBiomeJigsaws(File dir) { - Random random = new Random(); - write(new File(dir, "jigsaws.json"), writer -> { - JsonObject root = new JsonObject(); - for (Map.Entry e : getJigsawRegistry().entrySet()) { - JsonArray array = new JsonArray(); - List pieces = e.getValue().getShuffledPieces(random); - for (JigsawPiece piece : pieces) { - JsonElement element = piece.serialize(JsonOps.INSTANCE).getValue(); - array.add(element); - } - root.add(e.getKey().toString(), array); - } - write(root, writer); - }); - } - - private static Map getJigsawRegistry() { - try { - for (Field field : JigsawPatternRegistry.class.getDeclaredFields()) { - if (field.getType() == Map.class) { - field.setAccessible(true); - Object value = field.get(JigsawManager.REGISTRY); - return (Map) value; - } - } - } catch (Throwable t) { - t.printStackTrace(); - } - return Collections.emptyMap(); - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/Poisson.java b/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/Poisson.java deleted file mode 100644 index 09d36ff..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/Poisson.java +++ /dev/null @@ -1,173 +0,0 @@ -package com.terraforged.mod.feature.decorator.poisson; - -import com.terraforged.core.util.concurrent.ObjectPool; -import me.dags.noise.Source; -import me.dags.noise.util.NoiseUtil; -import me.dags.noise.util.Vec2f; - -import javax.swing.*; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.util.Arrays; -import java.util.Random; -import java.util.function.BiConsumer; - -public class Poisson { - - private static final int SAMPLES = 50; - - private final int radius; - private final int radius2; - private final float halfRadius; - private final int maxDistance; - private final int regionSize; - private final int gridSize; - private final float cellSize; - private final ObjectPool pool; - - public Poisson(int radius) { - int size = 48; - this.radius = radius; - this.radius2 = radius * radius; - this.halfRadius = radius / 2F; - this.maxDistance = radius * 2; - this.regionSize = size - radius; - this.cellSize = radius / NoiseUtil.SQRT2; - this.gridSize = (int) Math.ceil(regionSize / cellSize); - this.pool = new ObjectPool<>(3, () -> new Vec2f[gridSize][gridSize]); - } - - public int getRadius() { - return radius; - } - - public void visit(int chunkX, int chunkZ, PoissonContext context, BiConsumer consumer) { - try (ObjectPool.Item grid = pool.get()) { - clear(grid.getValue()); - context.startX = (chunkX << 4); - context.startZ = (chunkZ << 4); - context.endX = context.startX + 16; - context.endZ = context.startZ + 16; - int regionX = (context.startX >> 5); - int regionZ = (context.startZ >> 5); - context.offsetX = regionX << 5; - context.offsetZ = regionZ << 5; - context.random.setSeed(NoiseUtil.hash2D(context.seed, regionX, regionZ)); - int x = context.random.nextInt(regionSize); - int z = context.random.nextInt(regionSize); - visit(x, z, grid.getValue(), SAMPLES, context, consumer); - } - } - - private void visit(float px, float pz, Vec2f[][] grid, int samples, PoissonContext context, BiConsumer consumer) { - for (int i = 0; i < samples; i++) { - float angle = context.random.nextFloat() * NoiseUtil.PI2; - float distance = radius + (context.random.nextFloat() * maxDistance); - float x = halfRadius + px + NoiseUtil.sin(angle) * distance; - float z = halfRadius + pz + NoiseUtil.cos(angle) * distance; - if (valid(x, z, grid, context)) { - Vec2f vec = new Vec2f(x, z); - visit(vec, context, consumer); - int cellX = (int) (x / cellSize); - int cellZ = (int) (z / cellSize); - grid[cellZ][cellX] = vec; - visit(vec.x, vec.y, grid, samples, context, consumer); - } - } - } - - private void visit(Vec2f pos, PoissonContext context, BiConsumer consumer) { - int dx = context.offsetX + (int) pos.x; - int dz = context.offsetZ + (int) pos.y; - if (dx >= context.startX && dx < context.endX && dz >= context.startZ && dz < context.endZ) { - consumer.accept(dx, dz); - } - } - - private boolean valid(float x, float z, Vec2f[][] grid, PoissonContext context) { - if (x < 0 || x >= regionSize || z < 0 || z >= regionSize) { - return false; - } - - int cellX = (int) (x / cellSize); - int cellZ = (int) (z / cellSize); - if (grid[cellZ][cellX] != null) { - return false; - } - - float noise = context.density.getValue(context.offsetX + x, context.offsetZ + z); - float radius2 = noise * this.radius2; - - int searchRadius = 2; - int minX = Math.max(0, cellX - searchRadius); - int maxX = Math.min(grid[0].length - 1, cellX + searchRadius); - int minZ = Math.max(0, cellZ - searchRadius); - int maxZ = Math.min(grid.length - 1, cellZ + searchRadius); - - for (int dz = minZ; dz <= maxZ; dz++) { - for (int dx = minX; dx <= maxX; dx++) { - Vec2f vec = grid[dz][dx]; - if (vec == null) { - continue; - } - - float dist2 = vec.dist2(x, z); - if (dist2 < radius2) { - return false; - } - } - } - return true; - } - - private static void clear(Vec2f[][] grid) { - for (Vec2f[] row : grid) { - Arrays.fill(row, null); - } - } - - public static void main(String[] args) { - int size = 512; - int radius = 6; - - int chunkSize = 16; - int chunks = size / chunkSize; - - BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB); - Poisson poisson = new Poisson(radius); - PoissonContext context = new PoissonContext(213, new Random()); - context.density = Source.simplex(213, 100, 1).scale(2).bias(0); - - long time = 0L; - long count = 0L; - - int chunkX = 342; - int chunkZ = 546; - for (int cz = 0; cz < chunks; cz++) { - for (int cx = 0; cx < chunks; cx++) { - long start = System.nanoTime(); - poisson.visit(chunkX + cx, chunkZ + cz, context, (x, z) -> { - x -= chunkX << 4; - z -= chunkZ << 4; - if (x < 0 || x >= image.getWidth() || z < 0 || z >= image.getHeight()) { - return; - } - image.setRGB(x, z, Color.WHITE.getRGB()); - }); - time += (System.nanoTime() - start); - count++; - } - } - - double avg = (double) (time / count) / 1000000; - System.out.println(avg + "ms"); - - JFrame frame = new JFrame(); - frame.add(new JLabel(new ImageIcon(image))); - frame.setVisible(true); - frame.pack(); - frame.setResizable(false); - frame.setLocationRelativeTo(null); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonContext.java b/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonContext.java deleted file mode 100644 index 7c6c512..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonContext.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.terraforged.mod.feature.decorator.poisson; - -import me.dags.noise.Module; -import me.dags.noise.Source; - -import java.util.Random; - -public class PoissonContext { - - public int offsetX; - public int offsetZ; - public int startX; - public int startZ; - public int endX; - public int endZ; - public Module density = Source.ONE; - - public final int seed; - public final Random random; - - public PoissonContext(long seed, Random random) { - this.seed = (int) seed; - this.random = random; - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingConfig.java b/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingConfig.java deleted file mode 100644 index 70b4333..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingConfig.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.feature.tree; - -import com.google.gson.reflect.TypeToken; -import com.mojang.datafixers.types.DynamicOps; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.NoFeatureConfig; -import net.minecraftforge.registries.ForgeRegistries; - -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class SaplingConfig { - - private static final TypeToken> TOKEN = new TypeToken>() { - }; - - private final Map normal; - private final Map giant; - - public SaplingConfig() { - normal = new HashMap<>(); - giant = new HashMap<>(); - } - - public SaplingConfig(T config, DynamicOps ops) { - this.normal = getSection("normal", config, ops); - this.giant = getSection("giant", config, ops); - } - - public SaplingConfig addNormal(ResourceLocation name, int weight) { - normal.put(name, weight); - return this; - } - - public SaplingConfig addNormal(String name, int weight) { - normal.put(new ResourceLocation(name), weight); - return this; - } - - public SaplingConfig addGiant(ResourceLocation name, int weight) { - giant.put(name, weight); - return this; - } - - public SaplingConfig addGiant(String name, int weight) { - giant.put(new ResourceLocation(name), weight); - return this; - } - - private Map getSection(String key, T config, DynamicOps ops) { - return ops.get(config, key).flatMap(ops::getMapValues).map(map -> { - Map backing = new HashMap<>(); - - for (Map.Entry entry : map.entrySet()) { - String name = ops.getStringValue(entry.getKey()).orElse(""); - int weight = ops.getNumberValue(entry.getValue()).orElse(0).intValue(); - if (name.isEmpty() || weight == 0) { - continue; - } - - ResourceLocation loc = new ResourceLocation(name); - backing.put(loc, weight); - } - - return backing; - }).orElse(Collections.emptyMap()); - } - - public List> getNormal() { - return build(normal); - } - - public List> getGiant() { - return build(giant); - } - - @SuppressWarnings("unchecked") - public static List> build(Map map) { - List> list = new LinkedList<>(); - for (Map.Entry entry : map.entrySet()) { - Feature feature = ForgeRegistries.FEATURES.getValue(entry.getKey()); - if (feature == null) { - continue; - } - - if (TOKEN.getRawType().isAssignableFrom(feature.getClass())) { - Feature noConfFeature = (Feature) feature; - list.add(noConfFeature); - } - } - return list; - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingFeature.java b/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingFeature.java deleted file mode 100644 index b8204ff..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingFeature.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.feature.tree; - -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.NoFeatureConfig; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -public class SaplingFeature { - - private final List> normal; - private final List> giant; - - public SaplingFeature(SaplingConfig config) { - this.normal = new ArrayList<>(config.getNormal()); - this.giant = new ArrayList<>(config.getGiant()); - } - - public Feature nextNormal(Random random) { - if (normal.isEmpty()) { - return null; - } - return normal.get(random.nextInt(normal.size())); - } - - public Feature nextGiant(Random random) { - if (giant.isEmpty()) { - return null; - } - return giant.get(random.nextInt(giant.size())); - } - - public int getNormalCount() { - return normal.size(); - } - - public int getGiantCount() { - return giant.size(); - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingListener.java b/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingListener.java deleted file mode 100644 index 7836573..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingListener.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.feature.tree; - -import com.terraforged.mod.TerraWorld; -import com.terraforged.mod.chunk.TerraChunkGenerator; -import com.terraforged.mod.chunk.TerraContext; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SaplingBlock; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3i; -import net.minecraft.world.IWorld; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.NoFeatureConfig; -import net.minecraft.world.server.ServerWorld; -import net.minecraftforge.event.world.SaplingGrowTreeEvent; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; - -@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE) -public class SaplingListener { - - private static final BlockPos[] NONE = {BlockPos.ZERO}; - - private static final Vec3i[][] DIRECTIONS = { - {new Vec3i(0, 0, 1), new Vec3i(1, 0, 1), new Vec3i(1, 0, 0)}, - {new Vec3i(1, 0, 0), new Vec3i(1, 0, -1), new Vec3i(0, 0, -1)}, - {new Vec3i(0, 0, -1), new Vec3i(-1, 0, -1), new Vec3i(-1, 0, 0)}, - {new Vec3i(-1, 0, 0), new Vec3i(-1, 0, 1), new Vec3i(0, 0, 1)}, - }; - - @SubscribeEvent(priority = EventPriority.LOWEST) - public static void onTreeGrow(SaplingGrowTreeEvent event) { - // ignore if client - if (event.getWorld().isRemote()) { - return; - } - // ignore other world types - if (!TerraWorld.isTerraWorld(event.getWorld())) { - return; - } - // has user disabled custom trees? - if (!areCustomTreesEnabled(event.getWorld())) { - return; - } - - IWorld world = event.getWorld(); - BlockPos pos = event.getPos(); - Block block = world.getBlockState(pos).getBlock(); - if (block instanceof SaplingBlock) { - // get the sapling feature for the given block type - SaplingFeature tree = SaplingManager.getSapling(block.getRegistryName()); - - // tree is null if the sapling type hasn't been configured - if (tree == null) { - return; - } - - // check for a 2x2 arrangement of sapling blocks around the position - Vec3i[] directions = getNeighbourDirections(world, block, pos); - - // length is 1 if a full 2x2 arrangement could not be found - if (directions.length == 1) { - placeNormal(tree, event, directions); - } else { - placeGiant(tree, event, block, directions); - } - } - } - - private static void placeNormal(SaplingFeature tree, SaplingGrowTreeEvent event, Vec3i[] directions) { - SaplingPlacer.placeTree(tree.nextNormal(event.getRand()), event, directions); - } - - private static void placeGiant(SaplingFeature tree, SaplingGrowTreeEvent event, Block type, Vec3i[] directions) { - Feature feature = tree.nextGiant(event.getRand()); - - // if no giant tree exists for this sapling type try and place a normal one instead - if (feature == null) { - placeNormal(tree, event, directions); - return; - } - - // do not continue if unable to place the tree - if (!SaplingPlacer.placeTree(feature, event, directions)) { - return; - } - - // iterate through the contributing saplings and remove any that were not destroyed during tree creation - BlockPos pos = event.getPos(); - for (Vec3i dir : directions) { - BlockPos blockPos = pos.add(dir); - BlockState state = event.getWorld().getBlockState(blockPos); - if (state.getBlock() == type) { - event.getWorld().removeBlock(blockPos, false); - } - } - } - - private static Vec3i[] getNeighbourDirections(IWorld world, Block block, BlockPos pos) { - for (Vec3i[] dirs : DIRECTIONS) { - boolean match = true; - for (Vec3i dir : dirs) { - BlockState state = world.getBlockState(pos.add(dir)); - if (state.getBlock() != block) { - match = false; - break; - } - } - if (match) { - return dirs; - } - } - return NONE; - } - - private static boolean areCustomTreesEnabled(IWorld world) { - if (world instanceof ServerWorld) { - ServerWorld serverWorld = (ServerWorld) world; - ChunkGenerator generator = serverWorld.getChunkProvider().generator; - if (generator instanceof TerraChunkGenerator) { - TerraContext context = ((TerraChunkGenerator) generator).getContext(); - return context.terraSettings.features.customBiomeFeatures; - } - } - return false; - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingManager.java b/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingManager.java deleted file mode 100644 index 9335703..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingManager.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.feature.tree; - -import com.mojang.datafixers.types.DynamicOps; -import com.terraforged.mod.Log; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.util.ResourceLocation; - -import java.util.HashMap; -import java.util.Map; - -public class SaplingManager { - - private static final Map saplings = new HashMap<>(); - - public static SaplingFeature getSapling(ResourceLocation name) { - return saplings.get(name); - } - - public static void register(Block block, SaplingConfig config) { - register(block.getRegistryName(), config); - } - - public static void register(ResourceLocation location, T config, DynamicOps ops) { - register(location, new SaplingConfig(config, ops)); - } - - public static void register(ResourceLocation location, SaplingConfig config) { - saplings.put(location, new SaplingFeature(config)); - } - - public static void init() { - register(Blocks.OAK_SAPLING, new SaplingConfig() - .addNormal("terraforged:oak_small", 4) - .addNormal("terraforged:oak_forest", 3) - .addNormal("terraforged:oak_large", 2) - .addGiant("terraforged:oak_huge", 1)); - - register(Blocks.BIRCH_SAPLING, new SaplingConfig() - .addNormal("terraforged:birch_small", 4) - .addNormal("terraforged:birch_forest", 3) - .addNormal("terraforged:birch_large", 1)); - - register(Blocks.JUNGLE_SAPLING, new SaplingConfig() - .addNormal("terraforged:jungle_small", 4) - .addGiant("terraforged:jungle_large", 1)); - - register( - Blocks.SPRUCE_SAPLING, - new SaplingConfig() - .addNormal("terraforged:spruce_small", 4) - .addNormal("terraforged:spruce_large", 1) - .addGiant("terraforged:redwood_huge", 1)); - - register(Blocks.DARK_OAK_SAPLING, new SaplingConfig() - .addNormal("terraforged:dark_oak_small", 4) - .addNormal("terraforged:dark_oak_large", 1)); - - register(Blocks.ACACIA_SAPLING, new SaplingConfig() - .addNormal("terraforged:acacia_small", 2) - .addNormal("terraforged:acacia_large", 1)); - - Log.info("Registered saplings"); - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingPlacer.java b/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingPlacer.java deleted file mode 100644 index 5c335ab..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/SaplingPlacer.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.feature.tree; - -import com.terraforged.feature.template.decorator.DecoratedFeature; -import com.terraforged.feature.template.decorator.DecoratorWorld; -import com.terraforged.feature.template.feature.TemplateFeature; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3i; -import net.minecraft.world.IWorld; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.NoFeatureConfig; -import net.minecraft.world.server.ServerChunkProvider; -import net.minecraftforge.event.world.SaplingGrowTreeEvent; -import net.minecraftforge.eventbus.api.Event; - -public class SaplingPlacer { - - public static boolean placeTree(Feature feature, SaplingGrowTreeEvent event, Vec3i[] dirs) { - if (feature == null) { - return false; - } - - event.setResult(Event.Result.DENY); - - if (feature instanceof DecoratedFeature) { - return placeDecorated((DecoratedFeature) feature, event, dirs); - } - - return placeNormal(feature, event, dirs); - } - - private static boolean placeDecorated(DecoratedFeature feature, SaplingGrowTreeEvent event, Vec3i[] dirs) { - if (!(event.getWorld().getChunkProvider() instanceof ServerChunkProvider)) { - return false; - } - - TreeGrowBuffer buffer = new TreeGrowBuffer(event.getWorld(), event.getPos()); - W world = feature.wrap(buffer); - - ChunkGenerator generator = ((ServerChunkProvider) event.getWorld().getChunkProvider()).getChunkGenerator(); - feature.placeFeature(world, generator, event.getRand(), event.getPos(), NoFeatureConfig.NO_FEATURE_CONFIG); - - // check that the tree can grow here - if (overheadIsSolid(event.getWorld(), event.getPos(), buffer.getTopY())) { - return false; - } - - BlockPos translation = buffer.getBaseMin().add(getMin(dirs)); - - // apply buffer to world with translation - applyBuffer(buffer, event.getWorld(), translation); - - // translate the decoration positions and apply in the world - world.setDelegate(event.getWorld()); - world.translate(translation); - feature.decorate(world, event.getRand()); - return true; - } - - private static boolean placeNormal(Feature feature, SaplingGrowTreeEvent event, Vec3i[] dirs) { - // apply the feature to a buffer - TreeGrowBuffer buffer = new TreeGrowBuffer(event.getWorld(), event.getPos()); - buffer.placeFeature(feature, event.getPos(), event.getRand()); - - // check that the tree can grow here - if (overheadIsSolid(event.getWorld(), event.getPos(), buffer.getTopY())) { - return false; - } - - // get the min position in the 2x2 grid - BlockPos translation = buffer.getBaseMin().add(getMin(dirs)); - - // copy the feature from the buffer to the world while translating each block - applyBuffer(buffer, event.getWorld(), translation); - return true; - } - - private static void applyBuffer(TreeGrowBuffer buffer, IWorld world, BlockPos translation) { - try (BlockPos.PooledMutable pos = BlockPos.PooledMutable.retain()) { - for (TemplateFeature.BlockInfo block : buffer.getChanges()) { - int x = block.getPos().getX() + translation.getX(); - int y = block.getPos().getY(); - int z = block.getPos().getZ() + translation.getZ(); - - pos.setPos(x, y, z); - - BlockState current = world.getBlockState(pos); - if (current.isSolid()) { - continue; - } - - world.setBlockState(pos, block.getState(), 2); - } - } - } - - private static boolean overheadIsSolid(IWorld world, BlockPos pos, int topY) { - try (BlockPos.PooledMutable blockPos = BlockPos.PooledMutable.retain()) { - for (int y = pos.getY(); y <= topY; y++) { - blockPos.setPos(pos.getX(), y, pos.getZ()); - BlockState state = world.getBlockState(pos); - if (state.isSolid()) { - return true; - } - } - return false; - } - } - - private static Vec3i getMin(Vec3i[] dirs) { - Vec3i min = Vec3i.NULL_VECTOR; - for (Vec3i dir : dirs) { - if (dir.getX() < min.getX() && dir.getZ() <= min.getZ()) { - min = dir; - continue; - } - if (dir.getZ() < min.getZ() && dir.getX() <= min.getX()) { - min = dir; - } - } - return min; - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/TreeGrowBuffer.java b/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/TreeGrowBuffer.java deleted file mode 100644 index 27a5371..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/tree/TreeGrowBuffer.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.feature.tree; - -import com.terraforged.feature.template.feature.TemplateFeature; -import com.terraforged.feature.util.WorldDelegate; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3i; -import net.minecraft.world.IWorld; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.IFeatureConfig; -import net.minecraft.world.gen.feature.NoFeatureConfig; -import net.minecraft.world.server.ServerChunkProvider; - -import java.util.LinkedList; -import java.util.List; -import java.util.Random; - -public class TreeGrowBuffer extends WorldDelegate { - - private int topY = 0; - private final BlockPos pos; - private final MutableVec3i baseMin = new MutableVec3i(0); - private final MutableVec3i baseMax = new MutableVec3i(0); - private final List changes = new LinkedList<>(); - - public TreeGrowBuffer(IWorld delegate, BlockPos pos) { - super(delegate); - this.pos = pos; - } - - public int getTopY() { - return topY; - } - - public BlockPos getBaseMin() { - return new BlockPos(-baseMin.x, baseMin.y, -baseMin.z); - } - - public BlockPos getBaseMax() { - return new BlockPos(baseMax.x, baseMax.y, baseMax.z); - } - - public Iterable getChanges() { - return changes; - } - - @Override - public boolean setBlockState(BlockPos pos, BlockState state, int i) { - if (pos.getY() < this.pos.getY()) { - return false; - } - if (state.isSolid()) { - recordPos(pos); - } - changes.add(new TemplateFeature.BlockInfo(pos, state)); - return true; - } - - public void placeFeature(Feature feature, BlockPos pos, Random random) { - placeFeature(feature, pos, random, NoFeatureConfig.NO_FEATURE_CONFIG); - } - - public void placeFeature(Feature feature, BlockPos pos, Random random, T config) { - if (getChunkProvider() instanceof ServerChunkProvider) { - ServerChunkProvider chunkProvider = (ServerChunkProvider) getChunkProvider(); - feature.place(this, chunkProvider.getChunkGenerator(), random, pos, config); - } - } - - private void recordPos(BlockPos pos) { - if (pos.getY() > topY) { - topY = pos.getY(); - baseMax.max(pos.subtract(this.pos)); - } else if (pos.getY() == this.pos.getY()) { - baseMin.min(pos.subtract(this.pos)); - } - } - - private static class MutableVec3i { - - private int x, y, z; - - private MutableVec3i(int start) { - x = start; - y = start; - z = start; - } - - private void min(Vec3i vec) { - x = Math.min(x, vec.getX()); - y = Math.min(y, vec.getY()); - z = Math.min(z, vec.getZ()); - } - - private void max(Vec3i vec) { - x = Math.max(x, vec.getX()); - y = Math.max(y, vec.getY()); - z = Math.max(z, vec.getZ()); - } - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/DimensionsPage.java b/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/DimensionsPage.java deleted file mode 100644 index 0fece56..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/DimensionsPage.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.terraforged.mod.gui.page; - -import com.terraforged.mod.TerraWorld; -import com.terraforged.mod.gui.OverlayScreen; -import com.terraforged.mod.gui.element.TerraTextInput; -import com.terraforged.mod.settings.TerraSettings; -import com.terraforged.mod.util.nbt.NBTHelper; -import net.minecraft.client.gui.widget.Widget; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.nbt.StringNBT; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.WorldType; -import net.minecraftforge.registries.ForgeRegistries; - -public class DimensionsPage extends BasePage { - - private final TerraSettings settings; - private final CompoundNBT dimensionSettings; - - public DimensionsPage(TerraSettings settings) { - this.settings = settings; - this.dimensionSettings = NBTHelper.serialize(settings.dimensions); - - CompoundNBT generators = dimensionSettings.getCompound("dimensionGenerators").getCompound("value"); - for (String name : generators.keySet()) { - CompoundNBT setting = generators.getCompound(name); - setting.put("#options", getWorldTypes()); - } - } - - @Override - public String getTitle() { - return "Dimension Settings"; - } - - @Override - public void save() { - NBTHelper.deserialize(dimensionSettings, settings.dimensions); - } - - @Override - public void init(OverlayScreen parent) { - Column left = getColumn(0); - addElements(left.left, left.top, left, dimensionSettings, true, left.scrollPane::addButton, this::update); - } - - @Override - public void onAddWidget(Widget widget) { - if (widget instanceof TerraTextInput) { - TerraTextInput input = (TerraTextInput) widget; - input.setColorValidator(string -> ForgeRegistries.BLOCKS.containsKey(new ResourceLocation(string))); - } - } - - private static ListNBT getWorldTypes() { - ListNBT options = new ListNBT(); - for (WorldType type : WorldType.WORLD_TYPES) { - if (type == null || (type.getId() >= 1 && type.getId() <= 6) || type.getId() == 8) { - continue; - } - if (!TerraWorld.isTerraType(type)) { - options.add(StringNBT.valueOf(type.getName())); - } - } - return options; - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/FilterPage.java b/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/FilterPage.java deleted file mode 100644 index 9d48767..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/FilterPage.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.gui.page; - -import com.terraforged.core.settings.Settings; -import com.terraforged.mod.gui.OverlayScreen; -import com.terraforged.mod.gui.preview.PreviewPage; -import com.terraforged.mod.util.nbt.NBTHelper; -import net.minecraft.nbt.CompoundNBT; - -public class FilterPage extends BasePage { - - private final Settings settings; - private final PreviewPage preview; - private final CompoundNBT filterSettings; - - public FilterPage(Settings settings, PreviewPage preview) { - this.settings = settings; - this.preview = preview; - this.filterSettings = NBTHelper.serialize(settings.filters); - } - - @Override - public String getTitle() { - return "Filter Settings"; - } - - @Override - public void save() { - NBTHelper.deserialize(filterSettings, settings.filters); - } - - @Override - public void init(OverlayScreen parent) { - Column column = getColumn(0); - addElements(0, 0, column, filterSettings, true, column.scrollPane::addButton, this::update); - } - - @Override - protected void update() { - super.update(); - preview.apply(settings -> NBTHelper.deserialize(filterSettings, settings.filters)); - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/GeneratorPage.java b/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/GeneratorPage.java deleted file mode 100644 index ff979a1..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/GeneratorPage.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.gui.page; - -import com.terraforged.core.settings.Settings; -import com.terraforged.mod.gui.OverlayScreen; -import com.terraforged.mod.gui.preview.PreviewPage; -import com.terraforged.mod.util.nbt.NBTHelper; -import net.minecraft.nbt.CompoundNBT; - -public class GeneratorPage extends BasePage { - - private final Settings settings; - private final PreviewPage preview; - private final CompoundNBT generatorSettings; - - public GeneratorPage(Settings settings, PreviewPage preview) { - this.settings = settings; - this.preview = preview; - this.generatorSettings = NBTHelper.serialize(settings.generator); - } - - @Override - public String getTitle() { - return "Generator Settings"; - } - - @Override - public void save() { - NBTHelper.deserialize(generatorSettings, settings.generator); - } - - @Override - public void init(OverlayScreen parent) { - Column left = getColumn(0); - addElements(left.left, left.top, left, generatorSettings, true, left.scrollPane::addButton, this::update); - } - - protected void update() { - super.update(); - preview.apply(settings -> NBTHelper.deserialize(generatorSettings, settings.generator)); - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/nbt/NBTWriter.java b/TerraForgedMod/src/main/java/com/terraforged/mod/util/nbt/NBTWriter.java deleted file mode 100644 index a2a0550..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/util/nbt/NBTWriter.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.util.nbt; - -import com.terraforged.core.util.serialization.serializer.Writer; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.FloatNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.IntNBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.nbt.StringNBT; - -public class NBTWriter implements Writer { - - private final Context root = new Context(null); - - private String name = ""; - private Context context = root; - - public NBTWriter() { - - } - - public INBT root() { - return root.value; - } - - public CompoundNBT compound() { - return (CompoundNBT) root(); - } - - public ListNBT list() { - return (ListNBT) root(); - } - - private NBTWriter begin(INBT value) { - if (root.value == null) { - root.value = value; - context.value = value; - } else { - append(value); - context = new Context(context); - context.value = value; - } - return this; - } - - private NBTWriter append(INBT value) { - if (context.value instanceof CompoundNBT) { - ((CompoundNBT) context.value).put(name, value); - } else if (context.value instanceof ListNBT) { - ((ListNBT) context.value).add(value); - } - return this; - } - - @Override - public NBTWriter name(String name) { - this.name = name; - return this; - } - - @Override - public NBTWriter beginObject() { - return begin(new CompoundNBT()); - } - - @Override - public NBTWriter endObject() { - context = context.parent; - return this; - } - - @Override - public NBTWriter beginArray() { - return begin(new ListNBT()); - } - - @Override - public NBTWriter endArray() { - context = context.parent; - return this; - } - - @Override - public NBTWriter value(String value) { - return append(StringNBT.valueOf(value)); - } - - @Override - public NBTWriter value(float value) { - return append(FloatNBT.valueOf(value)); - } - - @Override - public NBTWriter value(int value) { - return append(IntNBT.valueOf(value)); - } - - private static class Context { - - private final Context parent; - private INBT value; - - private Context(Context root) { - this.parent = root; - } - } -} diff --git a/TerraForgedMod/src/main/resources/assets/terraforged/lang/en_us.json b/TerraForgedMod/src/main/resources/assets/terraforged/lang/en_us.json deleted file mode 100644 index 529f20c..0000000 --- a/TerraForgedMod/src/main/resources/assets/terraforged/lang/en_us.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "generator.terraforged": "TerraForged", - "generator.terratest": "TerraTest", - "biome.terraforged.cold_steppe": "Cold Steppe", - "biome.terraforged.marshland": "Marshland", - "biome.terraforged.savanna_scrub": "Savanna Scrub", - "biome.terraforged.shattered_savanna_scrub": "Shattered Savanna Scrub", - "biome.terraforged.snowy_taiga_scrub": "Snowy Taiga Scrub", - "biome.terraforged.steppe": "Steppe", - "biome.terraforged.taiga_scrub": "Taiga Scrub", - "biome.terraforged.warm_beach": "Warm Beach" -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/birch_oak.json b/TerraForgedMod/src/main/resources/data/terraforged/features/trees/birch_oak.json deleted file mode 100644 index e9ffca8..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/birch_oak.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "biomes": [ - "minecraft:wooded_hills" - ], - "match": [ - [ - "minecraft:birch_log", - "minecraft:birch_leaves", - "minecraft:oak_log", - "minecraft:oak_leaves" - ] - ], - "replace": { - "name": "minecraft:decorated", - "config": { - "feature": { - "name": "minecraft:random_selector", - "config": { - "features": [ - { - "name": "terraforged:birch_forest", - "config": {}, - "chance": 0.2 - }, - { - "name": "terraforged:birch_large", - "config": {}, - "chance": 0.2 - }, - { - "name": "terraforged:oak_forest", - "config": {}, - "chance": 0.2 - }, - { - "name": "terraforged:oak_large", - "config": {}, - "chance": 0.2 - } - ], - "default": { - "name": "terraforged:birch_forest", - "config": {} - } - } - }, - "decorator": { - "name": "minecraft:count_extra_heightmap", - "config": { - "count": 20, - "extra_chance": 0.1, - "extra_count": 1 - } - } - } - } -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/flower_forest.json b/TerraForgedMod/src/main/resources/data/terraforged/features/trees/flower_forest.json deleted file mode 100644 index d399328..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/flower_forest.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "biomes": [ - "minecraft:flower_forest" - ], - "match": [ - [ - "minecraft:oak_log", - "minecraft:oak_leaves" - ] - ], - "replace": { - "name": "minecraft:decorated", - "config": { - "feature": { - "name": "minecraft:random_selector", - "config": { - "features": [ - { - "name": "terraforged:birch_forest", - "config": {}, - "chance": 0.2 - }, - { - "name": "terraforged:birch_large", - "config": {}, - "chance": 0.2 - }, - { - "name": "terraforged:oak_forest", - "config": {}, - "chance": 0.2 - }, - { - "name": "terraforged:oak_large", - "config": {}, - "chance": 0.2 - } - ], - "default": { - "name": "terraforged:birch_forest", - "config": {} - } - } - }, - "decorator": { - "name": "minecraft:count_extra_heightmap", - "config": { - "count": 2, - "extra_chance": 0.1, - "extra_count": 2 - } - } - } - } -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/jungle_edge.json b/TerraForgedMod/src/main/resources/data/terraforged/features/trees/jungle_edge.json deleted file mode 100644 index 638dfc5..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/jungle_edge.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "biomes": [ - "minecraft:jungle_edge", - "minecraft:modified_jungle_edge" - ], - "match": [ - [ - "minecraft:fancy_tree" - ] - ], - "replace": { - "name": "minecraft:decorated", - "config": { - "feature": { - "name": "minecraft:random_selector", - "config": { - "features": [ - { - "name": "terraforged:jungle_small", - "config": {}, - "chance": 0.2 - }, - { - "name": "terraforged:jungle_large", - "config": {}, - "chance": 0.3 - } - ], - "default": { - "name": "terraforged:jungle_small", - "config": {} - } - } - }, - "decorator": { - "name": "minecraft:count_extra_heightmap", - "config": { - "count": 3, - "extra_chance": 0.25, - "extra_count": 1 - } - } - } - } -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/oak_forest.json b/TerraForgedMod/src/main/resources/data/terraforged/features/trees/oak_forest.json deleted file mode 100644 index dd1ff71..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/oak_forest.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "biomes": [ - "minecraft:forest" - ], - "match": [ - [ - "minecraft:oak_log", - "minecraft:oak_leaves" - ] - ], - "replace": { - "name": "minecraft:decorated", - "config": { - "feature": { - "name": "minecraft:random_selector", - "config": { - "features": [ - { - "name": "terraforged:oak_forest", - "config": {}, - "chance": 0.2 - }, - { - "name": "terraforged:oak_large", - "config": {}, - "chance": 0.3 - } - ], - "default": { - "name": "terraforged:oak_forest", - "config": {} - } - } - }, - "decorator": { - "name": "minecraft:count_extra_heightmap", - "config": { - "count": 10, - "extra_chance": 0.1, - "extra_count": 2 - } - } - } - } -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/redwood.json b/TerraForgedMod/src/main/resources/data/terraforged/features/trees/redwood.json deleted file mode 100644 index e9fb356..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/redwood.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "biomes": [ - "minecraft:*" - ], - "match": [ - [ - "minecraft:mega_spruce_tree" - ] - ], - "replace": { - "name": "minecraft:decorated", - "config": { - "feature": { - "name": "minecraft:random_selector", - "config": { - "features": [ - { - "name": "terraforged:redwood_huge", - "config": {}, - "chance": 0.025641026 - }, - { - "name": "terraforged:pine", - "config": {}, - "chance": 0.15 - }, - { - "name": "terraforged:redwood_large", - "config": {}, - "chance": 0.33333334 - } - ], - "default": { - "name": "terraforged:redwood_large", - "config": {} - } - } - }, - "decorator": { - "name": "minecraft:count_extra_heightmap", - "config": { - "count": 10, - "extra_chance": 0.1, - "extra_count": 1 - } - } - } - } -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_1.nbt deleted file mode 100644 index 08257a8..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_2.nbt deleted file mode 100644 index 48cc4db..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_3.nbt deleted file mode 100644 index 7385cf3..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_4.nbt deleted file mode 100644 index b3f6430..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_5.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_5.nbt deleted file mode 100644 index e741a4e..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_5.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_7.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_7.nbt deleted file mode 100644 index 2d3a9e4..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_7.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_musroom_6.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_musroom_6.nbt deleted file mode 100644 index 7e39414..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_musroom_6.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_1.nbt deleted file mode 100644 index 811c3ad..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_2.nbt deleted file mode 100644 index 5ac6bc5..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_3.nbt deleted file mode 100644 index 80c3b2f..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_4.nbt deleted file mode 100644 index f4ee702..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_5.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_5.nbt deleted file mode 100644 index d4e55b1..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_5.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/bush/acacia_bush_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/bush/acacia_bush_1.nbt deleted file mode 100644 index d6dc4ac..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/bush/acacia_bush_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/bush/acacia_bush_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/bush/acacia_bush_2.nbt deleted file mode 100644 index d6dc4ac..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/bush/acacia_bush_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/large/acacia_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/large/acacia_1.nbt deleted file mode 100644 index 17e91d1..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/large/acacia_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/large/acacia_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/large/acacia_2.nbt deleted file mode 100644 index c80c016..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/large/acacia_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/small/acacia_small_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/small/acacia_small_1.nbt deleted file mode 100644 index de1dc6d..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/small/acacia_small_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/small/acacia_small_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/small/acacia_small_2.nbt deleted file mode 100644 index fbfe087..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/acacia/small/acacia_small_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_1.nbt deleted file mode 100644 index a207f2e..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_2.nbt deleted file mode 100644 index e20cd28..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_3.nbt deleted file mode 100644 index e14b0e1..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_4.nbt deleted file mode 100644 index 03675e3..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/large/birch_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/large/birch_1.nbt deleted file mode 100644 index 3ecd569..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/large/birch_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/large/birch_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/large/birch_2.nbt deleted file mode 100644 index a729f97..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/large/birch_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/large/birch_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/large/birch_3.nbt deleted file mode 100644 index 28c32ab..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/large/birch_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_bush_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_bush_1.nbt deleted file mode 100644 index 6598771..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_bush_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_bush_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_bush_2.nbt deleted file mode 100644 index 135d305..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_bush_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_small_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_small_1.nbt deleted file mode 100644 index 6499e1c..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_small_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_small_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_small_2.nbt deleted file mode 100644 index 559a1b0..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/birch/small/birch_small_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_1.nbt deleted file mode 100644 index b0dced8..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_2.nbt deleted file mode 100644 index bcd2635..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_3.nbt deleted file mode 100644 index 3d5c4a8..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_4.nbt deleted file mode 100644 index f7a72fc..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_5.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_5.nbt deleted file mode 100644 index a20faf1..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_5.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_1.nbt deleted file mode 100644 index f4cefe7..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_2.nbt deleted file mode 100644 index aca73e6..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_3.nbt deleted file mode 100644 index e271a5d..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_bush_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_bush_1.nbt deleted file mode 100644 index 25bfaa9..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_bush_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_bush_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_bush_2.nbt deleted file mode 100644 index 88b159b..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_bush_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_1.nbt deleted file mode 100644 index f6e7ddc..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_2.nbt deleted file mode 100644 index 557b4b4..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_3.nbt deleted file mode 100644 index a9068dc..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_4.nbt deleted file mode 100644 index 32bcd61..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_5.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_5.nbt deleted file mode 100644 index 842471c..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_5.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_6.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_6.nbt deleted file mode 100644 index 77e8e14..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_6.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_1.nbt deleted file mode 100644 index 975566d..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_2.nbt deleted file mode 100644 index e298e80..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_3.nbt deleted file mode 100644 index 7ebb022..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_4.nbt deleted file mode 100644 index a3abdbc..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_1.nbt deleted file mode 100644 index 37c90f7..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_2.nbt deleted file mode 100644 index eae5e04..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_3.nbt deleted file mode 100644 index 14dc95b..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/forest/forest_oak_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/forest/forest_oak_1.nbt deleted file mode 100644 index 2e0d9de..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/forest/forest_oak_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/forest/forest_oak_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/forest/forest_oak_2.nbt deleted file mode 100644 index c044495..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/forest/forest_oak_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/huge/oak_big_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/huge/oak_big_1.nbt deleted file mode 100644 index 06387f7..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/huge/oak_big_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/huge/oak_big_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/huge/oak_big_2.nbt deleted file mode 100644 index 63982e3..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/huge/oak_big_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_1.nbt deleted file mode 100644 index aecb79c..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_2.nbt deleted file mode 100644 index aecb79c..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_3.nbt deleted file mode 100644 index fb741e8..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_4.nbt deleted file mode 100644 index 8dccea0..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_5.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_5.nbt deleted file mode 100644 index 0d95ab0..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/large/oak_5.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_bush_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_bush_1.nbt deleted file mode 100644 index 66cd106..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_bush_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_bush_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_bush_2.nbt deleted file mode 100644 index e5e5f52..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_bush_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_1.nbt deleted file mode 100644 index 39338cb..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_2.nbt deleted file mode 100644 index 441a181..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_3.nbt deleted file mode 100644 index 5788941..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_4.nbt deleted file mode 100644 index 31e8968..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_1.nbt deleted file mode 100644 index 873740e..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_2.nbt deleted file mode 100644 index cbfaff2..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_3.nbt deleted file mode 100644 index 53d7c1b..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_1.nbt deleted file mode 100644 index ae5ee8c..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_2.nbt deleted file mode 100644 index 1f8c56c..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_small_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_small_1.nbt deleted file mode 100644 index 19f44b4..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_small_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_small_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_small_2.nbt deleted file mode 100644 index dcd6a0c..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_small_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/stone_pine_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/stone_pine_1.nbt deleted file mode 100644 index 8e59f5c..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/stone_pine_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/stone_pine_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/stone_pine_2.nbt deleted file mode 100644 index e952b2a..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/pine/stone_pine_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_1.nbt deleted file mode 100644 index 844a9e4..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_2.nbt deleted file mode 100644 index 7183b7a..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_3.nbt deleted file mode 100644 index 7f7417f..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_4.nbt deleted file mode 100644 index 4ce6494..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_5.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_5.nbt deleted file mode 100644 index 377d1f6..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_5.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_6.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_6.nbt deleted file mode 100644 index 0db8d0c..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_6.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_1.nbt deleted file mode 100644 index f548aa5..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_2.nbt deleted file mode 100644 index afa43f1..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_3.nbt deleted file mode 100644 index abaaa84..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_4.nbt deleted file mode 100644 index a9b8c42..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/bush/spruce_bush_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/bush/spruce_bush_1.nbt deleted file mode 100644 index 9773995..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/bush/spruce_bush_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/bush/spruce_bush_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/bush/spruce_bush_2.nbt deleted file mode 100644 index 00b6325..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/bush/spruce_bush_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_1.nbt deleted file mode 100644 index f98ae16..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_2.nbt deleted file mode 100644 index 195d494..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_3.nbt deleted file mode 100644 index afa1449..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_4.nbt deleted file mode 100644 index ecd2945..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_5.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_5.nbt deleted file mode 100644 index 4521bd6..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_5.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_1.nbt deleted file mode 100644 index 2a8ba15..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_2.nbt deleted file mode 100644 index 195d494..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_3.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_3.nbt deleted file mode 100644 index e2b27f8..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_3.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_4.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_4.nbt deleted file mode 100644 index 9a1f793..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_4.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_1.nbt deleted file mode 100644 index 52b80b3..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_2.nbt deleted file mode 100644 index 2f46f61..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/small/weeping_willow_small_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/small/weeping_willow_small_1.nbt deleted file mode 100644 index 5066472..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/small/weeping_willow_small_1.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/small/weeping_willow_small_2.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/small/weeping_willow_small_2.nbt deleted file mode 100644 index 5434dd9..0000000 Binary files a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/small/weeping_willow_small_2.nbt and /dev/null differ diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/birch_forest.json b/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/birch_forest.json deleted file mode 100644 index 8e2334f..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/birch_forest.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "tree", - "base": 3, - "name": "terraforged:birch_forest", - "paths": [ - "terraforged:trees/birch/forest" - ], - "decorators": { - "minecraft:beehive": { - "probability": 0.002 - } - } -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/birch_large.json b/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/birch_large.json deleted file mode 100644 index 517da81..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/birch_large.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "tree", - "base": 3, - "name": "terraforged:birch_large", - "paths": [ - "terraforged:trees/birch/large" - ], - "decorators": { - "minecraft:beehive": { - "probability": 0.002 - } - } -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_forest.json b/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_forest.json deleted file mode 100644 index eacbf1f..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_forest.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "tree", - "base": 3, - "name": "terraforged:oak_forest", - "paths": [ - "terraforged:trees/oak/forest" - ], - "decorators": { - "minecraft:beehive": { - "probability": 0.002 - } - } -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_huge.json b/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_huge.json deleted file mode 100644 index 15704e9..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_huge.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "tree", - "base": 3, - "name": "terraforged:oak_huge", - "paths": [ - "terraforged:trees/oak/huge" - ], - "decorators": { - "minecraft:beehive": { - "probability": 0.002 - } - } -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_large.json b/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_large.json deleted file mode 100644 index dd11f3e..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_large.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "tree", - "base": 3, - "name": "terraforged:oak_large", - "paths": [ - "terraforged:trees/oak/large" - ], - "decorators": { - "minecraft:beehive": { - "probability": 0.002 - } - } -} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/license.txt b/TerraForgedMod/src/main/resources/license.txt deleted file mode 100644 index 0b31935..0000000 --- a/TerraForgedMod/src/main/resources/license.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 TerraForged - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/TerraForgedMod/src/main/resources/terraforged.png b/TerraForgedMod/src/main/resources/terraforged.png deleted file mode 100644 index 0d649c9..0000000 Binary files a/TerraForgedMod/src/main/resources/terraforged.png and /dev/null differ diff --git a/build.gradle b/build.gradle index 04634f8..bdcefd3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,113 @@ -allprojects { - apply plugin: "java" - group = "com.terraforged" - version = mod_version +buildscript { + repositories { + jcenter() + mavenCentral() + maven { url "https://files.minecraftforge.net/maven" } + } + dependencies { + classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "3.+", changing: true + } } -jar.enabled(false) \ No newline at end of file +apply plugin: "net.minecraftforge.gradle" +apply plugin: "maven-publish" +apply plugin: "eclipse" + +version = "${mc_version}-${mod_version}${getClassifier()}" + +allprojects { + apply plugin: "java" +} + +configurations { + lib + compile.extendsFrom lib +} + +repositories { + jcenter() + mavenCentral() + maven { url "https://io.terraforged.com/repository/maven/" } +} + +dependencies { + minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" + lib (project(":FeatureManager")) { transitive false } + lib project(":Engine") +} + +minecraft { + mappings channel: mcp_channel, version: mcp_version + runs { + client { + workingDirectory project.file("run/client") + property "forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP" + property "forge.logging.console.level", "debug" + jvmArgs "-Xmx8G", "-Xms6G", "-Ddev" + mods { + terraforged { + source sourceSets.main + } + } + } + server { + workingDirectory project.file("run/server") + property "forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP" + property "forge.logging.console.level", "debug" + jvmArgs "-Xmx8G", "-Xms6G", "-Ddev" + mods { + terraforged { + source sourceSets.main + } + } + } + data { + workingDirectory project.file("run/data") + property "forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP" + property "forge.logging.console.level", "debug" + property "fml.earlyprogresswindow", "false" + args "--mod", "terraforged", "--server", "--output", file("generated/resources/") + jvmArgs "-Xmx4G", "-Xms2G" + mods { + terraforged { + source sourceSets.main + } + } + } + } +} + +sourceSets { + main.resources { + srcDirs += "generated/resources/" + exclude ".cache" + } +} + +task collectLibs(type: Copy) { + dependsOn(dependsOn: subprojects.tasks["jar"]) + from { configurations.lib.collect { it.isDirectory() ? it : zipTree(it) } } + into("build/classes/java/main") + duplicatesStrategy = "EXCLUDE" +} + +processResources { + filesMatching("**/mods.toml") { + expand("version": "${mod_version}${getClassifier()}", "mc_version": mc_version) + } +} + +classes { + dependsOn(collectLibs) +} + +static def getClassifier() { + if (System.getenv("GIT_TAG_NAME") != null) { + return "" + } + def buildNumber = System.getenv("BUILD_NUMBER") + if (buildNumber != null) { + return "-${buildNumber}" + } + return "" +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 01967c6..b38ed21 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -mod_version=0.0.14 +mod_version=0.1.0 mc_version=1.15.2 forge_version=31.1.77 mcp_channel=snapshot diff --git a/settings.gradle b/settings.gradle index 4448c28..d66aaef 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,3 @@ rootProject.name = "TerraForged" -include ":TerraForgedMod" -include ":TerraForgedAPI" +include ":Engine" include ":FeatureManager" \ No newline at end of file diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/BiomeTags.java b/src/main/java/com/terraforged/api/biome/BiomeTags.java similarity index 98% rename from TerraForgedAPI/src/main/java/com/terraforged/api/biome/BiomeTags.java rename to src/main/java/com/terraforged/api/biome/BiomeTags.java index e411af3..4d9db20 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/BiomeTags.java +++ b/src/main/java/com/terraforged/api/biome/BiomeTags.java @@ -25,7 +25,7 @@ package com.terraforged.api.biome; -import com.terraforged.core.world.biome.BiomeType; +import com.terraforged.world.biome.BiomeType; import net.minecraft.tags.Tag; import net.minecraft.tags.TagCollection; import net.minecraft.util.ResourceLocation; diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/BiomeVariant.java b/src/main/java/com/terraforged/api/biome/BiomeVariant.java similarity index 86% rename from TerraForgedAPI/src/main/java/com/terraforged/api/biome/BiomeVariant.java rename to src/main/java/com/terraforged/api/biome/BiomeVariant.java index b98d854..3bf9895 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/BiomeVariant.java +++ b/src/main/java/com/terraforged/api/biome/BiomeVariant.java @@ -25,6 +25,7 @@ package com.terraforged.api.biome; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; public abstract class BiomeVariant extends Biome { @@ -49,4 +50,9 @@ public abstract class BiomeVariant extends Biome { } public abstract Biome getBase(); + + protected static float getTemperatureNoise(BlockPos pos) { + float value = (float) (TEMPERATURE_NOISE.noiseAt(pos.getX() / 8F, pos.getZ() / 8F, false) * 4F); + return (value + pos.getY() - 64F) * 0.05F / 30F; + } } diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/AbstractMaxHeightModifier.java b/src/main/java/com/terraforged/api/biome/modifier/AbstractMaxHeightModifier.java similarity index 86% rename from TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/AbstractMaxHeightModifier.java rename to src/main/java/com/terraforged/api/biome/modifier/AbstractMaxHeightModifier.java index 773b321..7149583 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/AbstractMaxHeightModifier.java +++ b/src/main/java/com/terraforged/api/biome/modifier/AbstractMaxHeightModifier.java @@ -26,9 +26,8 @@ package com.terraforged.api.biome.modifier; import com.terraforged.core.cell.Cell; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.core.Seed; +import com.terraforged.world.climate.Climate; import me.dags.noise.Module; import me.dags.noise.Source; import net.minecraft.world.biome.Biome; @@ -49,7 +48,7 @@ public abstract class AbstractMaxHeightModifier extends AbstractOffsetModifier { } @Override - protected final Biome modify(Biome in, Cell cell, int x, int z, float ox, float oz) { + protected final Biome modify(Biome in, Cell cell, int x, int z, float ox, float oz) { float var = variance.getValue(x, z); float value = cell.value + var; if (value < minHeight) { @@ -63,5 +62,5 @@ public abstract class AbstractMaxHeightModifier extends AbstractOffsetModifier { return in; } - protected abstract Biome getModifiedBiome(Biome in, Cell cell, int x, int z, float ox, float oz); + protected abstract Biome getModifiedBiome(Biome in, Cell cell, int x, int z, float ox, float oz); } diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/AbstractOffsetModifier.java b/src/main/java/com/terraforged/api/biome/modifier/AbstractOffsetModifier.java similarity index 85% rename from TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/AbstractOffsetModifier.java rename to src/main/java/com/terraforged/api/biome/modifier/AbstractOffsetModifier.java index d0a6a43..6727c52 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/AbstractOffsetModifier.java +++ b/src/main/java/com/terraforged/api/biome/modifier/AbstractOffsetModifier.java @@ -26,8 +26,7 @@ package com.terraforged.api.biome.modifier; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.world.climate.Climate; import net.minecraft.world.biome.Biome; public abstract class AbstractOffsetModifier implements BiomeModifier { @@ -39,11 +38,11 @@ public abstract class AbstractOffsetModifier implements BiomeModifier { } @Override - public Biome modify(Biome in, Cell cell, int x, int z) { + public Biome modify(Biome in, Cell cell, int x, int z) { float dx = climate.getOffsetX(x, z, 50); float dz = climate.getOffsetX(x, z, 50); return modify(in, cell, x, z, x + dx, z + dz); } - protected abstract Biome modify(Biome in, Cell cell, int x, int z, float ox, float oz); + protected abstract Biome modify(Biome in, Cell cell, int x, int z, float ox, float oz); } diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java b/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java similarity index 93% rename from TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java rename to src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java index 2d81330..9e31607 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java +++ b/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java @@ -26,7 +26,6 @@ package com.terraforged.api.biome.modifier; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; import net.minecraft.world.biome.Biome; public interface BiomeModifier extends Comparable { @@ -35,7 +34,7 @@ public interface BiomeModifier extends Comparable { boolean test(Biome biome); - Biome modify(Biome in, Cell cell, int x, int z); + Biome modify(Biome in, Cell cell, int x, int z); @Override default int compareTo(BiomeModifier other) { diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/ModifierManager.java b/src/main/java/com/terraforged/api/biome/modifier/ModifierManager.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/biome/modifier/ModifierManager.java rename to src/main/java/com/terraforged/api/biome/modifier/ModifierManager.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/ChunkContext.java b/src/main/java/com/terraforged/api/chunk/ChunkContext.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/ChunkContext.java rename to src/main/java/com/terraforged/api/chunk/ChunkContext.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/ChunkDelegate.java b/src/main/java/com/terraforged/api/chunk/ChunkDelegate.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/ChunkDelegate.java rename to src/main/java/com/terraforged/api/chunk/ChunkDelegate.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/column/ColumnDecorator.java b/src/main/java/com/terraforged/api/chunk/column/ColumnDecorator.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/column/ColumnDecorator.java rename to src/main/java/com/terraforged/api/chunk/column/ColumnDecorator.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/column/DecoratorContext.java b/src/main/java/com/terraforged/api/chunk/column/DecoratorContext.java similarity index 86% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/column/DecoratorContext.java rename to src/main/java/com/terraforged/api/chunk/column/DecoratorContext.java index 2181348..45ae033 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/column/DecoratorContext.java +++ b/src/main/java/com/terraforged/api/chunk/column/DecoratorContext.java @@ -27,11 +27,10 @@ package com.terraforged.api.chunk.column; import com.terraforged.api.chunk.ChunkContext; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.geology.DepthBuffer; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.world.climate.Climate; +import com.terraforged.world.geology.DepthBuffer; +import com.terraforged.world.heightmap.Levels; +import com.terraforged.world.terrain.Terrains; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.IChunk; @@ -45,7 +44,7 @@ public class DecoratorContext extends ChunkContext { public final BlockPos.Mutable pos = new BlockPos.Mutable(); public Biome biome; - public Cell cell; + public Cell cell; public DecoratorContext(IChunk chunk, Levels levels, Terrains terrain, Climate climate) { super(chunk); diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/column/DecoratorManager.java b/src/main/java/com/terraforged/api/chunk/column/DecoratorManager.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/column/DecoratorManager.java rename to src/main/java/com/terraforged/api/chunk/column/DecoratorManager.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/CachedSurface.java b/src/main/java/com/terraforged/api/chunk/surface/CachedSurface.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/CachedSurface.java rename to src/main/java/com/terraforged/api/chunk/surface/CachedSurface.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/ChunkSurfaceBuffer.java b/src/main/java/com/terraforged/api/chunk/surface/ChunkSurfaceBuffer.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/ChunkSurfaceBuffer.java rename to src/main/java/com/terraforged/api/chunk/surface/ChunkSurfaceBuffer.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/Surface.java b/src/main/java/com/terraforged/api/chunk/surface/Surface.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/Surface.java rename to src/main/java/com/terraforged/api/chunk/surface/Surface.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/SurfaceContext.java b/src/main/java/com/terraforged/api/chunk/surface/SurfaceContext.java similarity index 92% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/SurfaceContext.java rename to src/main/java/com/terraforged/api/chunk/surface/SurfaceContext.java index 923351a..684ff89 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/SurfaceContext.java +++ b/src/main/java/com/terraforged/api/chunk/surface/SurfaceContext.java @@ -26,9 +26,9 @@ package com.terraforged.api.chunk.surface; import com.terraforged.api.chunk.column.DecoratorContext; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.world.climate.Climate; +import com.terraforged.world.heightmap.Levels; +import com.terraforged.world.terrain.Terrains; import net.minecraft.block.BlockState; import net.minecraft.world.gen.GenerationSettings; diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/SurfaceManager.java b/src/main/java/com/terraforged/api/chunk/surface/SurfaceManager.java similarity index 70% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/SurfaceManager.java rename to src/main/java/com/terraforged/api/chunk/surface/SurfaceManager.java index e0578de..62c3c7e 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/SurfaceManager.java +++ b/src/main/java/com/terraforged/api/chunk/surface/SurfaceManager.java @@ -26,20 +26,42 @@ package com.terraforged.api.chunk.surface; import com.terraforged.api.chunk.surface.builder.Delegate; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.biome.Biome; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; public class SurfaceManager { - private final Map surfaces = new HashMap<>(); + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + private final Map surfaces = new HashMap<>(); public SurfaceManager replace(Biome biome, Surface surface) { - surfaces.put(biome, surface); + lock.writeLock().lock(); + surfaces.put(biome.getRegistryName(), surface); + lock.writeLock().unlock(); return this; } + public Surface getSurface(Biome biome) { + lock.readLock().lock(); + Surface surface = surfaces.get(biome.getRegistryName()); + lock.readLock().unlock(); + return surface; + } + + public Surface getOrCreateSurface(Biome biome) { + Surface surface = getSurface(biome); + if (surface == null) { + surface = Delegate.FUNC.apply(biome); + replace(biome, surface); + } + return surface; + } + public SurfaceManager extend(Biome biome, Surface surface) { Surface result = getOrCreateSurface(biome).then(surface); return replace(biome, result); @@ -53,8 +75,4 @@ public class SurfaceManager { context.cached.surface = getOrCreateSurface(context.biome); return context.cached.surface; } - - public Surface getOrCreateSurface(Biome biome) { - return surfaces.computeIfAbsent(biome, Delegate.FUNC); - } } diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/builder/Combiner.java b/src/main/java/com/terraforged/api/chunk/surface/builder/Combiner.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/builder/Combiner.java rename to src/main/java/com/terraforged/api/chunk/surface/builder/Combiner.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/builder/Delegate.java b/src/main/java/com/terraforged/api/chunk/surface/builder/Delegate.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/chunk/surface/builder/Delegate.java rename to src/main/java/com/terraforged/api/chunk/surface/builder/Delegate.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/event/SetupEvent.java b/src/main/java/com/terraforged/api/event/SetupEvent.java similarity index 95% rename from TerraForgedAPI/src/main/java/com/terraforged/api/event/SetupEvent.java rename to src/main/java/com/terraforged/api/event/SetupEvent.java index e05a98c..663162a 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/event/SetupEvent.java +++ b/src/main/java/com/terraforged/api/event/SetupEvent.java @@ -30,9 +30,9 @@ import com.terraforged.api.chunk.column.DecoratorManager; import com.terraforged.api.chunk.surface.SurfaceManager; import com.terraforged.api.material.geology.GeologyManager; import com.terraforged.api.material.layer.LayerManager; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.terrain.provider.TerrainProvider; -import com.terraforged.feature.modifier.FeatureModifiers; +import com.terraforged.world.GeneratorContext; +import com.terraforged.world.terrain.provider.TerrainProvider; +import com.terraforged.mod.feature.manager.modifier.FeatureModifiers; import net.minecraftforge.eventbus.api.Event; public abstract class SetupEvent extends Event { diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/WGTags.java b/src/main/java/com/terraforged/api/material/WGTags.java similarity index 91% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/WGTags.java rename to src/main/java/com/terraforged/api/material/WGTags.java index f2c741a..9cf6f76 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/material/WGTags.java +++ b/src/main/java/com/terraforged/api/material/WGTags.java @@ -25,7 +25,6 @@ package com.terraforged.api.material; -import com.terraforged.api.material.state.StateTagPredicate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.tags.BlockTags; @@ -51,6 +50,10 @@ public class WGTags { } public static Predicate stone() { - return new StateTagPredicate(STONE); + return toStatePredicate(STONE); + } + + private static Predicate toStatePredicate(Tag tag) { + return state -> tag.contains(state.getBlock()); } } diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/geology/GeologyManager.java b/src/main/java/com/terraforged/api/material/geology/GeologyManager.java similarity index 95% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/geology/GeologyManager.java rename to src/main/java/com/terraforged/api/material/geology/GeologyManager.java index dd46b94..b8a7c72 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/material/geology/GeologyManager.java +++ b/src/main/java/com/terraforged/api/material/geology/GeologyManager.java @@ -25,8 +25,8 @@ package com.terraforged.api.material.geology; -import com.terraforged.core.world.geology.Geology; -import com.terraforged.core.world.geology.Strata; +import com.terraforged.world.geology.Geology; +import com.terraforged.world.geology.Strata; import net.minecraft.block.BlockState; import net.minecraft.world.biome.Biome; diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/geology/StrataConfig.java b/src/main/java/com/terraforged/api/material/geology/StrataConfig.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/geology/StrataConfig.java rename to src/main/java/com/terraforged/api/material/geology/StrataConfig.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/geology/StrataGenerator.java b/src/main/java/com/terraforged/api/material/geology/StrataGenerator.java similarity index 96% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/geology/StrataGenerator.java rename to src/main/java/com/terraforged/api/material/geology/StrataGenerator.java index ae712f4..f553a38 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/material/geology/StrataGenerator.java +++ b/src/main/java/com/terraforged/api/material/geology/StrataGenerator.java @@ -25,7 +25,7 @@ package com.terraforged.api.material.geology; -import com.terraforged.core.world.geology.Strata; +import com.terraforged.world.geology.Strata; import net.minecraft.block.BlockState; public interface StrataGenerator { diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/layer/LayerManager.java b/src/main/java/com/terraforged/api/material/layer/LayerManager.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/layer/LayerManager.java rename to src/main/java/com/terraforged/api/material/layer/LayerManager.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/layer/LayerMaterial.java b/src/main/java/com/terraforged/api/material/layer/LayerMaterial.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/layer/LayerMaterial.java rename to src/main/java/com/terraforged/api/material/layer/LayerMaterial.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/state/CachedState.java b/src/main/java/com/terraforged/api/material/state/CachedState.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/state/CachedState.java rename to src/main/java/com/terraforged/api/material/state/CachedState.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/state/DefaultState.java b/src/main/java/com/terraforged/api/material/state/DefaultState.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/state/DefaultState.java rename to src/main/java/com/terraforged/api/material/state/DefaultState.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/state/StateSupplier.java b/src/main/java/com/terraforged/api/material/state/StateSupplier.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/state/StateSupplier.java rename to src/main/java/com/terraforged/api/material/state/StateSupplier.java diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/state/States.java b/src/main/java/com/terraforged/api/material/state/States.java similarity index 100% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/state/States.java rename to src/main/java/com/terraforged/api/material/state/States.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/Log.java b/src/main/java/com/terraforged/mod/Log.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/Log.java rename to src/main/java/com/terraforged/mod/Log.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/TerraForgedMod.java b/src/main/java/com/terraforged/mod/TerraForgedMod.java similarity index 91% rename from TerraForgedMod/src/main/java/com/terraforged/mod/TerraForgedMod.java rename to src/main/java/com/terraforged/mod/TerraForgedMod.java index 83f36db..8a23460 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/TerraForgedMod.java +++ b/src/main/java/com/terraforged/mod/TerraForgedMod.java @@ -26,12 +26,12 @@ package com.terraforged.mod; import com.terraforged.api.material.WGTags; -import com.terraforged.feature.FeatureManager; +import com.terraforged.mod.feature.manager.template.TemplateManager; import com.terraforged.mod.command.TerraCommand; import com.terraforged.mod.data.DataGen; +import com.terraforged.mod.feature.context.ContextSelectorFeature; import com.terraforged.mod.feature.decorator.poisson.PoissonAtSurface; import com.terraforged.mod.feature.feature.DiskFeature; -import com.terraforged.mod.feature.tree.SaplingManager; import com.terraforged.mod.settings.SettingsHelper; import com.terraforged.mod.util.DataPackFinder; import com.terraforged.mod.util.Environment; @@ -61,16 +61,14 @@ public class TerraForgedMod { Log.info("Common setup"); WGTags.init(); TerraWorld.init(); - SaplingManager.init(); TerraCommand.init(); - SettingsHelper.initSettings(); + SettingsHelper.init(); // temp fix BiomeDictionary.addTypes(Biomes.BAMBOO_JUNGLE, BiomeDictionary.Type.OVERWORLD); BiomeDictionary.addTypes(Biomes.BAMBOO_JUNGLE_HILLS, BiomeDictionary.Type.OVERWORLD); - // allows ores to replace any world-gen stone type - OreFeatureConfig.FillerBlockType.create("WG_STONE", "wg_stone", WGTags.stone()); + OreFeatureConfig.FillerBlockType.create("wg_stone", "wg_stone", WGTags.stone()); } @SubscribeEvent @@ -83,8 +81,9 @@ public class TerraForgedMod { @SubscribeEvent public static void registerFeatures(RegistryEvent.Register> event) { Log.info("Registering features"); - FeatureManager.registerTemplates(event); + TemplateManager.register(event); event.getRegistry().register(DiskFeature.INSTANCE); + event.getRegistry().register(ContextSelectorFeature.INSTANCE); } @SubscribeEvent diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/TerraWorld.java b/src/main/java/com/terraforged/mod/TerraWorld.java similarity index 91% rename from TerraForgedMod/src/main/java/com/terraforged/mod/TerraWorld.java rename to src/main/java/com/terraforged/mod/TerraWorld.java index 0c7d479..9984787 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/TerraWorld.java +++ b/src/main/java/com/terraforged/mod/TerraWorld.java @@ -25,7 +25,6 @@ package com.terraforged.mod; -import com.terraforged.core.world.terrain.Terrains; import com.terraforged.mod.biome.provider.BiomeProvider; import com.terraforged.mod.chunk.ChunkGeneratorFactory; import com.terraforged.mod.chunk.TerraChunkGenerator; @@ -38,6 +37,7 @@ import com.terraforged.mod.settings.SettingsHelper; import com.terraforged.mod.settings.TerraSettings; import com.terraforged.mod.util.Environment; import com.terraforged.mod.util.nbt.NBTHelper; +import com.terraforged.world.terrain.Terrains; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.CreateWorldScreen; import net.minecraft.world.IWorld; @@ -53,10 +53,10 @@ import net.minecraftforge.api.distmarker.OnlyIn; import java.util.HashSet; import java.util.Set; +import java.util.function.Consumer; public class TerraWorld extends WorldType { - public static final int VERSION = 1; private static final Set types = new HashSet<>(); private final ChunkGeneratorFactory factory; @@ -72,10 +72,8 @@ public class TerraWorld extends WorldType { public ChunkGenerator createChunkGenerator(World world) { if (world.getDimension().getType() == DimensionType.OVERWORLD) { WorldInfo info = world.getWorldInfo(); - int version = SettingsHelper.getVersion(info); TerraSettings settings = SettingsHelper.getSettings(info); - SettingsHelper.syncSettings(world.getWorldInfo(), settings, version); - settings.dimensions.dimensionGenerators.apply(world.getWorldInfo()); + settings.dimensions.dimensions.apply(world.getWorldInfo()); Terrains terrains = Terrains.create(settings); @@ -131,6 +129,19 @@ public class TerraWorld extends WorldType { } } + public static WorldType getFirst() { + for (WorldType worldType : WorldType.WORLD_TYPES) { + if (worldType instanceof TerraWorld) { + return worldType; + } + } + throw new RuntimeException(); + } + + public static void forEach(Consumer consumer) { + types.forEach(consumer); + } + public static boolean isTerraType(WorldType type) { return types.contains(type); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/ColdSteppe.java b/src/main/java/com/terraforged/mod/biome/ColdSteppe.java similarity index 92% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/ColdSteppe.java rename to src/main/java/com/terraforged/mod/biome/ColdSteppe.java index e114c54..36d348b 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/ColdSteppe.java +++ b/src/main/java/com/terraforged/mod/biome/ColdSteppe.java @@ -29,7 +29,6 @@ import com.terraforged.api.biome.BiomeVariant; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; import net.minecraft.world.biome.DefaultBiomeFeatures; @@ -42,8 +41,10 @@ import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; public class ColdSteppe extends BiomeVariant { + private static final float DEFAULT_TEMPERATURE = 0.4F; + public ColdSteppe() { - super((new Biome.Builder()).surfaceBuilder(SurfaceBuilder.GIANT_TREE_TAIGA, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG).precipitation(RainType.SNOW).category(Biome.Category.TAIGA).depth(0.2F).scale(0.25F).temperature(0.2F).downfall(0.1F).waterColor(4159204).waterFogColor(329011).parent((String) null)); + super((new Biome.Builder()).surfaceBuilder(SurfaceBuilder.GIANT_TREE_TAIGA, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG).precipitation(RainType.SNOW).category(Biome.Category.TAIGA).depth(0.2F).scale(0.25F).temperature(0.2F).downfall(0.05F).waterColor(4159204).waterFogColor(329011).parent((String) null)); this.addStructure(Feature.VILLAGE.withConfiguration(new VillageConfig("village/taiga/town_centers", 6))); this.addStructure(Feature.PILLAGER_OUTPOST.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)); this.addStructure(Feature.MINESHAFT.withConfiguration(new MineshaftConfig(0.004D, MineshaftStructure.Type.NORMAL))); @@ -58,7 +59,6 @@ public class ColdSteppe extends BiomeVariant { DefaultBiomeFeatures.addGrass(this); DefaultBiomeFeatures.addVeryDenseGrass(this); DefaultBiomeFeatures.addBerryBushes(this); - DefaultBiomeFeatures.addFreezeTopLayer(this); this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.SHEEP, 12, 4, 4)); this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.PIG, 10, 4, 4)); this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.CHICKEN, 10, 4, 4)); @@ -80,13 +80,12 @@ public class ColdSteppe extends BiomeVariant { } @Override - public boolean doesSnowGenerate(IWorldReader worldIn, BlockPos pos) { - return false; - } - - @Override - public boolean doesWaterFreeze(IWorldReader worldIn, BlockPos pos) { - return false; + public float getTemperatureRaw(BlockPos pos) { + if (pos.getY() > 64) { + return DEFAULT_TEMPERATURE - getTemperatureNoise(pos); + } else { + return DEFAULT_TEMPERATURE; + } } @Override diff --git a/src/main/java/com/terraforged/mod/biome/Dunes.java b/src/main/java/com/terraforged/mod/biome/Dunes.java new file mode 100644 index 0000000..35d65c9 --- /dev/null +++ b/src/main/java/com/terraforged/mod/biome/Dunes.java @@ -0,0 +1,54 @@ +package com.terraforged.mod.biome; + +import com.terraforged.api.biome.BiomeVariant; +import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.EntityType; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.Biomes; +import net.minecraft.world.biome.DefaultBiomeFeatures; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.IFeatureConfig; +import net.minecraft.world.gen.feature.structure.MineshaftConfig; +import net.minecraft.world.gen.feature.structure.MineshaftStructure; +import net.minecraft.world.gen.feature.structure.VillageConfig; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; + +public class Dunes extends BiomeVariant { + + protected Dunes() { + super((new Biome.Builder()).surfaceBuilder(SurfaceBuilder.DEFAULT, SurfaceBuilder.SAND_SAND_GRAVEL_CONFIG).precipitation(Biome.RainType.NONE).category(Biome.Category.DESERT).depth(0.125F).scale(0.05F).temperature(2.0F).downfall(0.0F).waterColor(4159204).waterFogColor(329011).parent((String)null)); + this.addStructure(Feature.VILLAGE.withConfiguration(new VillageConfig("village/desert/town_centers", 6))); + this.addStructure(Feature.PILLAGER_OUTPOST.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)); + this.addStructure(Feature.DESERT_PYRAMID.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)); + this.addStructure(Feature.MINESHAFT.withConfiguration(new MineshaftConfig(0.004D, MineshaftStructure.Type.NORMAL))); + this.addStructure(Feature.STRONGHOLD.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)); + DefaultBiomeFeatures.addCarvers(this); + DefaultBiomeFeatures.addStructures(this); + DefaultBiomeFeatures.addMonsterRooms(this); + DefaultBiomeFeatures.addStoneVariants(this); + DefaultBiomeFeatures.addOres(this); + DefaultBiomeFeatures.addDefaultFlowers(this); + DefaultBiomeFeatures.addSparseGrass(this); + DefaultBiomeFeatures.addDeadBushes(this); + DefaultBiomeFeatures.addMushrooms(this); + DefaultBiomeFeatures.addExtraReedsPumpkinsCactus(this); + DefaultBiomeFeatures.addFreezeTopLayer(this); + this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.RABBIT, 4, 2, 3)); + this.addSpawn(EntityClassification.AMBIENT, new Biome.SpawnListEntry(EntityType.BAT, 10, 8, 8)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SPIDER, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SKELETON, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.CREEPER, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SLIME, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE, 19, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE_VILLAGER, 1, 1, 1)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.HUSK, 80, 4, 4)); + setRegistryName("terraforged", "dunes"); + } + + @Override + public Biome getBase() { + return Biomes.DESERT; + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/FirForest.java b/src/main/java/com/terraforged/mod/biome/FirForest.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/FirForest.java rename to src/main/java/com/terraforged/mod/biome/FirForest.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/FlowerPlains.java b/src/main/java/com/terraforged/mod/biome/FlowerPlains.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/FlowerPlains.java rename to src/main/java/com/terraforged/mod/biome/FlowerPlains.java diff --git a/src/main/java/com/terraforged/mod/biome/FrozenLake.java b/src/main/java/com/terraforged/mod/biome/FrozenLake.java new file mode 100644 index 0000000..fc44c9d --- /dev/null +++ b/src/main/java/com/terraforged/mod/biome/FrozenLake.java @@ -0,0 +1,75 @@ +/* + * + * MIT License + * + * Copyright (c) 2020 TerraForged + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.terraforged.mod.biome; + +import com.terraforged.api.biome.BiomeVariant; +import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.EntityType; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.Biomes; +import net.minecraft.world.biome.DefaultBiomeFeatures; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.structure.MineshaftConfig; +import net.minecraft.world.gen.feature.structure.MineshaftStructure; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; + +public class FrozenLake extends BiomeVariant { + + protected FrozenLake() { + super((new Biome.Builder()).surfaceBuilder(SurfaceBuilder.DEFAULT, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG).precipitation(Biome.RainType.SNOW).category(Biome.Category.RIVER).depth(-0.5F).scale(0.0F).temperature(0.0F).downfall(0.5F).waterColor(3750089).waterFogColor(329011).parent((String)null)); + this.addStructure(Feature.MINESHAFT.withConfiguration(new MineshaftConfig(0.004D, MineshaftStructure.Type.NORMAL))); + DefaultBiomeFeatures.addCarvers(this); + DefaultBiomeFeatures.addStructures(this); + DefaultBiomeFeatures.addMonsterRooms(this); + DefaultBiomeFeatures.addStoneVariants(this); + DefaultBiomeFeatures.addOres(this); + DefaultBiomeFeatures.addSedimentDisks(this); + DefaultBiomeFeatures.addDefaultFlowers(this); + DefaultBiomeFeatures.addSparseGrass(this); + DefaultBiomeFeatures.addMushrooms(this); + DefaultBiomeFeatures.addReedsAndPumpkins(this); + DefaultBiomeFeatures.addSprings(this); + DefaultBiomeFeatures.addFreezeTopLayer(this); + this.addSpawn(EntityClassification.WATER_CREATURE, new Biome.SpawnListEntry(EntityType.SQUID, 2, 1, 4)); + this.addSpawn(EntityClassification.WATER_CREATURE, new Biome.SpawnListEntry(EntityType.SALMON, 5, 1, 5)); + this.addSpawn(EntityClassification.AMBIENT, new Biome.SpawnListEntry(EntityType.BAT, 10, 8, 8)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SPIDER, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE, 95, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.DROWNED, 1, 1, 1)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE_VILLAGER, 5, 1, 1)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SKELETON, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.CREEPER, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SLIME, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1)); + setRegistryName("terraforged", "frozen_lake"); + } + + @Override + public Biome getBase() { + return Biomes.FROZEN_RIVER; + } +} diff --git a/src/main/java/com/terraforged/mod/biome/Lake.java b/src/main/java/com/terraforged/mod/biome/Lake.java new file mode 100644 index 0000000..1cc1d03 --- /dev/null +++ b/src/main/java/com/terraforged/mod/biome/Lake.java @@ -0,0 +1,80 @@ +/* + * + * MIT License + * + * Copyright (c) 2020 TerraForged + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.terraforged.mod.biome; + +import com.terraforged.api.biome.BiomeVariant; +import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.EntityType; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.Biomes; +import net.minecraft.world.biome.DefaultBiomeFeatures; +import net.minecraft.world.gen.GenerationStage; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.SeaGrassConfig; +import net.minecraft.world.gen.feature.structure.MineshaftConfig; +import net.minecraft.world.gen.feature.structure.MineshaftStructure; +import net.minecraft.world.gen.placement.IPlacementConfig; +import net.minecraft.world.gen.placement.Placement; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; + +public class Lake extends BiomeVariant { + + protected Lake() { + super((new Biome.Builder()).surfaceBuilder(SurfaceBuilder.DEFAULT, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG).precipitation(Biome.RainType.RAIN).category(Biome.Category.RIVER).depth(-0.5F).scale(0.0F).temperature(0.5F).downfall(0.5F).waterColor(4159204).waterFogColor(329011).parent((String)null)); + this.addStructure(Feature.MINESHAFT.withConfiguration(new MineshaftConfig(0.004D, MineshaftStructure.Type.NORMAL))); + DefaultBiomeFeatures.addCarvers(this); + DefaultBiomeFeatures.addStructures(this); + DefaultBiomeFeatures.addMonsterRooms(this); + DefaultBiomeFeatures.addStoneVariants(this); + DefaultBiomeFeatures.addOres(this); + DefaultBiomeFeatures.addSedimentDisks(this); + DefaultBiomeFeatures.addDefaultFlowers(this); + DefaultBiomeFeatures.addSparseGrass(this); + DefaultBiomeFeatures.addMushrooms(this); + DefaultBiomeFeatures.addReedsAndPumpkins(this); + DefaultBiomeFeatures.addSprings(this); + this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.SEAGRASS.withConfiguration(new SeaGrassConfig(48, 0.4D)).withPlacement(Placement.TOP_SOLID_HEIGHTMAP.configure(IPlacementConfig.NO_PLACEMENT_CONFIG))); + DefaultBiomeFeatures.addFreezeTopLayer(this); + this.addSpawn(EntityClassification.WATER_CREATURE, new Biome.SpawnListEntry(EntityType.SQUID, 2, 1, 4)); + this.addSpawn(EntityClassification.WATER_CREATURE, new Biome.SpawnListEntry(EntityType.SALMON, 5, 1, 5)); + this.addSpawn(EntityClassification.AMBIENT, new Biome.SpawnListEntry(EntityType.BAT, 10, 8, 8)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SPIDER, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE, 95, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.DROWNED, 100, 1, 1)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE_VILLAGER, 5, 1, 1)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SKELETON, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.CREEPER, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SLIME, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1)); + setRegistryName("terraforged", "lake"); + } + + @Override + public Biome getBase() { + return Biomes.RIVER; + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/Marshland.java b/src/main/java/com/terraforged/mod/biome/Marshland.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/Marshland.java rename to src/main/java/com/terraforged/mod/biome/Marshland.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/ModBiomes.java b/src/main/java/com/terraforged/mod/biome/ModBiomes.java similarity index 87% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/ModBiomes.java rename to src/main/java/com/terraforged/mod/biome/ModBiomes.java index d2ded1b..97b7f7d 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/ModBiomes.java +++ b/src/main/java/com/terraforged/mod/biome/ModBiomes.java @@ -40,15 +40,19 @@ public class ModBiomes { private static final ArrayList biomes = new ArrayList<>(); public static final Biome COLD_STEPPE = register(new ColdSteppe()); +// public static final Biome DUNES = register(new Dunes()); + public static final Biome FIR_FOREST = register(new FirForest()); + public static final Biome FLOWER_PLAINS = register(new FlowerPlains()); + public static final Biome FROZEN_LAKE = register(new FrozenLake()); + public static final Biome LAKE = register(new Lake()); + public static final Biome MARSHLAND = register(new Marshland()); public static final Biome SAVANNA_SCRUB = register(new SavannaScrub()); public static final Biome SHATTERED_SAVANNA_SCRUB = register(new ShatteredSavannaScrub()); + public static final Biome SNOWY_FIR_FOREST = register(new SnowyFirForest()); public static final Biome SNOWY_TAIGA_SCRUB = register(new SnowyTaigaScrub()); public static final Biome STEPPE = register(new Steppe()); public static final Biome TAIGA_SCRUB = register(new TaigaScrub()); public static final Biome WARM_BEACH = register(new WarmBeach()); - public static final Biome MARSHLAND = register(new Marshland()); -// public static final Biome FIR_FOREST = register(new FirForest()); -// public static final Biome FLOWER_PLAINS = register(new FlowerPlains()); private static Biome register(BiomeVariant biome) { biomes.add(biome); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/SavannaScrub.java b/src/main/java/com/terraforged/mod/biome/SavannaScrub.java similarity index 99% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/SavannaScrub.java rename to src/main/java/com/terraforged/mod/biome/SavannaScrub.java index 3ce4ee9..9ac7079 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/SavannaScrub.java +++ b/src/main/java/com/terraforged/mod/biome/SavannaScrub.java @@ -63,8 +63,8 @@ public class SavannaScrub extends BiomeVariant { DefaultBiomeFeatures.addSedimentDisks(this); DefaultBiomeFeatures.addExtraDefaultFlowers(this); // func_222339_L - add grasses - add this a few times since there are no trees - DefaultBiomeFeatures.addGrass(this); DefaultBiomeFeatures.addVeryDenseGrass(this); + DefaultBiomeFeatures.addDeadBushes(this); DefaultBiomeFeatures.addMushrooms(this); DefaultBiomeFeatures.addReedsAndPumpkins(this); this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.SHEEP, 12, 4, 4)); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/ShatteredSavannaScrub.java b/src/main/java/com/terraforged/mod/biome/ShatteredSavannaScrub.java similarity index 98% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/ShatteredSavannaScrub.java rename to src/main/java/com/terraforged/mod/biome/ShatteredSavannaScrub.java index 2121706..aac48de 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/ShatteredSavannaScrub.java +++ b/src/main/java/com/terraforged/mod/biome/ShatteredSavannaScrub.java @@ -59,6 +59,8 @@ public class ShatteredSavannaScrub extends BiomeVariant { DefaultBiomeFeatures.addDefaultFlowers(this); DefaultBiomeFeatures.addGrass(this); DefaultBiomeFeatures.addVeryDenseGrass(this); + DefaultBiomeFeatures.addPlainsTallGrass(this); + DefaultBiomeFeatures.addDeadBushes(this); DefaultBiomeFeatures.addMushrooms(this); DefaultBiomeFeatures.addReedsAndPumpkins(this); DefaultBiomeFeatures.addFreezeTopLayer(this); diff --git a/src/main/java/com/terraforged/mod/biome/SnowyFirForest.java b/src/main/java/com/terraforged/mod/biome/SnowyFirForest.java new file mode 100644 index 0000000..421f49b --- /dev/null +++ b/src/main/java/com/terraforged/mod/biome/SnowyFirForest.java @@ -0,0 +1,60 @@ +package com.terraforged.mod.biome; + +import com.terraforged.api.biome.BiomeVariant; +import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.EntityType; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.Biomes; +import net.minecraft.world.biome.DefaultBiomeFeatures; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.IFeatureConfig; +import net.minecraft.world.gen.feature.structure.MineshaftConfig; +import net.minecraft.world.gen.feature.structure.MineshaftStructure; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; + +public class SnowyFirForest extends BiomeVariant { + + public SnowyFirForest() { + super((new Biome.Builder()).surfaceBuilder(SurfaceBuilder.DEFAULT, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG).precipitation(Biome.RainType.SNOW).category(Biome.Category.TAIGA).depth(0.2F).scale(0.2F).temperature(-0.5F).downfall(0.4F).waterColor(4020182).waterFogColor(329011).parent((String)null)); + this.addStructure(Feature.IGLOO.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)); + this.addStructure(Feature.MINESHAFT.withConfiguration(new MineshaftConfig(0.004D, MineshaftStructure.Type.NORMAL))); + this.addStructure(Feature.STRONGHOLD.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)); + DefaultBiomeFeatures.addCarvers(this); + DefaultBiomeFeatures.addStructures(this); + DefaultBiomeFeatures.addMonsterRooms(this); + DefaultBiomeFeatures.addTaigaLargeFerns(this); + DefaultBiomeFeatures.addStoneVariants(this); + DefaultBiomeFeatures.addOres(this); + DefaultBiomeFeatures.addSedimentDisks(this); + DefaultBiomeFeatures.addTaigaConifers(this); + DefaultBiomeFeatures.addDefaultFlowers(this); + DefaultBiomeFeatures.addTaigaGrassAndMushrooms(this); + DefaultBiomeFeatures.addMushrooms(this); + DefaultBiomeFeatures.addReedsAndPumpkins(this); + DefaultBiomeFeatures.addSprings(this); + DefaultBiomeFeatures.addSparseBerryBushes(this); + DefaultBiomeFeatures.addFreezeTopLayer(this); + this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.SHEEP, 12, 4, 4)); + this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.PIG, 10, 4, 4)); + this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.CHICKEN, 10, 4, 4)); + this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.COW, 8, 4, 4)); + this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.WOLF, 8, 4, 4)); + this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.RABBIT, 4, 2, 3)); + this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.FOX, 8, 2, 4)); + this.addSpawn(EntityClassification.AMBIENT, new Biome.SpawnListEntry(EntityType.BAT, 10, 8, 8)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SPIDER, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE, 95, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE_VILLAGER, 5, 1, 1)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SKELETON, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.CREEPER, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SLIME, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4)); + this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1)); + this.setRegistryName("terraforged", "snowy_fir_forest"); + } + + @Override + public Biome getBase() { + return Biomes.SNOWY_TAIGA; + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/SnowyTaigaScrub.java b/src/main/java/com/terraforged/mod/biome/SnowyTaigaScrub.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/SnowyTaigaScrub.java rename to src/main/java/com/terraforged/mod/biome/SnowyTaigaScrub.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/Steppe.java b/src/main/java/com/terraforged/mod/biome/Steppe.java similarity index 89% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/Steppe.java rename to src/main/java/com/terraforged/mod/biome/Steppe.java index e85f77d..742d870 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/Steppe.java +++ b/src/main/java/com/terraforged/mod/biome/Steppe.java @@ -29,7 +29,6 @@ import com.terraforged.api.biome.BiomeVariant; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; import net.minecraft.world.biome.DefaultBiomeFeatures; @@ -42,8 +41,10 @@ import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; public class Steppe extends BiomeVariant { + private static final float DEFAULT_TEMPERATURE = 1F; + protected Steppe() { - super((new Biome.Builder()).surfaceBuilder(SurfaceBuilder.GIANT_TREE_TAIGA, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG).precipitation(RainType.SNOW).category(Category.SAVANNA).depth(0.2F).scale(0.2F).temperature(0.7F).downfall(0.1F).waterColor(4159204).waterFogColor(329011).parent((String) null)); + super((new Biome.Builder()).surfaceBuilder(SurfaceBuilder.GIANT_TREE_TAIGA, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG).precipitation(RainType.RAIN).category(Category.SAVANNA).depth(0.2F).scale(0.2F).temperature(0.7F).downfall(0.05F).waterColor(4159204).waterFogColor(329011).parent((String) null)); this.addStructure(Feature.VILLAGE.withConfiguration(new VillageConfig("village/savanna/town_centers", 6))); this.addStructure(Feature.PILLAGER_OUTPOST.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)); this.addStructure(Feature.MINESHAFT.withConfiguration(new MineshaftConfig(0.004D, MineshaftStructure.Type.NORMAL))); @@ -54,8 +55,9 @@ public class Steppe extends BiomeVariant { DefaultBiomeFeatures.addStoneVariants(this); DefaultBiomeFeatures.addOres(this); DefaultBiomeFeatures.addSedimentDisks(this); - DefaultBiomeFeatures.addGrass(this); DefaultBiomeFeatures.addVeryDenseGrass(this); + DefaultBiomeFeatures.addPlainsTallGrass(this); + DefaultBiomeFeatures.addDeadBushes(this); DefaultBiomeFeatures.addFreezeTopLayer(this); this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.SHEEP, 12, 4, 4)); this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.PIG, 10, 4, 4)); @@ -72,18 +74,16 @@ public class Steppe extends BiomeVariant { this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SLIME, 100, 4, 4)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1)); - setRegistryName("terraforged", "steppe"); } @Override - public boolean doesSnowGenerate(IWorldReader worldIn, BlockPos pos) { - return false; - } - - @Override - public boolean doesWaterFreeze(IWorldReader worldIn, BlockPos pos) { - return false; + public float getTemperatureRaw(BlockPos pos) { + if (pos.getY() > 64) { + return DEFAULT_TEMPERATURE - getTemperatureNoise(pos); + } else { + return DEFAULT_TEMPERATURE; + } } @Override diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/TaigaScrub.java b/src/main/java/com/terraforged/mod/biome/TaigaScrub.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/TaigaScrub.java rename to src/main/java/com/terraforged/mod/biome/TaigaScrub.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/WarmBeach.java b/src/main/java/com/terraforged/mod/biome/WarmBeach.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/WarmBeach.java rename to src/main/java/com/terraforged/mod/biome/WarmBeach.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java b/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java similarity index 93% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java rename to src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java index aa6bb9a..7adfa55 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java +++ b/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java @@ -28,7 +28,7 @@ package com.terraforged.mod.biome.map; import com.google.common.collect.Sets; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.terraforged.core.world.biome.BiomeType; +import com.terraforged.world.biome.BiomeType; import com.terraforged.mod.biome.ModBiomes; import com.terraforged.mod.biome.provider.BiomeHelper; import me.dags.noise.util.NoiseUtil; @@ -43,6 +43,7 @@ public abstract class AbstractBiomeMap implements BiomeMap { private final Biome[][] beach; private final Biome[][] river; + private final Biome[][] lake; private final Biome[][] wetland; private final Biome[][] ocean; private final Biome[][] deepOcean; @@ -50,12 +51,14 @@ public abstract class AbstractBiomeMap implements BiomeMap { protected final DefaultBiome defaultLand = this::defaultBiome; protected final DefaultBiome defaultBeach = this::defaultBeach; protected final DefaultBiome defaultRiver = this::defaultRiver; + protected final DefaultBiome defaultLake = this::defaultLake; protected final DefaultBiome defaultWetland = this::defaultWetland; protected final DefaultBiome defaultOcean = this::defaultOcean; protected final DefaultBiome defaultDeepOcean = this::defaultDeepOcean; protected AbstractBiomeMap(BiomeMapBuilder builder) { river = builder.rivers(); + lake = builder.lakes(); beach = builder.beaches(); ocean = builder.oceans(); wetland = builder.wetlands(); @@ -72,6 +75,11 @@ public abstract class AbstractBiomeMap implements BiomeMap { return get(river, getCategory(temperature), shape, temperature, defaultRiver); } + @Override + public Biome getLake(float temperature, float moisture, float shape) { + return get(lake, getCategory(temperature), shape, temperature, defaultLake); + } + @Override public Biome getWetland(float temperature, float moisture, float shape) { return get(wetland, getCategory(temperature), shape, temperature, defaultWetland); @@ -159,6 +167,13 @@ public abstract class AbstractBiomeMap implements BiomeMap { return Biomes.RIVER; } + protected Biome defaultLake(float temperature) { + if (temperature < 0.15) { + return ModBiomes.FROZEN_LAKE; + } + return ModBiomes.LAKE; + } + protected Biome defaultWetland(float temperature) { if (temperature < 0.15) { return ModBiomes.TAIGA_SCRUB; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BasicBiomeMap.java b/src/main/java/com/terraforged/mod/biome/map/BasicBiomeMap.java similarity index 98% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BasicBiomeMap.java rename to src/main/java/com/terraforged/mod/biome/map/BasicBiomeMap.java index 37f62e8..a483825 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BasicBiomeMap.java +++ b/src/main/java/com/terraforged/mod/biome/map/BasicBiomeMap.java @@ -28,7 +28,7 @@ package com.terraforged.mod.biome.map; import com.google.common.collect.Sets; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.terraforged.core.world.biome.BiomeType; +import com.terraforged.world.biome.BiomeType; import com.terraforged.mod.biome.provider.BiomeHelper; import net.minecraft.world.biome.Biome; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeGroup.java b/src/main/java/com/terraforged/mod/biome/map/BiomeGroup.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeGroup.java rename to src/main/java/com/terraforged/mod/biome/map/BiomeGroup.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMap.java b/src/main/java/com/terraforged/mod/biome/map/BiomeMap.java similarity index 92% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMap.java rename to src/main/java/com/terraforged/mod/biome/map/BiomeMap.java index 7fa0f1a..751423a 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMap.java +++ b/src/main/java/com/terraforged/mod/biome/map/BiomeMap.java @@ -27,8 +27,7 @@ package com.terraforged.mod.biome.map; import com.google.gson.JsonElement; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.biome.BiomeType; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.world.biome.BiomeType; import net.minecraft.world.biome.Biome; import java.util.List; @@ -40,6 +39,8 @@ public interface BiomeMap { Biome getRiver(float temperature, float moisture, float shape); + Biome getLake(float temperature, float moisture, float shape); + Biome getWetland(float temperature, float moisture, float shape); Biome getOcean(float temperature, float moisture, float shape); @@ -48,7 +49,7 @@ public interface BiomeMap { Biome getBiome(BiomeType type, float temperature, float moisture, float shape); - default Biome getBiome(Cell cell) { + default Biome getBiome(Cell cell) { return getBiome(cell.biomeType, cell.temperature, cell.moisture, cell.biome); } @@ -74,6 +75,8 @@ public interface BiomeMap { Builder addRiver(Biome biome, int count); + Builder addLake(Biome biome, int count); + Builder addWetland(Biome biome, int count); Builder addOcean(Biome biome, int count); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMapBuilder.java b/src/main/java/com/terraforged/mod/biome/map/BiomeMapBuilder.java similarity index 93% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMapBuilder.java rename to src/main/java/com/terraforged/mod/biome/map/BiomeMapBuilder.java index c4c2ee5..1e276e3 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMapBuilder.java +++ b/src/main/java/com/terraforged/mod/biome/map/BiomeMapBuilder.java @@ -26,8 +26,8 @@ package com.terraforged.mod.biome.map; import com.terraforged.core.util.grid.FixedGrid; -import com.terraforged.core.world.biome.BiomeData; -import com.terraforged.core.world.biome.BiomeType; +import com.terraforged.world.biome.BiomeData; +import com.terraforged.world.biome.BiomeType; import com.terraforged.mod.biome.provider.BiomeHelper; import com.terraforged.mod.util.ListUtils; import net.minecraft.world.biome.Biome; @@ -44,6 +44,7 @@ import java.util.function.Function; public class BiomeMapBuilder implements BiomeMap.Builder { private final Map> rivers = new HashMap<>(); + private final Map> lakes = new HashMap<>(); private final Map> wetlands = new HashMap<>(); private final Map> beaches = new HashMap<>(); private final Map> oceans = new HashMap<>(); @@ -88,6 +89,13 @@ public class BiomeMapBuilder implements BiomeMap.Builder { return this; } + @Override + public BiomeMapBuilder addLake(Biome biome, int count) { + Biome.TempCategory category = BiomeHelper.getTempCategory(biome); + add(lakes.computeIfAbsent(category, c -> new ArrayList<>()), biome, count); + return this; + } + @Override public BiomeMapBuilder addWetland(Biome biome, int count) { Biome.TempCategory category = BiomeHelper.getTempCategory(biome); @@ -110,6 +118,10 @@ public class BiomeMapBuilder implements BiomeMap.Builder { return collectTemps(rivers); } + Biome[][] lakes() { + return collectTemps(lakes); + } + Biome[][] wetlands() { return collectTemps(wetlands); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomePredicate.java b/src/main/java/com/terraforged/mod/biome/map/BiomePredicate.java similarity index 95% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomePredicate.java rename to src/main/java/com/terraforged/mod/biome/map/BiomePredicate.java index 30e3fcd..8e63870 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomePredicate.java +++ b/src/main/java/com/terraforged/mod/biome/map/BiomePredicate.java @@ -25,7 +25,7 @@ package com.terraforged.mod.biome.map; -import com.terraforged.core.world.biome.BiomeData; +import com.terraforged.world.biome.BiomeData; import com.terraforged.mod.biome.provider.BiomeHelper; import net.minecraft.world.biome.Biome; @@ -85,17 +85,19 @@ public interface BiomePredicate { } BiomePredicate COAST = type(Biome.Category.BEACH, Biome.Category.MUSHROOM).or(name("shore")).or(name("beach")); - BiomePredicate WETLAND = type(Biome.Category.SWAMP); - BiomePredicate DESERT = type(Biome.Category.DESERT).or(temp(0.9, 2).and(rain(-1, 0.2))); - BiomePredicate SAVANNA = type(Biome.Category.SAVANNA).or(temp(0.8, 2).and(rain(-1, 0.4))); - BiomePredicate MESA = type(Biome.Category.MESA); - BiomePredicate STEPPE = name("steppe").and(temp(0.3, 1)); BiomePredicate COLD_STEPPE = name("steppe").and(temp(-1, 0.3)); + BiomePredicate DESERT = type(Biome.Category.DESERT).or(temp(0.9, 2).and(rain(-1, 0.2))); BiomePredicate GRASSLAND = type(Biome.Category.PLAINS); + BiomePredicate LAKE = type(Biome.Category.RIVER).and(name("lake")); + BiomePredicate MESA = type(Biome.Category.MESA); + BiomePredicate MOUNTAIN = type(Biome.Category.EXTREME_HILLS).or(name("mountain")); + BiomePredicate RIVER = type(Biome.Category.RIVER).not(name("lake")); + BiomePredicate SAVANNA = type(Biome.Category.SAVANNA).or(temp(0.8, 2).and(rain(-1, 0.4))); + BiomePredicate STEPPE = name("steppe").and(temp(0.3, 1)); + BiomePredicate TAIGA = type(Biome.Category.TAIGA).or(temp(0.19, 0.35)).not(rainType(Biome.RainType.SNOW)); BiomePredicate TEMPERATE_FOREST = type(Biome.Category.FOREST).and(rain(-1, 0.81)); BiomePredicate TEMPERATE_RAINFOREST = type(Biome.Category.FOREST).and(rain(0.8, 2)); BiomePredicate TROPICAL_RAINFOREST = type(Biome.Category.JUNGLE); - BiomePredicate TAIGA = type(Biome.Category.TAIGA).or(temp(0.19, 0.35)).not(rainType(Biome.RainType.SNOW)); BiomePredicate TUNDRA = type(Biome.Category.ICY).or(temp(-1, 0.21).and(rainType(Biome.RainType.SNOW))); - BiomePredicate MOUNTAIN = type(Biome.Category.EXTREME_HILLS).or(name("mountain")); + BiomePredicate WETLAND = type(Biome.Category.SWAMP); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/DefaultBiome.java b/src/main/java/com/terraforged/mod/biome/map/DefaultBiome.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/DefaultBiome.java rename to src/main/java/com/terraforged/mod/biome/map/DefaultBiome.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/GridBiomeMap.java b/src/main/java/com/terraforged/mod/biome/map/GridBiomeMap.java similarity index 98% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/GridBiomeMap.java rename to src/main/java/com/terraforged/mod/biome/map/GridBiomeMap.java index eb0a02f..c5278b6 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/GridBiomeMap.java +++ b/src/main/java/com/terraforged/mod/biome/map/GridBiomeMap.java @@ -29,7 +29,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.terraforged.core.util.grid.FixedList; import com.terraforged.core.util.grid.MappedList; -import com.terraforged.core.world.biome.BiomeType; +import com.terraforged.world.biome.BiomeType; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/AbstractMaxHeightModifier.java b/src/main/java/com/terraforged/mod/biome/modifier/AbstractMaxHeightModifier.java similarity index 86% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/AbstractMaxHeightModifier.java rename to src/main/java/com/terraforged/mod/biome/modifier/AbstractMaxHeightModifier.java index 8915c6d..ca5fa5c 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/AbstractMaxHeightModifier.java +++ b/src/main/java/com/terraforged/mod/biome/modifier/AbstractMaxHeightModifier.java @@ -26,9 +26,8 @@ package com.terraforged.mod.biome.modifier; import com.terraforged.core.cell.Cell; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.core.Seed; +import com.terraforged.world.climate.Climate; import me.dags.noise.Module; import me.dags.noise.Source; import net.minecraft.world.biome.Biome; @@ -49,7 +48,7 @@ public abstract class AbstractMaxHeightModifier extends AbstractOffsetModifier { } @Override - protected final Biome modify(Biome in, Cell cell, int x, int z, float ox, float oz) { + protected final Biome modify(Biome in, Cell cell, int x, int z, float ox, float oz) { float var = variance.getValue(x, z); float value = cell.value + var; if (value < minHeight) { @@ -63,5 +62,5 @@ public abstract class AbstractMaxHeightModifier extends AbstractOffsetModifier { return in; } - protected abstract Biome getModifiedBiome(Biome in, Cell cell, int x, int z, float ox, float oz); + protected abstract Biome getModifiedBiome(Biome in, Cell cell, int x, int z, float ox, float oz); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/AbstractOffsetModifier.java b/src/main/java/com/terraforged/mod/biome/modifier/AbstractOffsetModifier.java similarity index 86% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/AbstractOffsetModifier.java rename to src/main/java/com/terraforged/mod/biome/modifier/AbstractOffsetModifier.java index 0f9031a..5ba1157 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/AbstractOffsetModifier.java +++ b/src/main/java/com/terraforged/mod/biome/modifier/AbstractOffsetModifier.java @@ -27,8 +27,7 @@ package com.terraforged.mod.biome.modifier; import com.terraforged.api.biome.modifier.BiomeModifier; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.world.climate.Climate; import net.minecraft.world.biome.Biome; public abstract class AbstractOffsetModifier implements BiomeModifier { @@ -40,11 +39,11 @@ public abstract class AbstractOffsetModifier implements BiomeModifier { } @Override - public Biome modify(Biome in, Cell cell, int x, int z) { + public Biome modify(Biome in, Cell cell, int x, int z) { float dx = climate.getOffsetX(x, z, 50); float dz = climate.getOffsetX(x, z, 50); return modify(in, cell, x, z, x + dx, z + dz); } - protected abstract Biome modify(Biome in, Cell cell, int x, int z, float ox, float oz); + protected abstract Biome modify(Biome in, Cell cell, int x, int z, float ox, float oz); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/BeachModifier.java b/src/main/java/com/terraforged/mod/biome/modifier/BeachModifier.java similarity index 75% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/BeachModifier.java rename to src/main/java/com/terraforged/mod/biome/modifier/BeachModifier.java index 31abce2..b82e173 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/BeachModifier.java +++ b/src/main/java/com/terraforged/mod/biome/modifier/BeachModifier.java @@ -27,18 +27,21 @@ package com.terraforged.mod.biome.modifier; import com.terraforged.api.biome.modifier.BiomeModifier; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.world.heightmap.Levels; +import com.terraforged.world.terrain.Terrains; import com.terraforged.mod.biome.map.BiomeMap; +import com.terraforged.mod.chunk.TerraContext; import net.minecraft.world.biome.Biome; public class BeachModifier implements BiomeModifier { + private final Levels levels; private final Terrains terrain; private final BiomeMap biomeMap; - public BeachModifier(BiomeMap biomeMap, Terrains terrain) { - this.terrain = terrain; + public BeachModifier(BiomeMap biomeMap, TerraContext context) { + this.levels = context.levels; + this.terrain = context.terrain; this.biomeMap = biomeMap; } @@ -53,10 +56,13 @@ public class BeachModifier implements BiomeModifier { } @Override - public Biome modify(Biome in, Cell cell, int x, int z) { - if (cell.tag == terrain.beach) { + public Biome modify(Biome in, Cell cell, int x, int z) { + if (cell.terrainType == terrain.beach) { return biomeMap.getBeach(cell.temperature, cell.moisture, cell.biome); } + if (cell.terrainType == terrain.coast && cell.value <= levels.water) { + return biomeMap.getOcean(cell.temperature, cell.moisture, cell.biome); + } return in; } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/BiomeModifierManager.java b/src/main/java/com/terraforged/mod/biome/modifier/BiomeModifierManager.java similarity index 92% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/BiomeModifierManager.java rename to src/main/java/com/terraforged/mod/biome/modifier/BiomeModifierManager.java index 5cbf385..4b07659 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/BiomeModifierManager.java +++ b/src/main/java/com/terraforged/mod/biome/modifier/BiomeModifierManager.java @@ -28,8 +28,7 @@ package com.terraforged.mod.biome.modifier; import com.terraforged.api.biome.modifier.BiomeModifier; import com.terraforged.api.biome.modifier.ModifierManager; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.biome.BiomeType; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.world.biome.BiomeType; import com.terraforged.mod.biome.map.BiomeMap; import com.terraforged.mod.biome.provider.DesertBiomes; import com.terraforged.mod.chunk.TerraContext; @@ -47,7 +46,7 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager { public BiomeModifierManager(TerraContext context, BiomeMap biomes) { desertBiomes = new DesertBiomes(context.materials, biomes.getAllBiomes(BiomeType.DESERT)); List modifiers = new ArrayList<>(); - modifiers.add(new BeachModifier(biomes, context.terrain)); + modifiers.add(new BeachModifier(biomes, context)); modifiers.add(new DesertColorModifier(desertBiomes)); modifiers.add(new SandBiomeModifier( context.seed, @@ -79,7 +78,7 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager { } @Override - public Biome modify(Biome biome, Cell cell, int x, int z) { + public Biome modify(Biome biome, Cell cell, int x, int z) { for (BiomeModifier modifier : biomeModifiers) { if (modifier.test(biome)) { biome = modifier.modify(biome, cell, x, z); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/DesertColorModifier.java b/src/main/java/com/terraforged/mod/biome/modifier/DesertColorModifier.java similarity index 94% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/DesertColorModifier.java rename to src/main/java/com/terraforged/mod/biome/modifier/DesertColorModifier.java index d941f23..fc47448 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/DesertColorModifier.java +++ b/src/main/java/com/terraforged/mod/biome/modifier/DesertColorModifier.java @@ -27,7 +27,6 @@ package com.terraforged.mod.biome.modifier; import com.terraforged.api.biome.modifier.BiomeModifier; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; import com.terraforged.mod.biome.provider.DesertBiomes; import net.minecraft.world.biome.Biome; @@ -50,7 +49,7 @@ public class DesertColorModifier implements BiomeModifier { } @Override - public Biome modify(Biome in, Cell cell, int x, int z) { + public Biome modify(Biome in, Cell cell, int x, int z) { if (biomes.isRedDesert(in)) { if (cell.continent <= 0.5F) { return biomes.getWhiteDesert(cell.biome); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/SandBiomeModifier.java b/src/main/java/com/terraforged/mod/biome/modifier/SandBiomeModifier.java similarity index 88% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/SandBiomeModifier.java rename to src/main/java/com/terraforged/mod/biome/modifier/SandBiomeModifier.java index bd5279b..62cc408 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/SandBiomeModifier.java +++ b/src/main/java/com/terraforged/mod/biome/modifier/SandBiomeModifier.java @@ -26,10 +26,9 @@ package com.terraforged.mod.biome.modifier; import com.terraforged.core.cell.Cell; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.core.Seed; +import com.terraforged.world.climate.Climate; +import com.terraforged.world.heightmap.Levels; import com.terraforged.mod.material.MaterialHelper; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; @@ -61,7 +60,7 @@ public class SandBiomeModifier extends AbstractMaxHeightModifier { } @Override - protected Biome getModifiedBiome(Biome in, Cell cell, int x, int z, float ox, float oz) { + protected Biome getModifiedBiome(Biome in, Cell cell, int x, int z, float ox, float oz) { return Biomes.BADLANDS; } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/AbstractBiomeProvider.java b/src/main/java/com/terraforged/mod/biome/provider/AbstractBiomeProvider.java similarity index 77% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/AbstractBiomeProvider.java rename to src/main/java/com/terraforged/mod/biome/provider/AbstractBiomeProvider.java index 99cb204..a431457 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/AbstractBiomeProvider.java +++ b/src/main/java/com/terraforged/mod/biome/provider/AbstractBiomeProvider.java @@ -27,22 +27,15 @@ package com.terraforged.mod.biome.provider; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; -import net.minecraftforge.common.BiomeDictionary; -import net.minecraftforge.registries.ForgeRegistries; import java.util.List; import java.util.Random; import java.util.Set; -import java.util.stream.Collectors; public abstract class AbstractBiomeProvider extends net.minecraft.world.biome.provider.BiomeProvider { public AbstractBiomeProvider() { - super(getOverworldBiomes()); - } - - public Set getAvailableBiomes() { - return super.field_226837_c_; + super(BiomeHelper.getAllBiomes()); } @Override @@ -58,11 +51,4 @@ public abstract class AbstractBiomeProvider extends net.minecraft.world.biome.pr public abstract Set getBiomesInSquare(int x, int y, int z, int size); public abstract BlockPos findBiomePosition(int centerX, int centerY, int centerZ, int range, List biomes, Random random); - - private static Set getOverworldBiomes() { - return ForgeRegistries.BIOMES.getValues().stream() - .map(biome -> biome.delegate.get()) - .filter(biome -> BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.OVERWORLD)) - .collect(Collectors.toSet()); - } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeHelper.java b/src/main/java/com/terraforged/mod/biome/provider/BiomeHelper.java similarity index 80% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeHelper.java rename to src/main/java/com/terraforged/mod/biome/provider/BiomeHelper.java index 121472a..8b9da6e 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeHelper.java +++ b/src/main/java/com/terraforged/mod/biome/provider/BiomeHelper.java @@ -25,9 +25,8 @@ package com.terraforged.mod.biome.provider; -import com.terraforged.core.settings.BiomeSettings; -import com.terraforged.core.world.biome.BiomeData; -import com.terraforged.core.world.biome.BiomeType; +import com.terraforged.world.biome.BiomeData; +import com.terraforged.world.biome.BiomeType; import com.terraforged.mod.biome.ModBiomes; import com.terraforged.mod.biome.map.BiomeMap; import com.terraforged.mod.biome.map.BiomeMapBuilder; @@ -50,7 +49,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; -import java.util.stream.Collectors; public class BiomeHelper { @@ -74,33 +72,24 @@ public class BiomeHelper { public static BiomeMap getDefaultBiomeMap() { List biomes = getAllBiomeData(); + BiomeWeights weights = new BiomeWeights(); BiomeMap.Builder builder = getBuilder(biomes); for (BiomeData data : biomes) { - int weight = 10; Biome biome = (Biome) data.reference; - if (biome.isMutation() && getId(biome).contains("hills")) { continue; } - if (biome.getCategory() == Biome.Category.FOREST) { - weight = 5; - } - - // don't use BiomeDictionary with transient biomes - if (ForgeRegistries.BIOMES.containsKey(biome.getRegistryName())) { - if (BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.RARE)) { - weight = 1; - } - } - + int weight = weights.getWeight(biome); if (BiomePredicate.COAST.test(data)) { builder.addBeach(biome, weight); } else if (biome.getCategory() == Biome.Category.OCEAN) { builder.addOcean(biome, weight); - } else if (biome.getCategory() == Biome.Category.RIVER) { + } else if (BiomePredicate.RIVER.test(data)) { builder.addRiver(biome, weight); - } else if (biome.getCategory() == Biome.Category.SWAMP) { + } else if (BiomePredicate.LAKE.test(data)) { + builder.addLake(biome, weight); + } else if (BiomePredicate.WETLAND.test(data)) { builder.addWetland(biome, weight); } else { Collection types = getTypes(data, biome); @@ -111,7 +100,7 @@ public class BiomeHelper { } builder.addBiome(BiomeType.TEMPERATE_RAINFOREST, Biomes.PLAINS, 10); - builder.addBiome(BiomeType.TEMPERATE_FOREST, Biomes.FLOWER_FOREST, 3); + builder.addBiome(BiomeType.TEMPERATE_FOREST, Biomes.FLOWER_FOREST, 2); builder.addBiome(BiomeType.TEMPERATE_FOREST, Biomes.PLAINS, 10); builder.addBiome(BiomeType.TUNDRA, ModBiomes.SNOWY_TAIGA_SCRUB, 5); builder.addBiome(BiomeType.TAIGA, ModBiomes.TAIGA_SCRUB, 5); @@ -119,31 +108,6 @@ public class BiomeHelper { return builder.build(); } - public static BiomeMap getBiomeMap(BiomeSettings settings) { - List biomes = getAllBiomeData(); - BiomeMap.Builder builder = getBuilder(biomes); - Map biomeMap = biomes.stream().collect(Collectors.toMap(d -> d.name, d -> d)); - Map groupMap = settings.asMap(); - for (Map.Entry e : groupMap.entrySet()) { - for (BiomeSettings.BiomeWeight biomeWeight : e.getValue().biomes) { - BiomeData data = biomeMap.get(biomeWeight.id); - if (data == null) { - continue; - } - builder.addBiome(e.getKey(), (Biome) data.reference, biomeWeight.weight); - } - } - for (BiomeData data : biomes) { - Biome biome = (Biome) data.reference; - if (biome.getCategory() == Biome.Category.OCEAN) { - builder.addOcean(biome, 10); - } else if (biome.getCategory() == Biome.Category.RIVER) { - builder.addRiver(biome, 10); - } - } - return builder.build(); - } - public static Biome.TempCategory getTempCategory(Biome biome) { // vanilla ocean biome properties are not at all helpful for determining temperature if (biome.getCategory() == Biome.Category.OCEAN) { @@ -186,7 +150,7 @@ public class BiomeHelper { } public static List getAllBiomeData() { - Collection biomes = TerraBiomeRegistry.getInstance().getAll(BiomeHelper::filter); + Collection biomes = getAllBiomes(); Vec2f tempRange = getRange(biomes, Biome::getDefaultTemperature); Vec2f moistRange = getRange(biomes, Biome::getDownfall); List list = new LinkedList<>(); @@ -200,6 +164,17 @@ public class BiomeHelper { return list; } + public static Set getAllBiomes() { + Set biomes = new HashSet<>(); + for (Biome biome : ForgeRegistries.BIOMES) { + if (filter(biome)) { + continue; + } + biomes.add(biome.delegate.get()); + } + return biomes; + } + private static boolean filter(Biome biome) { if (biome.getCategory() == Biome.Category.NONE) { return true; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java b/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java similarity index 75% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java rename to src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java index 5e7bc4f..b4e3482 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java +++ b/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java @@ -28,18 +28,15 @@ package com.terraforged.mod.biome.provider; import com.google.common.collect.Sets; import com.terraforged.core.cell.Cell; import com.terraforged.core.region.chunk.ChunkReader; -import com.terraforged.core.world.decorator.Decorator; -import com.terraforged.core.world.heightmap.WorldLookup; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.world.terrain.decorator.Decorator; +import com.terraforged.world.heightmap.WorldLookup; import com.terraforged.mod.biome.map.BiomeMap; import com.terraforged.mod.biome.modifier.BiomeModifierManager; -import com.terraforged.mod.chunk.TerraContainer; +import com.terraforged.mod.chunk.util.TerraContainer; import com.terraforged.mod.chunk.TerraContext; import com.terraforged.mod.util.setup.SetupHooks; -import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.structure.Structure; import java.util.Collections; import java.util.HashMap; @@ -63,20 +60,8 @@ public class BiomeProvider extends AbstractBiomeProvider { this.modifierManager = SetupHooks.setup(new BiomeModifierManager(context, biomeMap), context.copy()); } - public TerraContext getContext() { - return context; - } - - public void lookupPos(int x, int z, Cell cell) { - worldLookup.applyCell(cell, x, z); - } - - public Cell lookupPos(int x, int z) { - return worldLookup.getCell(x, z); - } - - public boolean canSpawnAt(Cell cell) { - return cell.tag != context.terrain.ocean && cell.tag != context.terrain.deepOcean && cell.value > context.levels.ground; + public Cell lookupPos(int x, int z) { + return getWorldLookup().getCell(x, z); } @Override @@ -95,7 +80,7 @@ public class BiomeProvider extends AbstractBiomeProvider { int rangeX = maxX - minX + 1; int rangeZ = maxZ - minZ + 1; Set set = Sets.newHashSet(); - Cell cell = new Cell<>(); + Cell cell = new Cell(); for(int dz = 0; dz < rangeZ; ++dz) { for(int dx = 0; dx < rangeX; ++dx) { int x = (minX + dx) << 2; @@ -121,7 +106,7 @@ public class BiomeProvider extends AbstractBiomeProvider { BlockPos blockpos = null; int attempts = 0; - Cell cell = new Cell<>(); + Cell cell = new Cell(); for(int dz = 0; dz < rangeZ; ++dz) { for(int dx = 0; dx < rangeX; ++dx) { int x = (minX + dx) << 2; @@ -138,26 +123,12 @@ public class BiomeProvider extends AbstractBiomeProvider { return blockpos; } - @Override - public boolean hasStructure(Structure structure) { - return this.hasStructureCache.computeIfAbsent(structure, (name) -> { - for (Biome biome : getAvailableBiomes()) { - if (biome.hasStructure(name)) { - return true; - } - } - return false; - }); + public WorldLookup getWorldLookup() { + return worldLookup; } - @Override - public Set getSurfaceBlocks() { - if (this.topBlocksCache.isEmpty()) { - for (Biome biome : getAvailableBiomes()) { - this.topBlocksCache.add(biome.getSurfaceBuilderConfig().getTop()); - } - } - return this.topBlocksCache; + public TerraContext getContext() { + return context; } public BiomeModifierManager getModifierManager() { @@ -177,8 +148,8 @@ public class BiomeProvider extends AbstractBiomeProvider { return builder.build(chunkReader); } - public Biome getBiome(Cell cell, int x, int z) { - if (cell.tag == context.terrain.wetlands) { + public Biome getBiome(Cell cell, int x, int z) { + if (cell.terrainType.isWetland()) { return biomeMap.getWetland(cell.temperature, cell.moisture, cell.biome); } @@ -186,7 +157,11 @@ public class BiomeProvider extends AbstractBiomeProvider { return getModifierManager().modify(biomeMap.getBiome(cell), cell, x, z); } - if (cell.tag == context.terrain.river || cell.tag == context.terrain.riverBanks || cell.tag == context.terrain.lake) { + if (cell.terrainType.isLake()) { + return biomeMap.getLake(cell.temperature, cell.moisture, cell.biome); + } + + if (cell.terrainType.isRiver()) { Biome biome = biomeMap.getBiome(cell); if (overridesRiver(biome)) { return biome; @@ -194,21 +169,18 @@ public class BiomeProvider extends AbstractBiomeProvider { return biomeMap.getRiver(cell.temperature, cell.moisture, cell.biome); } - if (cell.tag == context.terrain.ocean) { + if (cell.terrainType.isShallowOcean()) { return biomeMap.getOcean(cell.temperature, cell.moisture, cell.biome); } return biomeMap.getDeepOcean(cell.temperature, cell.moisture, cell.biome); } + public boolean canSpawnAt(Cell cell) { + return cell.terrainType != context.terrain.ocean && cell.terrainType != context.terrain.deepOcean; + } + private static boolean overridesRiver(Biome biome) { return biome.getCategory() == Biome.Category.SWAMP || biome.getCategory() == Biome.Category.JUNGLE; } - - private static class SearchContext { - - private int count = 0; - private boolean first = true; - private final BlockPos.Mutable pos = new BlockPos.Mutable(); - } } diff --git a/src/main/java/com/terraforged/mod/biome/provider/BiomeWeights.java b/src/main/java/com/terraforged/mod/biome/provider/BiomeWeights.java new file mode 100644 index 0000000..be782e8 --- /dev/null +++ b/src/main/java/com/terraforged/mod/biome/provider/BiomeWeights.java @@ -0,0 +1,51 @@ +package com.terraforged.mod.biome.provider; + +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.biome.Biome; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeManager; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class BiomeWeights { + + private final int standardWeight; + private final int forestWeight; + private final int rareWeight; + private final Map biomes = new HashMap<>(); + + public BiomeWeights() { + this(10, 5, 1); + } + + public BiomeWeights(int standard, int forest, int rare) { + this.standardWeight = standard; + this.forestWeight = forest; + this.rareWeight = rare; + for (BiomeManager.BiomeType type : BiomeManager.BiomeType.values()) { + List entries = BiomeManager.getBiomes(type); + if (entries == null) { + continue; + } + for (BiomeManager.BiomeEntry entry : entries) { + biomes.put(entry.biome.getRegistryName(), entry.itemWeight); + } + } + } + + public int getWeight(Biome biome) { + Integer value = biomes.get(biome.getRegistryName()); + if (value != null) { + return value; + } + if (BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.RARE)) { + return rareWeight; + } + if (biome.getCategory() == Biome.Category.FOREST) { + return forestWeight; + } + return standardWeight; + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/DesertBiomes.java b/src/main/java/com/terraforged/mod/biome/provider/DesertBiomes.java similarity index 96% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/DesertBiomes.java rename to src/main/java/com/terraforged/mod/biome/provider/DesertBiomes.java index 18941d9..5aa7546 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/DesertBiomes.java +++ b/src/main/java/com/terraforged/mod/biome/provider/DesertBiomes.java @@ -27,11 +27,10 @@ package com.terraforged.mod.biome.provider; import com.terraforged.api.material.layer.LayerManager; import com.terraforged.api.material.layer.LayerMaterial; -import com.terraforged.core.util.concurrent.ObjectPool; +import com.terraforged.core.concurrent.ObjectPool; import com.terraforged.mod.material.Materials; import com.terraforged.mod.util.DummyBlockReader; import com.terraforged.mod.util.ListUtils; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.material.MaterialColor; @@ -102,7 +101,6 @@ public class DesertBiomes { } public LayerMaterial getSandLayers(Biome biome) { - Block top = biome.getSurfaceBuilderConfig().getTop().getBlock(); return layerManager.getMaterial(Blocks.SAND); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/spawn/SpawnHandler.java b/src/main/java/com/terraforged/mod/biome/spawn/SpawnHandler.java similarity index 77% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/spawn/SpawnHandler.java rename to src/main/java/com/terraforged/mod/biome/spawn/SpawnHandler.java index 188dca9..e32a6a0 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/spawn/SpawnHandler.java +++ b/src/main/java/com/terraforged/mod/biome/spawn/SpawnHandler.java @@ -1,5 +1,6 @@ package com.terraforged.mod.biome.spawn; +import com.terraforged.world.continent.MutableVeci; import com.terraforged.mod.Log; import com.terraforged.mod.biome.provider.BiomeProvider; import net.minecraft.util.math.BlockPos; @@ -21,7 +22,8 @@ public class SpawnHandler { if (world.getChunkProvider().getChunkGenerator().getBiomeProvider() instanceof BiomeProvider) { Log.info("Searching for world spawn position"); BiomeProvider provider = (BiomeProvider) world.getChunkProvider().getChunkGenerator().getBiomeProvider(); - SpawnSearch search = new SpawnSearch(BlockPos.ZERO, provider); + BlockPos center = getSearchCenter(provider, true); + SpawnSearch search = new SpawnSearch(center, provider); BlockPos spawn = search.get(); Log.info("Setting world spawn: {}", spawn); @@ -36,6 +38,15 @@ public class SpawnHandler { } } + private static BlockPos getSearchCenter(BiomeProvider provider, boolean continent) { + if (continent) { + MutableVeci pos = new MutableVeci(); + provider.getContext().heightmap.getContinent().getNearestCenter(0, 0, pos); + return new BlockPos(pos.x, 0, pos.z); + } + return BlockPos.ZERO; + } + private static void createBonusChest(ServerWorld world, BlockPos pos) { ConfiguredFeature chest = Feature.BONUS_CHEST.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG); chest.place(world, world.getChunkProvider().getChunkGenerator(), world.rand, pos); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/spawn/SpawnSearch.java b/src/main/java/com/terraforged/mod/biome/spawn/SpawnSearch.java similarity index 79% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/spawn/SpawnSearch.java rename to src/main/java/com/terraforged/mod/biome/spawn/SpawnSearch.java index be5b8cc..39e170d 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/spawn/SpawnSearch.java +++ b/src/main/java/com/terraforged/mod/biome/spawn/SpawnSearch.java @@ -1,7 +1,6 @@ package com.terraforged.mod.biome.spawn; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; import com.terraforged.mod.Log; import com.terraforged.mod.biome.provider.BiomeProvider; import com.terraforged.mod.command.search.Search; @@ -10,7 +9,7 @@ import net.minecraft.util.math.BlockPos; public class SpawnSearch extends Search { private final BiomeProvider biomeProvider; - private final Cell cell = new Cell<>(); + private final Cell cell = new Cell(); public SpawnSearch(BlockPos center, BiomeProvider biomeProvider) { super(center, 0, 2048); @@ -24,19 +23,19 @@ public class SpawnSearch extends Search { @Override public boolean test(BlockPos pos) { - biomeProvider.lookupPos(pos.getX(), pos.getZ(), cell); + biomeProvider.getWorldLookup().applyCell(cell, pos.getX(), pos.getZ()); return biomeProvider.canSpawnAt(cell); } @Override - protected BlockPos success(BlockPos.Mutable pos) { + public BlockPos success(BlockPos.Mutable pos) { pos.setY(biomeProvider.getContext().levels.scale(cell.value)); Log.info("Found valid spawn position: {}", pos); return super.success(pos); } @Override - protected BlockPos fail(BlockPos pos) { + public BlockPos fail(BlockPos pos) { Log.info("Unable to find valid spawn position, defaulting x=0, z=0"); return new BlockPos(0, biomeProvider.getContext().levels.groundLevel, 0); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/surface/DesertDunes.java b/src/main/java/com/terraforged/mod/biome/surface/DunesSurface.java similarity index 80% rename from TerraForgedMod/src/main/java/com/terraforged/mod/decorator/surface/DesertDunes.java rename to src/main/java/com/terraforged/mod/biome/surface/DunesSurface.java index 7089486..f61d268 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/surface/DesertDunes.java +++ b/src/main/java/com/terraforged/mod/biome/surface/DunesSurface.java @@ -23,25 +23,27 @@ * SOFTWARE. */ -package com.terraforged.mod.decorator.surface; +package com.terraforged.mod.biome.surface; import com.terraforged.api.chunk.surface.Surface; import com.terraforged.api.chunk.surface.SurfaceContext; import com.terraforged.api.material.layer.LayerMaterial; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.world.heightmap.Levels; +import com.terraforged.world.terrain.Terrains; import com.terraforged.mod.biome.provider.BiomeProvider; import com.terraforged.mod.biome.provider.DesertBiomes; import com.terraforged.mod.chunk.TerraContext; import me.dags.noise.Module; import me.dags.noise.Source; import me.dags.noise.func.CellFunc; +import me.dags.noise.util.NoiseUtil; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.gen.Heightmap; -public class DesertDunes implements Surface { +public class DunesSurface implements Surface { private final int maxHeight; private final Levels levels; @@ -50,7 +52,7 @@ public class DesertDunes implements Surface { private final DesertBiomes deserts; private final BlockPos.Mutable pos = new BlockPos.Mutable(); - public DesertDunes(TerraContext context, int maxHeight, DesertBiomes deserts) { + public DunesSurface(TerraContext context, int maxHeight, DesertBiomes deserts) { Module dunes = Source.cell(context.seed.next(), 80, CellFunc.DISTANCE) .warp(context.seed.next(), 70, 1, 70); this.terrains = context.terrain; @@ -63,16 +65,17 @@ public class DesertDunes implements Surface { @Override public void buildSurface(int x, int z, int surface, SurfaceContext ctx) { float value = module.getValue(x, z) * getMask(ctx.cell); - float baseHeight = ctx.cell.value * levels.worldHeight; + float baseHeight = ctx.chunk.getTopBlockY(Heightmap.Type.WORLD_SURFACE_WG, x & 15, z & 15); float duneHeight = baseHeight + value * maxHeight; int duneBase = (int) baseHeight; - int duneTop = (int) duneHeight; + int duneTop = (int) duneHeight + 1; if (duneTop < levels.waterLevel || duneTop <= baseHeight) { return; } LayerMaterial material = deserts.getSandLayers(ctx.biome); if (material == null) { + fill(x, z, duneBase - 4, duneTop, ctx, ctx.chunk, Blocks.SAND.getDefaultState()); return; } @@ -89,10 +92,10 @@ public class DesertDunes implements Surface { } public static Surface create(TerraContext context, DesertBiomes desertBiomes) { - return new DesertDunes(context, 25, desertBiomes); + return new DunesSurface(context, 25, desertBiomes); } - private static float getMask(Cell cell) { - return cell.biomeMask(0F, 0.75F) * cell.mask(0.4F, 0.5F, 0F, 0.8F); + private static float getMask(Cell cell) { + return cell.biomeMask(0F, 0.7F) * (NoiseUtil.map(cell.riverMask, 0.5F, 0.95F, 0.45F)); } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/surface/FrozenOcean.java b/src/main/java/com/terraforged/mod/biome/surface/IcebergsSurface.java similarity index 94% rename from TerraForgedMod/src/main/java/com/terraforged/mod/decorator/surface/FrozenOcean.java rename to src/main/java/com/terraforged/mod/biome/surface/IcebergsSurface.java index 68d2929..3a80217 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/surface/FrozenOcean.java +++ b/src/main/java/com/terraforged/mod/biome/surface/IcebergsSurface.java @@ -23,13 +23,13 @@ * SOFTWARE. */ -package com.terraforged.mod.decorator.surface; +package com.terraforged.mod.biome.surface; import com.terraforged.api.chunk.surface.Surface; import com.terraforged.api.chunk.surface.SurfaceContext; import com.terraforged.api.material.state.States; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.heightmap.Levels; +import com.terraforged.world.heightmap.Levels; import com.terraforged.mod.chunk.TerraContext; import me.dags.noise.Module; import me.dags.noise.Source; @@ -38,7 +38,7 @@ import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; -public class FrozenOcean implements Surface { +public class IcebergsSurface implements Surface { private final Module up; private final Module down; @@ -50,7 +50,7 @@ public class FrozenOcean implements Surface { private final float minDepth; private final float depthRange; - public FrozenOcean(TerraContext context, int height, int depth) { + public IcebergsSurface(TerraContext context, int height, int depth) { Levels levels = context.levels; Module shape = Source.perlin(context.seed.next(), 65, 3) .warp(context.seed.next(), 15, 1, 10) @@ -117,7 +117,7 @@ public class FrozenOcean implements Surface { return States.PACKED_ICE.get(); } - private float alpha(Cell cell) { + private float alpha(Cell cell) { if (cell.value > minDepth) { return 0; } diff --git a/src/main/java/com/terraforged/mod/biome/surface/SteppeSurface.java b/src/main/java/com/terraforged/mod/biome/surface/SteppeSurface.java new file mode 100644 index 0000000..c567912 --- /dev/null +++ b/src/main/java/com/terraforged/mod/biome/surface/SteppeSurface.java @@ -0,0 +1,30 @@ +package com.terraforged.mod.biome.surface; + +import com.terraforged.api.chunk.surface.Surface; +import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.material.state.States; +import me.dags.noise.Module; +import me.dags.noise.Source; +import me.dags.noise.func.CellFunc; +import net.minecraft.block.BlockState; + +public class SteppeSurface implements Surface { + + @Override + public void buildSurface(int x, int z, int height, SurfaceContext ctx) { + Module module = Source.cell(123, 4, CellFunc.DISTANCE).warp(214, 80, 1, 40); + float value = module.getValue(x, z); + + BlockState state = States.SAND.get(); + + if (value > 0.275F) { + state = States.GRASS_BLOCK.get(); + } else if (value > 0.225F) { + state = States.DIRT.get(); + } + + ctx.chunk.setBlockState(ctx.pos.setPos(x, height, z), state, false); + ctx.chunk.setBlockState(ctx.pos.setPos(x, height-1, z), state, false); + ctx.chunk.setBlockState(ctx.pos.setPos(x, height-2, z), state, false); + } +} diff --git a/src/main/java/com/terraforged/mod/biome/surface/SwampSurface.java b/src/main/java/com/terraforged/mod/biome/surface/SwampSurface.java new file mode 100644 index 0000000..68d7d11 --- /dev/null +++ b/src/main/java/com/terraforged/mod/biome/surface/SwampSurface.java @@ -0,0 +1,34 @@ +package com.terraforged.mod.biome.surface; + +import com.terraforged.api.chunk.surface.Surface; +import com.terraforged.api.chunk.surface.SurfaceContext; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig; + +public class SwampSurface implements Surface { + + private final SurfaceBuilderConfig config = SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG; + + @Override + public void buildSurface(int x, int z, int height, SurfaceContext ctx) { + double noise = Biome.INFO_NOISE.noiseAt(x * 0.25D, z * 0.25D, false); + if (noise > 0.0D) { + int dx = x & 15; + int dz = z & 15; + for (int y = height; y >= height - 10; --y) { + ctx.pos.setPos(dx, y, dz); + if (ctx.buffer.getBlockState(ctx.pos).isAir()) { + continue; + } + + if (y == ctx.seaLevel && ctx.buffer.getBlockState(ctx.pos).getBlock() != ctx.fluid.getBlock()) { + ctx.buffer.setBlockState(ctx.pos, ctx.fluid, false); + } + break; + } + } + + SurfaceBuilder.DEFAULT.buildSurface(ctx.random, ctx.buffer, ctx.biome, x, z, height, noise, ctx.solid, ctx.fluid, ctx.seaLevel, ctx.seed, config); + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/tag/BiomeTagManager.java b/src/main/java/com/terraforged/mod/biome/tag/BiomeTagManager.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/biome/tag/BiomeTagManager.java rename to src/main/java/com/terraforged/mod/biome/tag/BiomeTagManager.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ChunkGeneratorFactory.java b/src/main/java/com/terraforged/mod/chunk/ChunkGeneratorFactory.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ChunkGeneratorFactory.java rename to src/main/java/com/terraforged/mod/chunk/ChunkGeneratorFactory.java diff --git a/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java b/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java new file mode 100644 index 0000000..904a1ad --- /dev/null +++ b/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java @@ -0,0 +1,240 @@ +/* + * + * MIT License + * + * Copyright (c) 2020 TerraForged + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.terraforged.mod.chunk; + +import com.terraforged.api.chunk.column.ColumnDecorator; +import com.terraforged.api.chunk.surface.SurfaceManager; +import com.terraforged.api.material.layer.LayerManager; +import com.terraforged.core.cell.Cell; +import com.terraforged.core.region.Size; +import com.terraforged.core.region.chunk.ChunkReader; +import com.terraforged.core.region.gen.RegionCache; +import com.terraforged.mod.feature.manager.FeatureManager; +import com.terraforged.mod.feature.manager.data.DataManager; +import com.terraforged.mod.Log; +import com.terraforged.mod.biome.provider.BiomeProvider; +import com.terraforged.mod.chunk.component.BiomeGenerator; +import com.terraforged.mod.chunk.component.MobGenerator; +import com.terraforged.mod.chunk.component.StructureGenerator; +import com.terraforged.mod.chunk.component.TerrainCarver; +import com.terraforged.mod.chunk.component.TerrainGenerator; +import com.terraforged.mod.chunk.util.TerraHooks; +import com.terraforged.mod.feature.BlockDataManager; +import com.terraforged.mod.material.Materials; +import com.terraforged.mod.material.geology.GeoManager; +import com.terraforged.mod.util.Environment; +import com.terraforged.mod.util.setup.SetupHooks; +import net.minecraft.entity.EntityClassification; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.BiomeManager; +import net.minecraft.world.chunk.IChunk; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.GenerationSettings; +import net.minecraft.world.gen.GenerationStage; +import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.gen.WorldGenRegion; +import net.minecraft.world.gen.feature.template.TemplateManager; +import net.minecraft.world.server.ServerWorld; + +import java.util.List; + +public class TerraChunkGenerator extends ChunkGenerator { + + private final TerraContext context; + private final BiomeProvider biomeProvider; + + private final MobGenerator mobGenerator; + private final BiomeGenerator biomeGenerator; + private final TerrainCarver terrainCarver; + private final TerrainGenerator terrainGenerator; + private final StructureGenerator structureGenerator; + + private final GeoManager geologyManager; + private final FeatureManager featureManager; + private final SurfaceManager surfaceManager; + private final BlockDataManager blockDataManager; + private final List baseDecorators; + private final List postProcessors; + + private final RegionCache regionCache; + + public TerraChunkGenerator(TerraContext context, BiomeProvider biomeProvider, GenerationSettings settings) { + super(context.world, biomeProvider, settings); + this.context = context; + this.biomeProvider = biomeProvider; + this.mobGenerator = new MobGenerator(this); + this.biomeGenerator = new BiomeGenerator(this); + this.terrainCarver = new TerrainCarver(this); + this.terrainGenerator = new TerrainGenerator(this); + this.structureGenerator = new StructureGenerator(this); + + this.surfaceManager = TerraHooks.createSurfaceManager(context); + this.geologyManager = TerraHooks.createGeologyManager(context); + this.baseDecorators = TerraHooks.createBaseDecorators(geologyManager, context); + this.postProcessors = TerraHooks.createFeatureDecorators(context); + this.regionCache = context.cache; + + try (DataManager data = TerraHooks.createDataManager()) { + FeatureManager.initData(data); + this.featureManager = TerraHooks.createFeatureManager(data, context); + this.blockDataManager = TerraHooks.createBlockDataManager(data, context); + FeatureManager.clearData(); + } + + SetupHooks.setup(getLayerManager(), context.copy()); + SetupHooks.setup(baseDecorators, postProcessors, context.copy()); + Log.info("Vanilla Biomes: {}", Environment.isVanillaBiomes()); + } + + @Override + public final void generateStructures(BiomeManager biomes, IChunk chunk, ChunkGenerator generator, TemplateManager templates) { + structureGenerator.generateStructureStarts(biomes, chunk, generator, templates); + } + + @Override + public final void generateStructureStarts(IWorld world, IChunk chunk) { + structureGenerator.generateStructureReferences(world, chunk); + } + + @Override + public final void generateBiomes(IChunk chunk) { + biomeGenerator.generateBiomes(chunk); + } + + @Override + public final void makeBase(IWorld world, IChunk chunk) { + terrainGenerator.generateTerrain(world, chunk); + } + + @Override + public final void func_225551_a_(WorldGenRegion world, IChunk chunk) { + terrainGenerator.generateSurface(world, chunk); + } + + @Override + public final void decorate(WorldGenRegion region) { + terrainGenerator.generateFeatures(region); + } + + @Override + public final void func_225550_a_(BiomeManager biomes, IChunk chunk, GenerationStage.Carving type) { + terrainCarver.carveTerrain(biomes, chunk, type); + } + + @Override + public final void spawnMobs(WorldGenRegion region) { + mobGenerator.generateMobs(region); + } + + @Override + public final void spawnMobs(ServerWorld worldIn, boolean hostile, boolean peaceful) { + mobGenerator.spawnMobs(worldIn, hostile, peaceful); + } + + @Override + public final List getPossibleCreatures(EntityClassification type, BlockPos pos) { + return mobGenerator.getPossibleCreatures(world, type, pos); + } + + public final Biome getBiome(BiomeManager biomes, BlockPos pos) { + return super.getBiome(biomes, pos); + } + + @Override + public final int func_222529_a(int x, int z, Heightmap.Type type) { + int chunkX = Size.blockToChunk(x); + int chunkZ = Size.blockToChunk(z); + ChunkReader chunk = getChunkReader(chunkX, chunkZ); + Cell cell = chunk.getCell(x, z); + int level = context.levels.scale(cell.value) + 1; + if (type == Heightmap.Type.OCEAN_FLOOR || type == Heightmap.Type.OCEAN_FLOOR_WG) { + return level; + } + return Math.max(getSeaLevel(), level); + } + + @Override + public BiomeProvider getBiomeProvider() { + return biomeProvider; + } + + @Override + public final int getMaxHeight() { + return getContext().levels.worldHeight; + } + + @Override + public final int getSeaLevel() { + return getContext().levels.waterLevel; + } + + @Override + public final int getGroundHeight() { + return getContext().levels.groundLevel; + } + + public final TerraContext getContext() { + return context; + } + + public final Materials getMaterials() { + return context.materials; + } + + public final FeatureManager getFeatureManager() { + return featureManager; + } + + public final GeoManager getGeologyManager() { + return geologyManager; + } + + public final LayerManager getLayerManager() { + return context.materials.getLayerManager(); + } + + public final SurfaceManager getSurfaceManager() { + return surfaceManager; + } + + public final BlockDataManager getBlockDataManager() { + return blockDataManager; + } + + public final List getBaseDecorators() { + return baseDecorators; + } + + public final List getPostProcessors() { + return postProcessors; + } + + public final ChunkReader getChunkReader(int chunkX, int chunkZ) { + return regionCache.getChunk(chunkX, chunkZ); + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContext.java b/src/main/java/com/terraforged/mod/chunk/TerraContext.java similarity index 68% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContext.java rename to src/main/java/com/terraforged/mod/chunk/TerraContext.java index aacd5e8..d15ddc9 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContext.java +++ b/src/main/java/com/terraforged/mod/chunk/TerraContext.java @@ -28,14 +28,15 @@ package com.terraforged.mod.chunk; import com.terraforged.api.chunk.column.DecoratorContext; import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer; import com.terraforged.api.chunk.surface.SurfaceContext; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.WorldGeneratorFactory; -import com.terraforged.core.world.heightmap.Heightmap; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.core.region.gen.RegionCache; +import com.terraforged.core.region.gen.RegionGenerator; +import com.terraforged.core.concurrent.ThreadPool; +import com.terraforged.world.GeneratorContext; +import com.terraforged.world.WorldGeneratorFactory; +import com.terraforged.world.heightmap.Heightmap; +import com.terraforged.world.terrain.Terrains; import com.terraforged.mod.material.Materials; import com.terraforged.mod.settings.TerraSettings; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; import net.minecraft.world.IWorld; import net.minecraft.world.chunk.IChunk; import net.minecraft.world.gen.GenerationSettings; @@ -45,18 +46,22 @@ public class TerraContext extends GeneratorContext { public final IWorld world; public final Heightmap heightmap; public final Materials materials; - public final WorldGeneratorFactory factory; public final TerraSettings terraSettings; + public TerraContext(TerraContext other) { + super(other.terrain, other.settings, other.terrainFactory, TerraContext::createCache); + this.world = other.world; + this.materials = other.materials; + this.terraSettings = other.terraSettings; + this.heightmap = factory.getHeightmap(); + } + public TerraContext(IWorld world, Terrains terrain, TerraSettings settings) { - super(terrain, settings, TerraTerrainProvider::new); + super(terrain, settings, TerraTerrainProvider::new, TerraContext::createCache); this.world = world; this.materials = new Materials(); this.terraSettings = settings; - this.factory = new WorldGeneratorFactory(this); this.heightmap = factory.getHeightmap(); - ItemStack stack = new ItemStack(Items.COBBLESTONE); - stack.getMaxStackSize(); } public DecoratorContext decorator(IChunk chunk) { @@ -66,4 +71,14 @@ public class TerraContext extends GeneratorContext { public SurfaceContext surface(ChunkSurfaceBuffer buffer, GenerationSettings settings) { return new SurfaceContext(buffer, levels, terrain, factory.getClimate(), settings, world.getSeed()); } + + public static RegionCache createCache(WorldGeneratorFactory factory) { + return RegionGenerator.builder() + .factory(factory) + .size(3, 2) + .pool(ThreadPool.getPool()) + .batch(6) + .build() + .toCache(); + } } diff --git a/src/main/java/com/terraforged/mod/chunk/TerraGenSettings.java b/src/main/java/com/terraforged/mod/chunk/TerraGenSettings.java new file mode 100644 index 0000000..c7eba3d --- /dev/null +++ b/src/main/java/com/terraforged/mod/chunk/TerraGenSettings.java @@ -0,0 +1,92 @@ +/* + * + * MIT License + * + * Copyright (c) 2020 TerraForged + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.terraforged.mod.chunk; + +import com.terraforged.mod.settings.StructureSettings; +import net.minecraft.world.gen.OverworldGenSettings; + +public class TerraGenSettings extends OverworldGenSettings { + + private final int villageSeparation; + private final int mansionSeparation; + private final int biomeFeatureSeparation; + private final int shipwreckDistance; + private final int shipwreckSeparation; + private final int oceanRuinDistance; + private final int oceanRuinSeparation; + + public TerraGenSettings(StructureSettings settings) { + super.villageDistance = settings.villages.distance; + this.villageSeparation = settings.villages.separation; + super.mansionDistance = settings.mansions.distance; + this.mansionSeparation = settings.mansions.separation; + super.strongholdDistance = settings.strongholds.distance; + super.strongholdSpread = settings.strongholds.separation; + super.oceanMonumentSpacing = settings.oceanMonuments.distance; + super.oceanMonumentSeparation = settings.oceanMonuments.separation; + super.biomeFeatureDistance = settings.otherStructures.distance; + this.biomeFeatureSeparation = settings.otherStructures.separation; + this.shipwreckDistance = settings.shipwrecks.distance; + this.shipwreckSeparation = settings.shipwrecks.separation; + this.oceanRuinDistance = settings.oceanRuins.distance; + this.oceanRuinSeparation = settings.oceanRuins.separation; + } + + @Override + public int getVillageSeparation() { + return villageSeparation; + } + + @Override + public int getMansionSeparation() { + return mansionSeparation; + } + + @Override + public int getBiomeFeatureSeparation() { + return biomeFeatureSeparation; + } + + @Override + public int getOceanRuinDistance() { + return oceanRuinDistance; + } + + @Override + public int getOceanRuinSeparation() { + return oceanRuinSeparation; + } + + @Override + public int getShipwreckDistance() { + return shipwreckDistance; + } + + @Override + public int getShipwreckSeparation() { + return shipwreckSeparation; + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraTerrainProvider.java b/src/main/java/com/terraforged/mod/chunk/TerraTerrainProvider.java similarity index 89% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraTerrainProvider.java rename to src/main/java/com/terraforged/mod/chunk/TerraTerrainProvider.java index a6365df..9527781 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraTerrainProvider.java +++ b/src/main/java/com/terraforged/mod/chunk/TerraTerrainProvider.java @@ -26,9 +26,9 @@ package com.terraforged.mod.chunk; import com.terraforged.core.cell.Populator; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.heightmap.RegionConfig; -import com.terraforged.core.world.terrain.provider.StandardTerrainProvider; +import com.terraforged.world.GeneratorContext; +import com.terraforged.world.heightmap.RegionConfig; +import com.terraforged.world.terrain.provider.StandardTerrainProvider; import com.terraforged.mod.util.setup.SetupHooks; public class TerraTerrainProvider extends StandardTerrainProvider { diff --git a/src/main/java/com/terraforged/mod/chunk/component/BiomeGenerator.java b/src/main/java/com/terraforged/mod/chunk/component/BiomeGenerator.java new file mode 100644 index 0000000..6ba46d4 --- /dev/null +++ b/src/main/java/com/terraforged/mod/chunk/component/BiomeGenerator.java @@ -0,0 +1,39 @@ +package com.terraforged.mod.chunk.component; + +import com.terraforged.core.region.chunk.ChunkReader; +import com.terraforged.world.terrain.decorator.Decorator; +import com.terraforged.mod.chunk.TerraChunkGenerator; +import com.terraforged.mod.chunk.util.TerraContainer; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraft.world.chunk.IChunk; + +public class BiomeGenerator { + + private final TerraChunkGenerator generator; + + public BiomeGenerator(TerraChunkGenerator generator) { + this.generator = generator; + } + + public void generateBiomes(IChunk chunk) { + ChunkPos pos = chunk.getPos(); + ChunkReader reader = generator.getChunkReader(pos.x, pos.z); + TerraContainer container = generator.getBiomeProvider().createBiomeContainer(reader); + ((ChunkPrimer) chunk).func_225548_a_(container); + // apply chunk-local heightmap modifications + preProcess(pos, reader, container); + } + + private void preProcess(ChunkPos pos, ChunkReader chunk, TerraContainer container) { + chunk.iterate((cell, dx, dz) -> { + Biome biome = container.getBiome(dx, dz); + for (Decorator decorator : generator.getBiomeProvider().getDecorators(biome)) { + if (decorator.apply(cell, pos.getXStart() + dx, pos.getZStart() + dz)) { + return; + } + } + }); + } +} diff --git a/src/main/java/com/terraforged/mod/chunk/component/MobGenerator.java b/src/main/java/com/terraforged/mod/chunk/component/MobGenerator.java new file mode 100644 index 0000000..7807102 --- /dev/null +++ b/src/main/java/com/terraforged/mod/chunk/component/MobGenerator.java @@ -0,0 +1,69 @@ +package com.terraforged.mod.chunk.component; + +import com.terraforged.mod.chunk.TerraChunkGenerator; +import com.terraforged.mod.chunk.fix.SpawnFix; +import net.minecraft.entity.EntityClassification; +import net.minecraft.util.SharedSeedRandom; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.WorldGenRegion; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.spawner.CatSpawner; +import net.minecraft.world.spawner.PatrolSpawner; +import net.minecraft.world.spawner.PhantomSpawner; +import net.minecraft.world.spawner.WorldEntitySpawner; + +import java.util.List; + +public class MobGenerator { + + private final CatSpawner catSpawner = new CatSpawner(); + private final PatrolSpawner patrolSpawner = new PatrolSpawner(); + private final PhantomSpawner phantomSpawner = new PhantomSpawner(); + private final TerraChunkGenerator generator; + + public MobGenerator(TerraChunkGenerator generator) { + this.generator = generator; + } + + public final void generateMobs(WorldGenRegion region) { + // vanilla does NOT check the mobSpawning gamerule before calling this + if (SpawnFix.canSpawnMobs()) { + int chunkX = region.getMainChunkX(); + int chunkZ = region.getMainChunkZ(); + Biome biome = region.getChunk(chunkX, chunkZ).getBiomes().getNoiseBiome(0, 0, 0); + SharedSeedRandom sharedseedrandom = new SharedSeedRandom(); + sharedseedrandom.setDecorationSeed(region.getSeed(), chunkX << 4, chunkZ << 4); + WorldEntitySpawner.performWorldGenSpawning(region, biome, chunkX, chunkZ, sharedseedrandom); + } + } + + public final void spawnMobs(ServerWorld world, boolean hostile, boolean peaceful) { + phantomSpawner.tick(world, hostile, peaceful); + patrolSpawner.tick(world, hostile, peaceful); + catSpawner.tick(world, hostile, peaceful); + } + + public final List getPossibleCreatures(IWorld world, EntityClassification type, BlockPos pos) { + if (Feature.SWAMP_HUT.func_202383_b(world, pos)) { + if (type == EntityClassification.MONSTER) { + return Feature.SWAMP_HUT.getSpawnList(); + } + + if (type == EntityClassification.CREATURE) { + return Feature.SWAMP_HUT.getCreatureSpawnList(); + } + } else if (type == EntityClassification.MONSTER) { + if (Feature.PILLAGER_OUTPOST.isPositionInStructure(world, pos)) { + return Feature.PILLAGER_OUTPOST.getSpawnList(); + } + + if (Feature.OCEAN_MONUMENT.isPositionInStructure(world, pos)) { + return Feature.OCEAN_MONUMENT.getSpawnList(); + } + } + return world.getBiome(pos).getSpawns(type); + } +} diff --git a/src/main/java/com/terraforged/mod/chunk/component/StructureGenerator.java b/src/main/java/com/terraforged/mod/chunk/component/StructureGenerator.java new file mode 100644 index 0000000..948f27b --- /dev/null +++ b/src/main/java/com/terraforged/mod/chunk/component/StructureGenerator.java @@ -0,0 +1,85 @@ +package com.terraforged.mod.chunk.component; + +import com.terraforged.mod.chunk.TerraChunkGenerator; +import net.minecraft.network.DebugPacketSender; +import net.minecraft.util.SharedSeedRandom; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.math.MutableBoundingBox; +import net.minecraft.world.IWorld; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.BiomeManager; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunk; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.structure.Structure; +import net.minecraft.world.gen.feature.structure.StructureStart; +import net.minecraft.world.gen.feature.template.TemplateManager; + +import java.util.Map; + +public class StructureGenerator { + + private final TerraChunkGenerator generator; + + public StructureGenerator(TerraChunkGenerator generator) { + this.generator = generator; + } + + public void generateStructureStarts(BiomeManager biomes, IChunk chunk, ChunkGenerator generator, TemplateManager templates) { + ChunkPos chunkpos = chunk.getPos(); + BlockPos biomePos = new BlockPos(chunkpos.getXStart() + 9, 0, chunkpos.getZStart() + 9); + + for (Structure structure : Feature.STRUCTURES.values()) { + if (generator.getBiomeProvider().hasStructure(structure)) { + StructureStart existingStart = chunk.getStructureStart(structure.getStructureName()); + int refCount = existingStart != null ? existingStart.func_227457_j_() : 0; + + SharedSeedRandom random = new SharedSeedRandom(); + StructureStart start = StructureStart.DUMMY; + + Biome biome = biomes.getBiome(biomePos); + if (structure.func_225558_a_(biomes, generator, random, chunkpos.x, chunkpos.z, biome)) { + StructureStart altStart = structure.getStartFactory().create(structure, chunkpos.x, chunkpos.z, MutableBoundingBox.getNewBoundingBox(), refCount, generator.getSeed()); + altStart.init(generator, templates, chunkpos.x, chunkpos.z, biome); + start = altStart.isValid() ? altStart : StructureStart.DUMMY; + } + + chunk.putStructureStart(structure.getStructureName(), start); + } + } + } + + public void generateStructureReferences(IWorld world, IChunk chunk) { + try { + int radius = 8; + + int chunkX = chunk.getPos().x; + int chunkZ = chunk.getPos().z; + + int minX = chunkX << 4; + int minZ = chunkZ << 4; + int maxX = minX + 15; + int maxZ = minZ + 15; + + for (int dx = -radius; dx <= radius; ++dx) { + for (int dz = -radius; dz <= radius; ++dz) { + int cx = chunkX + dx; + int cz = chunkZ + dz; + long chunkSeed = ChunkPos.asLong(cx, cz); + IChunk c = world.getChunk(cx, cz); + for (Map.Entry entry : c.getStructureStarts().entrySet()) { + StructureStart start = entry.getValue(); + if (start != StructureStart.DUMMY && start.getBoundingBox().intersectsWith(minX, minZ, maxX, maxZ)) { + chunk.addStructureReference(entry.getKey(), chunkSeed); + DebugPacketSender.sendStructureStart(world, start); + } + } + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } +} diff --git a/src/main/java/com/terraforged/mod/chunk/component/TerrainCarver.java b/src/main/java/com/terraforged/mod/chunk/component/TerrainCarver.java new file mode 100644 index 0000000..cfbc9cd --- /dev/null +++ b/src/main/java/com/terraforged/mod/chunk/component/TerrainCarver.java @@ -0,0 +1,57 @@ +package com.terraforged.mod.chunk.component; + +import com.terraforged.mod.chunk.TerraChunkGenerator; +import com.terraforged.mod.chunk.fix.ChunkCarverFix; +import net.minecraft.util.SharedSeedRandom; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.BiomeManager; +import net.minecraft.world.chunk.IChunk; +import net.minecraft.world.gen.GenerationStage; +import net.minecraft.world.gen.carver.ConfiguredCarver; + +import java.util.BitSet; +import java.util.List; +import java.util.ListIterator; + +public class TerrainCarver { + + private final TerraChunkGenerator generator; + + public TerrainCarver(TerraChunkGenerator generator) { + this.generator = generator; + } + + public void carveTerrain(BiomeManager biomes, IChunk chunk, GenerationStage.Carving type) { + // World carvers have hardcoded 'carvable' blocks which can be problematic with modded blocks + // AirCarverFix shims the actual blockstates to an equivalent carvable type + chunk = new ChunkCarverFix(chunk, generator.getContext().materials); + + SharedSeedRandom random = new SharedSeedRandom(); + + ChunkPos chunkpos = chunk.getPos(); + int chunkX = chunkpos.x; + int chunkZ = chunkpos.z; + + BitSet mask = chunk.getCarvingMask(type); + Biome biome = generator.getBiome(biomes, chunkpos.asBlockPos()); + + List> carvers = biome.getCarvers(type); + ListIterator> iterator = carvers.listIterator(); + + for(int cx = chunkX - 8; cx <= chunkX + 8; ++cx) { + for(int cz = chunkZ - 8; cz <= chunkZ + 8; ++cz) { + + while(iterator.hasNext()) { + int index = iterator.nextIndex(); + ConfiguredCarver carver = iterator.next(); + random.setLargeFeatureSeed(generator.getSeed() + index, cx, cz); + if (carver.shouldCarve(random, cx, cz)) { + carver.func_227207_a_(chunk, pos -> generator.getBiome(biomes, pos), random, generator.getSeaLevel(), cx, cz, chunkX, chunkZ, mask); + } + } + } + } + + } +} diff --git a/src/main/java/com/terraforged/mod/chunk/component/TerrainGenerator.java b/src/main/java/com/terraforged/mod/chunk/component/TerrainGenerator.java new file mode 100644 index 0000000..0bbd3d6 --- /dev/null +++ b/src/main/java/com/terraforged/mod/chunk/component/TerrainGenerator.java @@ -0,0 +1,143 @@ +package com.terraforged.mod.chunk.component; + +import com.terraforged.api.chunk.column.ColumnDecorator; +import com.terraforged.api.chunk.column.DecoratorContext; +import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer; +import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.core.region.chunk.ChunkReader; +import com.terraforged.mod.chunk.util.FastChunk; +import com.terraforged.mod.chunk.TerraChunkGenerator; +import com.terraforged.mod.chunk.util.TerraContainer; +import com.terraforged.mod.chunk.fix.RegionFix; +import com.terraforged.mod.decorator.ChunkPopulator; +import com.terraforged.mod.feature.TerrainHelper; +import com.terraforged.mod.util.Environment; +import net.minecraft.util.SharedSeedRandom; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraft.world.chunk.IChunk; +import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.gen.INoiseGenerator; +import net.minecraft.world.gen.PerlinNoiseGenerator; +import net.minecraft.world.gen.WorldGenRegion; + +import java.util.List; + +public class TerrainGenerator { + + private final TerraChunkGenerator generator; + private final TerrainHelper terrainHelper; + private final INoiseGenerator surfaceNoise; + + public TerrainGenerator(TerraChunkGenerator generator) { + this.generator = generator; + this.terrainHelper = new TerrainHelper(0.75F); + this.surfaceNoise = new PerlinNoiseGenerator(new SharedSeedRandom(generator.getSeed()), 3, 0); + } + + public final void generateTerrain(IWorld world, IChunk chunk) { + TerraContainer container = getBiomeContainer(chunk); + DecoratorContext context = new DecoratorContext(FastChunk.wrap(chunk), generator.getContext().levels, generator.getContext().terrain, generator.getContext().factory.getClimate()); + container.getChunkReader().iterate(context, (cell, dx, dz, ctx) -> { + int px = ctx.blockX + dx; + int pz = ctx.blockZ + dz; + int py = ctx.levels.scale(cell.value); + ctx.cell = cell; + ctx.biome = container.getBiome(dx, dz); + ChunkPopulator.INSTANCE.decorate(ctx.chunk, ctx, px, py, pz); + }); + terrainHelper.flatten(world, chunk); + } + + public final void generateSurface(WorldGenRegion world, IChunk chunk) { + TerraContainer container = getBiomeContainer(chunk); + ChunkSurfaceBuffer buffer = new ChunkSurfaceBuffer(FastChunk.wrap(chunk)); + SurfaceContext context = generator.getContext().surface(buffer, generator.getSettings()); + + container.getChunkReader().iterate(context, (cell, dx, dz, ctx) -> { + int px = ctx.blockX + dx; + int pz = ctx.blockZ + dz; + int top = ctx.chunk.getTopBlockY(Heightmap.Type.WORLD_SURFACE_WG, dx, dz) + 1; + + ctx.buffer.setSurfaceLevel(top); + + ctx.cell = cell; + ctx.biome = container.getBiome(dx, dz); + ctx.noise = getSurfaceNoise(px, pz) * 15D; + + generator.getSurfaceManager().getSurface(ctx).buildSurface(px, pz, top, ctx); + + int py = ctx.levels.scale(cell.value); + for (ColumnDecorator processor : generator.getBaseDecorators()) { + processor.decorate(ctx.buffer, ctx, px, py, pz); + } + }); + + FastChunk.updateWGHeightmaps(chunk, context.pos); + } + + public final void generateFeatures(WorldGenRegion region) { + int chunkX = region.getMainChunkX(); + int chunkZ = region.getMainChunkZ(); + IChunk chunk = region.getChunk(chunkX, chunkZ); + TerraContainer container = getBiomeContainer(chunk); + Biome biome = container.getFeatureBiome(); + DecoratorContext context = generator.getContext().decorator(chunk); + + IWorld regionFix = new RegionFix(region, generator); + BlockPos pos = new BlockPos(context.blockX, 0, context.blockZ); + + // place biome features + generator.getFeatureManager().decorate(generator, regionFix, chunk, biome, pos); + + // run post processes on chunk + postProcess(container.getChunkReader(), container, context); + + // bake biome array & discard gen data + ((ChunkPrimer) chunk).func_225548_a_(container.bakeBiomes(Environment.isVanillaBiomes())); + + // marks the heightmap data for this chunk for removal + container.getChunkReader().dispose(); + } + + private void postProcess(ChunkReader chunk, TerraContainer container, DecoratorContext context) { + List decorators = generator.getPostProcessors(); + chunk.iterate(context, (cell, dx, dz, ctx) -> { + int px = ctx.blockX + dx; + int pz = ctx.blockZ + dz; + int py = ctx.chunk.getTopBlockY(Heightmap.Type.WORLD_SURFACE_WG, dx, dz); + ctx.cell = cell; + ctx.biome = container.getBiome(dx, dz); + for (ColumnDecorator decorator : decorators) { + decorator.decorate(ctx.chunk, ctx, px, py, pz); + } + }); + } + + private double getSurfaceNoise(int x, int z) { + double scale = 0.0625D; + double noiseX = x * scale; + double noiseZ = z * scale; + double unusedValue1 = scale; + double unusedValue2 = (x & 15) * scale; + return surfaceNoise.noiseAt(noiseX, noiseZ, unusedValue1, unusedValue2); + } + + private TerraContainer getBiomeContainer(IChunk chunk) { + if (chunk.getBiomes() instanceof TerraContainer) { + return (TerraContainer) chunk.getBiomes(); + } + + ChunkReader view = generator.getChunkReader(chunk.getPos().x, chunk.getPos().z); + TerraContainer container = generator.getBiomeProvider().createBiomeContainer(view); + if (chunk instanceof ChunkPrimer) { + ((ChunkPrimer) chunk).func_225548_a_(container); + } else if (chunk instanceof FastChunk) { + ((FastChunk) chunk).setBiomes(container); + } + + return container; + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/fix/ChunkCarverFix.java b/src/main/java/com/terraforged/mod/chunk/fix/ChunkCarverFix.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/fix/ChunkCarverFix.java rename to src/main/java/com/terraforged/mod/chunk/fix/ChunkCarverFix.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/fix/RegionDelegate.java b/src/main/java/com/terraforged/mod/chunk/fix/RegionDelegate.java similarity index 93% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/fix/RegionDelegate.java rename to src/main/java/com/terraforged/mod/chunk/fix/RegionDelegate.java index 446ef98..77351f2 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/fix/RegionDelegate.java +++ b/src/main/java/com/terraforged/mod/chunk/fix/RegionDelegate.java @@ -129,8 +129,8 @@ public class RegionDelegate extends WorldGenRegion { } @Override - public boolean func_225521_a_(BlockPos p_225521_1_, boolean p_225521_2_, @Nullable Entity p_225521_3_) { - return region.func_225521_a_(p_225521_1_, p_225521_2_, p_225521_3_); + public boolean func_225521_a_(BlockPos pos, boolean drop, @Nullable Entity entity) { + return region.func_225521_a_(pos, drop, entity); } @Override @@ -545,38 +545,38 @@ public class RegionDelegate extends WorldGenRegion { } @Override - public boolean func_226668_i_(Entity p_226668_1_) { - return region.func_226668_i_(p_226668_1_); + public boolean func_226669_j_(Entity entity) { + return region.func_226669_j_(entity); } @Override - public boolean func_226664_a_(AxisAlignedBB p_226664_1_) { - return region.func_226664_a_(p_226664_1_); + public boolean func_226664_a_(AxisAlignedBB bounds) { + return region.func_226664_a_(bounds); } @Override - public boolean func_226669_j_(Entity p_226669_1_) { - return region.func_226669_j_(p_226669_1_); + public boolean func_226668_i_(Entity entity) { + return region.func_226668_i_(entity); } @Override - public boolean func_226665_a__(Entity p_226665_1_, AxisAlignedBB p_226665_2_) { - return region.func_226665_a__(p_226665_1_, p_226665_2_); + public boolean func_226665_a__(Entity entity, AxisAlignedBB bounds) { + return region.func_226665_a__(entity, bounds); } @Override - public boolean func_226662_a_(@Nullable Entity p_226662_1_, AxisAlignedBB p_226662_2_, Set p_226662_3_) { - return region.func_226662_a_(p_226662_1_, p_226662_2_, p_226662_3_); + public boolean func_226662_a_(@Nullable Entity entity, AxisAlignedBB bounds, Set set) { + return region.func_226662_a_(entity, bounds, set); } @Override - public Stream func_226667_c_(@Nullable Entity p_226667_1_, AxisAlignedBB p_226667_2_, Set p_226667_3_) { - return region.func_226667_c_(p_226667_1_, p_226667_2_, p_226667_3_); + public Stream func_226667_c_(@Nullable Entity entity, AxisAlignedBB bounds, Set entities) { + return region.func_226667_c_(entity, bounds, entities); } @Override - public Stream func_226666_b_(@Nullable Entity p_226666_1_, AxisAlignedBB p_226666_2_) { - return region.func_226666_b_(p_226666_1_, p_226666_2_); + public Stream func_226666_b_(@Nullable Entity entity, AxisAlignedBB bounds) { + return region.func_226666_b_(entity, bounds); } @Override diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/fix/RegionFix.java b/src/main/java/com/terraforged/mod/chunk/fix/RegionFix.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/fix/RegionFix.java rename to src/main/java/com/terraforged/mod/chunk/fix/RegionFix.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/fix/SpawnFix.java b/src/main/java/com/terraforged/mod/chunk/fix/SpawnFix.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/fix/SpawnFix.java rename to src/main/java/com/terraforged/mod/chunk/fix/SpawnFix.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/Test.java b/src/main/java/com/terraforged/mod/chunk/test/Test.java similarity index 87% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/Test.java rename to src/main/java/com/terraforged/mod/chunk/test/Test.java index a6e716b..b79bbdf 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/Test.java +++ b/src/main/java/com/terraforged/mod/chunk/test/Test.java @@ -25,20 +25,20 @@ package com.terraforged.mod.chunk.test; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.world.terrain.Terrain; +import com.terraforged.world.terrain.Terrains; +import com.terraforged.mod.biome.ModBiomes; import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.Biomes; public class Test { public static boolean fixedBiome = true; public static Terrain getTerrainType(Terrains terrains) { - return terrains.mountains; + return terrains.steppe; } public static Biome getBiome() { - return Biomes.PLAINS; + return ModBiomes.STEPPE; } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestBiomeProvider.java b/src/main/java/com/terraforged/mod/chunk/test/TestBiomeProvider.java similarity index 93% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestBiomeProvider.java rename to src/main/java/com/terraforged/mod/chunk/test/TestBiomeProvider.java index 728d0e9..dc8c0d7 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestBiomeProvider.java +++ b/src/main/java/com/terraforged/mod/chunk/test/TestBiomeProvider.java @@ -26,7 +26,6 @@ package com.terraforged.mod.chunk.test; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; import com.terraforged.mod.biome.provider.BiomeProvider; import com.terraforged.mod.chunk.TerraContext; import net.minecraft.world.biome.Biome; @@ -38,7 +37,7 @@ public class TestBiomeProvider extends BiomeProvider { } @Override - public Biome getBiome(Cell cell, int x, int z) { + public Biome getBiome(Cell cell, int x, int z) { return Test.getBiome(); } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestChunkGenerator.java b/src/main/java/com/terraforged/mod/chunk/test/TestChunkGenerator.java similarity index 71% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestChunkGenerator.java rename to src/main/java/com/terraforged/mod/chunk/test/TestChunkGenerator.java index f823aa6..73e140f 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestChunkGenerator.java +++ b/src/main/java/com/terraforged/mod/chunk/test/TestChunkGenerator.java @@ -27,13 +27,8 @@ package com.terraforged.mod.chunk.test; import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Populator; -import com.terraforged.core.region.gen.RegionCache; -import com.terraforged.core.region.gen.RegionGenerator; -import com.terraforged.core.util.concurrent.ThreadPool; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.WorldGeneratorFactory; -import com.terraforged.core.world.heightmap.WorldHeightmap; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.world.GeneratorContext; +import com.terraforged.world.heightmap.WorldHeightmap; import com.terraforged.mod.biome.provider.BiomeProvider; import com.terraforged.mod.chunk.TerraChunkGenerator; import com.terraforged.mod.chunk.TerraContext; @@ -44,20 +39,10 @@ public class TestChunkGenerator extends TerraChunkGenerator { private final BiomeProvider biomeProvider; public TestChunkGenerator(TerraContext context, BiomeProvider biomeProvider, GenerationSettings settings) { - super(context, biomeProvider, settings); + super(new TestTerraContext(context), biomeProvider, settings); this.biomeProvider = new TestBiomeProvider(context); } - @Override - protected RegionCache createRegionCache(TerraContext context) { - return RegionGenerator.builder() - .factory(new WorldGeneratorFactory(context, new TestHeightMap(context))) - .pool(ThreadPool.getPool()) - .size(3, 2) - .build() - .toCache(false); - } - @Override public BiomeProvider getBiomeProvider() { return biomeProvider; @@ -73,13 +58,13 @@ public class TestChunkGenerator extends TerraChunkGenerator { } @Override - public void apply(Cell cell, float x, float y) { + public void apply(Cell cell, float x, float y) { super.apply(cell, x, y); populator.apply(cell, x, y); } @Override - public void tag(Cell cell, float x, float y) { + public void tag(Cell cell, float x, float y) { populator.tag(cell, x, y); } } diff --git a/src/main/java/com/terraforged/mod/chunk/test/TestHeightMap.java b/src/main/java/com/terraforged/mod/chunk/test/TestHeightMap.java new file mode 100644 index 0000000..c4e14bd --- /dev/null +++ b/src/main/java/com/terraforged/mod/chunk/test/TestHeightMap.java @@ -0,0 +1,27 @@ +package com.terraforged.mod.chunk.test; + +import com.terraforged.core.cell.Cell; +import com.terraforged.world.GeneratorContext; +import com.terraforged.world.heightmap.WorldHeightmap; +import com.terraforged.world.terrain.Terrains; + +public class TestHeightMap extends WorldHeightmap { + + private final Terrains terrains; + + public TestHeightMap(GeneratorContext context) { + super(context); + terrains = context.terrain; + } + + @Override + public void apply(Cell cell, float x, float y) { + super.apply(cell, x, y); + getPopulator(Test.getTerrainType(terrains)).apply(cell, x, y); + } + + @Override + public void tag(Cell cell, float x, float y) { + getPopulator(Test.getTerrainType(terrains)).tag(cell, x, y); + } +} diff --git a/src/main/java/com/terraforged/mod/chunk/test/TestTerraContext.java b/src/main/java/com/terraforged/mod/chunk/test/TestTerraContext.java new file mode 100644 index 0000000..c8f3088 --- /dev/null +++ b/src/main/java/com/terraforged/mod/chunk/test/TestTerraContext.java @@ -0,0 +1,17 @@ +package com.terraforged.mod.chunk.test; + +import com.terraforged.world.GeneratorContext; +import com.terraforged.world.WorldGeneratorFactory; +import com.terraforged.mod.chunk.TerraContext; + +public class TestTerraContext extends TerraContext { + + public TestTerraContext(TerraContext context) { + super(context); + } + + @Override + protected WorldGeneratorFactory createFactory(GeneratorContext context) { + return new WorldGeneratorFactory(context, new TestHeightMap(context)); + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/FastChunk.java b/src/main/java/com/terraforged/mod/chunk/util/FastChunk.java similarity index 99% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/FastChunk.java rename to src/main/java/com/terraforged/mod/chunk/util/FastChunk.java index c166475..73ace63 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/FastChunk.java +++ b/src/main/java/com/terraforged/mod/chunk/util/FastChunk.java @@ -1,4 +1,4 @@ -package com.terraforged.mod.chunk; +package com.terraforged.mod.chunk.util; import com.terraforged.api.chunk.ChunkDelegate; import net.minecraft.block.BlockState; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java b/src/main/java/com/terraforged/mod/chunk/util/TerraContainer.java similarity index 96% rename from TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java rename to src/main/java/com/terraforged/mod/chunk/util/TerraContainer.java index b9f0651..24eba45 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java +++ b/src/main/java/com/terraforged/mod/chunk/util/TerraContainer.java @@ -23,13 +23,12 @@ * SOFTWARE. */ -package com.terraforged.mod.chunk; +package com.terraforged.mod.chunk.util; import com.terraforged.api.biome.BiomeVariant; import com.terraforged.core.cell.Cell; import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.util.PosIterator; -import com.terraforged.core.world.terrain.Terrain; import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeContainer; @@ -67,7 +66,7 @@ public class TerraContainer extends BiomeContainer { public Biome getFeatureBiome() { PosIterator iterator = PosIterator.area(0, 0, 16, 16); while (iterator.next()) { - Cell cell = chunkReader.getCell(iterator.x(), iterator.z()); + Cell cell = chunkReader.getCell(iterator.x(), iterator.z()); if (cell.biomeType.isExtreme()) { return getBiome(iterator.x(), iterator.z()); } diff --git a/src/main/java/com/terraforged/mod/chunk/util/TerraHooks.java b/src/main/java/com/terraforged/mod/chunk/util/TerraHooks.java new file mode 100644 index 0000000..5cfce69 --- /dev/null +++ b/src/main/java/com/terraforged/mod/chunk/util/TerraHooks.java @@ -0,0 +1,122 @@ +package com.terraforged.mod.chunk.util; + +import com.terraforged.api.chunk.column.ColumnDecorator; +import com.terraforged.api.chunk.surface.SurfaceManager; +import com.terraforged.mod.feature.manager.FeatureManager; +import com.terraforged.mod.feature.manager.data.DataManager; +import com.terraforged.mod.feature.manager.matcher.biome.BiomeMatcher; +import com.terraforged.mod.feature.manager.matcher.feature.FeatureMatcher; +import com.terraforged.mod.feature.manager.modifier.FeatureModifiers; +import com.terraforged.mod.feature.manager.predicate.DeepWater; +import com.terraforged.mod.feature.manager.predicate.FeaturePredicate; +import com.terraforged.mod.feature.manager.predicate.MinDepth; +import com.terraforged.mod.feature.manager.predicate.MinHeight; +import com.terraforged.mod.Log; +import com.terraforged.mod.biome.ModBiomes; +import com.terraforged.mod.biome.surface.IcebergsSurface; +import com.terraforged.mod.biome.surface.SteppeSurface; +import com.terraforged.mod.biome.surface.SwampSurface; +import com.terraforged.mod.chunk.TerraContext; +import com.terraforged.mod.decorator.terrain.BedrockDecorator; +import com.terraforged.mod.decorator.terrain.CoastDecorator; +import com.terraforged.mod.decorator.terrain.ErosionDecorator; +import com.terraforged.mod.decorator.terrain.GeologyDecorator; +import com.terraforged.mod.decorator.feature.LayerDecorator; +import com.terraforged.mod.decorator.feature.SnowEroder; +import com.terraforged.mod.feature.Matchers; +import com.terraforged.mod.feature.BlockDataManager; +import com.terraforged.mod.material.geology.GeoManager; +import com.terraforged.mod.util.setup.SetupHooks; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.Biomes; +import net.minecraft.world.gen.feature.Feature; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class TerraHooks { + + public static DataManager createDataManager() { + return FeatureManager.data(new File("config/terraforged/datapacks")); + } + + public static List createBaseDecorators(GeoManager geoManager, TerraContext context) { + List processors = new ArrayList<>(); + if (context.terraSettings.features.strataDecorator) { + Log.info(" - Geology decorator enabled"); + processors.add(new GeologyDecorator(geoManager)); + } + if (context.terraSettings.features.erosionDecorator) { + Log.info(" - Erosion decorator enabled"); + processors.add(new ErosionDecorator(context)); + } + processors.add(new CoastDecorator(context)); + processors.add(new BedrockDecorator(context)); + return processors; + } + + public static List createFeatureDecorators(TerraContext context) { + List processors = new ArrayList<>(); + if (context.terraSettings.features.naturalSnowDecorator) { + Log.info(" - Natural snow decorator enabled"); + processors.add(new SnowEroder(context)); + } + if (context.terraSettings.features.smoothLayerDecorator) { + Log.info(" - Smooth layer decorator enabled"); + processors.add(new LayerDecorator(context.materials.getLayerManager())); + } + return processors; + } + + public static BlockDataManager createBlockDataManager(DataManager data, TerraContext context) { + return new BlockDataManager(data); + } + + public static FeatureManager createFeatureManager(DataManager data, TerraContext context) { + FeatureModifiers modifiers = FeatureManager.modifiers(data, context.terraSettings.features.customBiomeFeatures); + + if (context.terraSettings.features.strataDecorator) { + // block stone blobs if strata enabled + modifiers.getPredicates().add(Matchers.stoneBlobs(), FeaturePredicate.DENY); + } + + if (!context.terraSettings.features.vanillaWaterFeatures) { + // block lakes and springs if not enabled + modifiers.getPredicates().add(FeatureMatcher.of(Feature.LAKE), FeaturePredicate.DENY); + modifiers.getPredicates().add(FeatureMatcher.of(Feature.SPRING_FEATURE), FeaturePredicate.DENY); + } + + if (context.terraSettings.features.customBiomeFeatures) { + // remove default trees from river biomes since forests can go up to the edge of rivers + modifiers.getPredicates().add(BiomeMatcher.of(Biome.Category.RIVER), Matchers.tree(), FeaturePredicate.DENY); + } + + // block ugly features + modifiers.getPredicates().add(Matchers.sedimentDisks(), FeaturePredicate.DENY); + + // limit to deep oceans + modifiers.getPredicates().add(FeatureMatcher.of(Feature.SHIPWRECK), MinDepth.DEPTH55); + modifiers.getPredicates().add(FeatureMatcher.of(Feature.OCEAN_RUIN), DeepWater.INSTANCE); + modifiers.getPredicates().add(FeatureMatcher.of(Feature.OCEAN_MONUMENT), DeepWater.INSTANCE); + + // prevent mineshafts above ground + modifiers.getPredicates().add(FeatureMatcher.of(Feature.MINESHAFT), MinHeight.HEIGHT80); + + return FeatureManager.create(context.world, SetupHooks.setup(modifiers, context.copy())); + } + + public static SurfaceManager createSurfaceManager(TerraContext context) { + SurfaceManager manager = new SurfaceManager(); + manager.replace(Biomes.FROZEN_OCEAN.delegate.get(), new IcebergsSurface(context, 20, 15)); + manager.replace(Biomes.DEEP_FROZEN_OCEAN.delegate.get(), new IcebergsSurface(context, 30, 30)); + manager.replace(Biomes.SWAMP.delegate.get(), new SwampSurface()); + manager.replace(ModBiomes.MARSHLAND, new SwampSurface()); + manager.replace(ModBiomes.STEPPE, new SteppeSurface()); + return SetupHooks.setup(manager, context); + } + + public static GeoManager createGeologyManager(TerraContext context) { + return new GeoManager(context); + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/command/TerraCommand.java b/src/main/java/com/terraforged/mod/command/TerraCommand.java similarity index 79% rename from TerraForgedMod/src/main/java/com/terraforged/mod/command/TerraCommand.java rename to src/main/java/com/terraforged/mod/command/TerraCommand.java index 00b8a27..c14f1b9 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/command/TerraCommand.java +++ b/src/main/java/com/terraforged/mod/command/TerraCommand.java @@ -27,13 +27,14 @@ package com.terraforged.mod.command; import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.WorldGenerator; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.world.WorldGenerator; +import com.terraforged.world.terrain.Terrain; +import com.terraforged.world.terrain.Terrains; import com.terraforged.mod.Log; import com.terraforged.mod.biome.provider.BiomeProvider; import com.terraforged.mod.chunk.TerraChunkGenerator; @@ -48,6 +49,7 @@ import com.terraforged.mod.data.DataGen; import com.terraforged.mod.settings.SettingsHelper; import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; +import net.minecraft.command.arguments.ArgumentSerializer; import net.minecraft.command.arguments.ArgumentTypes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; @@ -68,21 +70,18 @@ import net.minecraft.world.gen.ChunkGenerator; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.server.FMLServerStartingEvent; -import net.minecraftforge.server.permission.DefaultPermissionLevel; -import net.minecraftforge.server.permission.PermissionAPI; import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; -import java.util.function.Predicate; import java.util.function.Supplier; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE) public class TerraCommand { public static void init() { - ArgumentTypes.register("terraforged:biome", BiomeArgType.class, new BiomeArgType.Serializer()); - ArgumentTypes.register("terraforged:terrain", TerrainArgType.class, new TerrainArgType.Serializer()); + ArgumentTypes.register("terraforged:biome", BiomeArgType.class, new ArgumentSerializer<>(BiomeArgType::new)); + ArgumentTypes.register("terraforged:terrain", TerrainArgType.class, new ArgumentSerializer<>(TerrainArgType::new)); } @SubscribeEvent @@ -92,59 +91,31 @@ public class TerraCommand { } public static void register(CommandDispatcher dispatcher) { - registerSimple(dispatcher); - registerLocate(dispatcher); - PermissionAPI.registerNode(Permissions.QUERY, DefaultPermissionLevel.OP, "Allows use of the query command"); - PermissionAPI.registerNode(Permissions.DATA, DefaultPermissionLevel.OP, "Allows use of the data command"); - PermissionAPI.registerNode(Permissions.DEFAULTS, DefaultPermissionLevel.OP, "Allows use of the defaults command"); - PermissionAPI.registerNode(Permissions.DEBUG, DefaultPermissionLevel.OP, "Allows use of the debug command"); - PermissionAPI.registerNode(Permissions.LOCATE, DefaultPermissionLevel.OP, "Allows use of the locate command"); + dispatcher.register(command()); } - private static void registerSimple(CommandDispatcher dispatcher) { - dispatcher.register(Commands.literal("terra") + private static LiteralArgumentBuilder command() { + return Commands.literal("terra") + .requires(source -> source.hasPermissionLevel(2)) .then(Commands.literal("query") - .requires(perm(Permissions.QUERY)) .executes(TerraCommand::query)) .then(Commands.literal("data") - .requires(perm(Permissions.DATA)) .then(Commands.literal("dump") .executes(TerraCommand::dump))) .then(Commands.literal("defaults") - .requires(perm(Permissions.DEFAULTS)) .then(Commands.literal("set") .executes(TerraCommand::setDefaults))) .then(Commands.literal("debug") - .requires(perm(Permissions.DEBUG)) - .executes(TerraCommand::debugBiome))); - } - - private static void registerLocate(CommandDispatcher dispatcher) { - dispatcher.register(Commands.literal("terra") + .executes(TerraCommand::debugBiome)) .then(Commands.literal("locate") - .requires(perm(Permissions.LOCATE)) - .then(Commands.argument("biome", BiomeArgType.biome()) - .executes(TerraCommand::findBiome)))); - - dispatcher.register(Commands.literal("terra") - .then(Commands.literal("locate") - .requires(perm(Permissions.LOCATE)) - .then(Commands.argument("terrain", TerrainArgType.terrain()) - .executes(TerraCommand::findTerrain)))); - - dispatcher.register(Commands.literal("terra") - .then(Commands.literal("locate") - .requires(perm(Permissions.LOCATE)) .then(Commands.argument("biome", BiomeArgType.biome()) + .executes(TerraCommand::findBiome) .then(Commands.argument("terrain", TerrainArgType.terrain()) - .executes(TerraCommand::findTerrainAndBiome))))); - - dispatcher.register(Commands.literal("terra") - .then(Commands.literal("locate") - .requires(perm(Permissions.LOCATE)) + .executes(TerraCommand::findTerrainAndBiome))) .then(Commands.argument("terrain", TerrainArgType.terrain()) + .executes(TerraCommand::findTerrain) .then(Commands.argument("biome", BiomeArgType.biome()) - .executes(TerraCommand::findTerrainAndBiome))))); + .executes(TerraCommand::findTerrainAndBiome)))); } private static int query(CommandContext context) throws CommandSyntaxException { @@ -155,10 +126,10 @@ public class TerraCommand { BlockPos pos = context.getSource().asPlayer().getPosition(); BiomeProvider biomeProvider = getBiomeProvider(context); - Cell cell = biomeProvider.lookupPos(pos.getX(), pos.getZ()); + Cell cell = biomeProvider.lookupPos(pos.getX(), pos.getZ()); Biome biome = biomeProvider.getBiome(cell, pos.getX(), pos.getZ()); context.getSource().sendFeedback( - new StringTextComponent("Terrain=" + cell.tag.getName() + ", Biome=" + biome.getRegistryName()), + new StringTextComponent("Terrain=" + cell.terrainType.getName() + ", Biome=" + biome.getRegistryName()), false ); @@ -223,7 +194,7 @@ public class TerraCommand { WorldGenerator worldGenerator = terraContext.factory.get(); Search search = new TerrainSearchTask(pos, worldGenerator, target); doSearch(server, playerID, search); - context.getSource().sendFeedback(new StringTextComponent("Locating terrain..."), false); + context.getSource().sendFeedback(new StringTextComponent("Searching..."), false); return Command.SINGLE_SUCCESS; } @@ -242,7 +213,7 @@ public class TerraCommand { IWorldReader reader = context.getSource().asPlayer().getServerWorld(); Search search = new BiomeSearchTask(pos, reader, biome); doSearch(server, playerID, search); - context.getSource().sendFeedback(new StringTextComponent("Locating biome..."), false); + context.getSource().sendFeedback(new StringTextComponent("Searching..."), false); return Command.SINGLE_SUCCESS; } @@ -266,7 +237,7 @@ public class TerraCommand { Search terrainSearch = new TerrainSearchTask(pos, worldGenerator, target); Search search = new BothSearchTask(pos, biomeSearch, terrainSearch); doSearch(server, playerID, search); - context.getSource().sendFeedback(new StringTextComponent("Locating biome & terrain..."), false); + context.getSource().sendFeedback(new StringTextComponent("Searching..."), false); return Command.SINGLE_SUCCESS; } @@ -283,8 +254,11 @@ public class TerraCommand { return; } + double distance = Math.sqrt(player.getPosition().distanceSq(pos)); + ITextComponent result = new StringTextComponent("Nearest match: ") - .appendSibling(createTeleportMessage(pos)); + .appendSibling(createTeleportMessage(pos)) + .appendSibling(new StringTextComponent(String.format(" Distance: %.2f", distance))); player.sendMessage(result); })); @@ -304,31 +278,14 @@ public class TerraCommand { // the terrain parsed from the command will not be the same instance as used in the // world generator, so find the matching instance by name private static Terrain getTerrainInstance(Terrain find, Terrains terrains) { - // search for exact match first for (Terrain t : terrains.index) { if (t.getName().equals(find.getName())) { return t; } } - // find a mixed terrain as a fallback - for (Terrain t : terrains.index) { - if (t.getName().contains("-") && t.getName().contains(find.getName())) { - return t; - } - } return find; } - private static Predicate perm(String node) { - return source -> { - try { - return PermissionAPI.hasPermission(source.asPlayer(), node); - } catch (Throwable t) { - return source.hasPermissionLevel(2); - } - }; - } - private static BiomeProvider getBiomeProvider(CommandContext context) { return (BiomeProvider) context.getSource().getWorld().getChunkProvider().getChunkGenerator().getBiomeProvider(); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/command/arg/BiomeArgType.java b/src/main/java/com/terraforged/mod/command/arg/BiomeArgType.java similarity index 66% rename from TerraForgedMod/src/main/java/com/terraforged/mod/command/arg/BiomeArgType.java rename to src/main/java/com/terraforged/mod/command/arg/BiomeArgType.java index 0053536..0dfc4a5 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/command/arg/BiomeArgType.java +++ b/src/main/java/com/terraforged/mod/command/arg/BiomeArgType.java @@ -25,7 +25,6 @@ package com.terraforged.mod.command.arg; -import com.google.gson.JsonObject; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -34,9 +33,8 @@ import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import net.minecraft.command.ISuggestionProvider; -import net.minecraft.command.arguments.IArgumentSerializer; -import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.registry.Registry; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.biome.Biome; import net.minecraftforge.registries.ForgeRegistries; @@ -47,28 +45,9 @@ public class BiomeArgType implements ArgumentType { @Override public Biome parse(StringReader reader) throws CommandSyntaxException { - int cursor = reader.getCursor(); - String raw = reader.getString().substring(cursor); - - if (raw.indexOf(':') == -1) { - reader.setCursor(cursor); - throw createException("Invalid biome", "%s is not a valid biome", raw); - } - - ResourceLocation resourcelocation = ResourceLocation.tryCreate(raw); - if (resourcelocation == null) { - reader.setCursor(cursor); - throw createException("Invalid biome", "%s is not a valid biome", raw); - } - - if (!ForgeRegistries.BIOMES.containsKey(resourcelocation)) { - reader.setCursor(cursor); - throw createException("Invalid biome", "%s is not a valid biome", resourcelocation); - } - - reader.setCursor(reader.getString().length()); - - return ForgeRegistries.BIOMES.getValue(resourcelocation); + ResourceLocation resourcelocation = ResourceLocation.read(reader); + return Registry.BIOME.getValue(resourcelocation) + .orElseThrow(() -> createException("Invalid biome", "%s is not a valid biome", resourcelocation)); } @Override @@ -90,22 +69,4 @@ public class BiomeArgType implements ArgumentType { public static Biome getBiome(CommandContext context, String name) { return context.getArgument(name, Biome.class); } - - public static class Serializer implements IArgumentSerializer { - - @Override - public void write(BiomeArgType type, PacketBuffer buffer) { - - } - - @Override - public BiomeArgType read(PacketBuffer buffer) { - return new BiomeArgType(); - } - - @Override - public void write(BiomeArgType type, JsonObject json) { - - } - } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/command/arg/TerrainArgType.java b/src/main/java/com/terraforged/mod/command/arg/TerrainArgType.java similarity index 78% rename from TerraForgedMod/src/main/java/com/terraforged/mod/command/arg/TerrainArgType.java rename to src/main/java/com/terraforged/mod/command/arg/TerrainArgType.java index dc843a0..9465da4 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/command/arg/TerrainArgType.java +++ b/src/main/java/com/terraforged/mod/command/arg/TerrainArgType.java @@ -25,7 +25,6 @@ package com.terraforged.mod.command.arg; -import com.google.gson.JsonObject; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.context.CommandContext; @@ -33,12 +32,8 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import com.terraforged.core.settings.Settings; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.world.terrain.Terrain; import net.minecraft.command.ISuggestionProvider; -import net.minecraft.command.arguments.IArgumentSerializer; -import net.minecraft.network.PacketBuffer; import net.minecraft.util.text.StringTextComponent; import java.util.List; @@ -47,7 +42,7 @@ import java.util.stream.Collectors; public class TerrainArgType implements ArgumentType { - private final List terrains = createTerrainList(); + private final List terrains = Terrain.getRegistered(); @Override public Terrain parse(StringReader reader) throws CommandSyntaxException { @@ -81,26 +76,4 @@ public class TerrainArgType implements ArgumentType { new StringTextComponent(String.format(message, args)) ); } - - private static List createTerrainList() { - return Terrains.create(new Settings()).index; - } - - public static class Serializer implements IArgumentSerializer { - - @Override - public void write(TerrainArgType type, PacketBuffer buffer) { - - } - - @Override - public TerrainArgType read(PacketBuffer buffer) { - return new TerrainArgType(); - } - - @Override - public void write(TerrainArgType type, JsonObject json) { - - } - } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/command/search/BiomeSearchTask.java b/src/main/java/com/terraforged/mod/command/search/BiomeSearchTask.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/command/search/BiomeSearchTask.java rename to src/main/java/com/terraforged/mod/command/search/BiomeSearchTask.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/command/search/BothSearchTask.java b/src/main/java/com/terraforged/mod/command/search/BothSearchTask.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/command/search/BothSearchTask.java rename to src/main/java/com/terraforged/mod/command/search/BothSearchTask.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/command/search/Search.java b/src/main/java/com/terraforged/mod/command/search/Search.java similarity index 95% rename from TerraForgedMod/src/main/java/com/terraforged/mod/command/search/Search.java rename to src/main/java/com/terraforged/mod/command/search/Search.java index 3bc5f1a..5a61899 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/command/search/Search.java +++ b/src/main/java/com/terraforged/mod/command/search/Search.java @@ -38,14 +38,6 @@ public abstract class Search implements Supplier { return 16; } - protected BlockPos success(BlockPos.Mutable pos) { - return pos.toImmutable(); - } - - protected BlockPos fail(BlockPos pos) { - return pos; - } - @Override public BlockPos get() { int radius = maxRadius; @@ -87,4 +79,12 @@ public abstract class Search implements Supplier { } public abstract boolean test(BlockPos pos); + + public BlockPos success(BlockPos.Mutable pos) { + return pos.toImmutable(); + } + + public BlockPos fail(BlockPos pos) { + return pos; + } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/command/search/TerrainSearchTask.java b/src/main/java/com/terraforged/mod/command/search/TerrainSearchTask.java similarity index 77% rename from TerraForgedMod/src/main/java/com/terraforged/mod/command/search/TerrainSearchTask.java rename to src/main/java/com/terraforged/mod/command/search/TerrainSearchTask.java index a48e45c..0adf8f8 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/command/search/TerrainSearchTask.java +++ b/src/main/java/com/terraforged/mod/command/search/TerrainSearchTask.java @@ -1,15 +1,15 @@ package com.terraforged.mod.command.search; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.WorldGenerator; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.world.WorldGenerator; +import com.terraforged.world.terrain.Terrain; import net.minecraft.util.math.BlockPos; public class TerrainSearchTask extends Search { private final Terrain type; private final WorldGenerator generator; - private final Cell cell = new Cell<>(); + private final Cell cell = new Cell(); public TerrainSearchTask(BlockPos center, WorldGenerator generator, Terrain type) { super(center, 256); @@ -25,6 +25,6 @@ public class TerrainSearchTask extends Search { @Override public boolean test(BlockPos pos) { generator.getHeightmap().apply(cell, pos.getX(), pos.getZ()); - return cell.tag == type; + return cell.terrainType == type; } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/data/DataGen.java b/src/main/java/com/terraforged/mod/data/DataGen.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/data/DataGen.java rename to src/main/java/com/terraforged/mod/data/DataGen.java diff --git a/src/main/java/com/terraforged/mod/data/DataGenerator.java b/src/main/java/com/terraforged/mod/data/DataGenerator.java new file mode 100644 index 0000000..d34c1af --- /dev/null +++ b/src/main/java/com/terraforged/mod/data/DataGenerator.java @@ -0,0 +1,92 @@ +package com.terraforged.mod.data; + +import com.terraforged.core.util.NameUtil; +import com.terraforged.mod.gui.preview.PreviewSettings; +import com.terraforged.mod.settings.TerraSettings; +import com.terraforged.mod.util.nbt.NBTHelper; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.biome.Biome; +import net.minecraftforge.common.data.LanguageProvider; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +import net.minecraftforge.registries.ForgeRegistries; + +import java.util.function.UnaryOperator; + +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) +public class DataGenerator { + + @SubscribeEvent + public static void gather(GatherDataEvent event) { + LanguageProvider langProvider = new LanguageProvider(event.getGenerator(), "terraforged", "en_us") { + @Override + protected void addTranslations() { + worlds(this); + biomes(this); + settings(this); + } + }; + event.getGenerator().addProvider(langProvider); + } + + private static void worlds(LanguageProvider provider) { + provider.add("generator.terraforged", "TerraForged"); + provider.add("generator.terratest", "TerraTest"); + } + + private static void biomes(LanguageProvider provider) { + for (Biome biome : ForgeRegistries.BIOMES) { + ResourceLocation name = biome.getRegistryName(); + if (name != null && name.getNamespace().equals("terraforged")) { + provider.add(biome, NameUtil.toDisplayName(name.getPath())); + } + } + } + + private static void settings(LanguageProvider provider) { + visit(NBTHelper.serialize(new DataGenSettings()), provider); + } + + private static void visit(CompoundNBT tag, LanguageProvider lang) { + tag.keySet().forEach(name -> { + if (name.startsWith("#")) { + return; + } + + INBT value = tag.get(name); + if (value instanceof CompoundNBT) { + visit((CompoundNBT) value, lang); + } + + CompoundNBT meta = tag.getCompound("#" + name); + if (meta.isEmpty()) { + return; + } + + add(meta, "key", "display", NameUtil::toDisplayNameKey, lang); + add(meta, "key", "comment", NameUtil::toTooltipKey, lang); + }); + } + + private static void add(CompoundNBT tag, String keyName, String valName, UnaryOperator keyFunc, LanguageProvider lang) { + String key = keyFunc.apply(tag.getString(keyName)); + if (key.isEmpty()) { + return; + } + + String value = tag.getString(valName); + if (value.isEmpty()) { + return; + } + + lang.add(key, value); + } + + public static class DataGenSettings extends TerraSettings { + + public PreviewSettings preview = new PreviewSettings(); + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBiomes.java b/src/main/java/com/terraforged/mod/data/WorldGenBiomes.java similarity index 98% rename from TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBiomes.java rename to src/main/java/com/terraforged/mod/data/WorldGenBiomes.java index 0f99d3a..eb92713 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBiomes.java +++ b/src/main/java/com/terraforged/mod/data/WorldGenBiomes.java @@ -28,7 +28,7 @@ package com.terraforged.mod.data; import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.terraforged.core.world.biome.BiomeType; +import com.terraforged.world.biome.BiomeType; import com.terraforged.mod.biome.map.BiomeMap; import com.terraforged.mod.biome.provider.BiomeHelper; import net.minecraft.util.ResourceLocation; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBlocks.java b/src/main/java/com/terraforged/mod/data/WorldGenBlocks.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBlocks.java rename to src/main/java/com/terraforged/mod/data/WorldGenBlocks.java diff --git a/src/main/java/com/terraforged/mod/data/WorldGenFeatures.java b/src/main/java/com/terraforged/mod/data/WorldGenFeatures.java new file mode 100644 index 0000000..cbe327b --- /dev/null +++ b/src/main/java/com/terraforged/mod/data/WorldGenFeatures.java @@ -0,0 +1,68 @@ +/* + * + * MIT License + * + * Copyright (c) 2020 TerraForged + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.terraforged.mod.data; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.mojang.datafixers.Dynamic; +import com.mojang.datafixers.types.JsonOps; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.GenerationStage; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraftforge.registries.ForgeRegistries; + +import java.io.File; + +public class WorldGenFeatures extends DataGen { + + public static void genBiomeFeatures(File dataDir) { + if (dataDir.exists() || dataDir.mkdirs()) { + for (Biome biome : ForgeRegistries.BIOMES) { + genBiomeFeatures(dataDir, biome); + } + } + } + + private static void genBiomeFeatures(File dir, Biome biome) { + write(new File(dir, getJsonPath("features", biome.getRegistryName())), writer -> { + JsonObject root = new JsonObject(); + for (GenerationStage.Decoration type : GenerationStage.Decoration.values()) { + JsonArray features = new JsonArray(); + for (ConfiguredFeature feature : biome.getFeatures(type)) { + try { + Dynamic dynamic = feature.serialize(JsonOps.INSTANCE); + features.add(dynamic.getValue()); + } catch (NullPointerException e) { + new NullPointerException("Badly written feature: " + feature.feature.getRegistryName()).printStackTrace(); + } + } + root.add(type.getName(), features); + } + write(root, writer); + }); + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/ChunkPopulator.java b/src/main/java/com/terraforged/mod/decorator/ChunkPopulator.java similarity index 95% rename from TerraForgedMod/src/main/java/com/terraforged/mod/decorator/ChunkPopulator.java rename to src/main/java/com/terraforged/mod/decorator/ChunkPopulator.java index 87e826f..f9ca4c4 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/ChunkPopulator.java +++ b/src/main/java/com/terraforged/mod/decorator/ChunkPopulator.java @@ -36,7 +36,7 @@ public class ChunkPopulator implements ColumnDecorator { @Override public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) { - if (context.cell.tag == context.terrains.volcanoPipe && context.cell.riverMask > 0.25F) { + if (context.cell.terrainType == context.terrains.volcanoPipe && context.cell.riverMask > 0.25F) { int lavaStart = Math.max(context.levels.waterY + 10, y - 30); int lavaEnd = Math.max(5, context.levels.waterY - 10); fillDown(context, chunk, x, z, lavaStart, lavaEnd, States.LAVA.get()); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/feature/LayerDecorator.java b/src/main/java/com/terraforged/mod/decorator/feature/LayerDecorator.java similarity index 96% rename from TerraForgedMod/src/main/java/com/terraforged/mod/decorator/feature/LayerDecorator.java rename to src/main/java/com/terraforged/mod/decorator/feature/LayerDecorator.java index 5467be8..cb26630 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/feature/LayerDecorator.java +++ b/src/main/java/com/terraforged/mod/decorator/feature/LayerDecorator.java @@ -30,7 +30,7 @@ import com.terraforged.api.chunk.column.DecoratorContext; import com.terraforged.api.material.layer.LayerManager; import com.terraforged.api.material.layer.LayerMaterial; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.heightmap.Levels; +import com.terraforged.world.heightmap.Levels; import com.terraforged.mod.material.MaterialHelper; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; @@ -72,7 +72,7 @@ public class LayerDecorator implements ColumnDecorator { } } - private void setLayer(IChunk chunk, BlockPos pos, LayerMaterial material, Cell cell, Levels levels, float min) { + private void setLayer(IChunk chunk, BlockPos pos, LayerMaterial material, Cell cell, Levels levels, float min) { float height = cell.value * levels.worldHeight; float depth = material.getDepth(height); if (depth > min) { diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/feature/SnowEroder.java b/src/main/java/com/terraforged/mod/decorator/feature/SnowEroder.java similarity index 96% rename from TerraForgedMod/src/main/java/com/terraforged/mod/decorator/feature/SnowEroder.java rename to src/main/java/com/terraforged/mod/decorator/feature/SnowEroder.java index 829a6d9..465e7a1 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/feature/SnowEroder.java +++ b/src/main/java/com/terraforged/mod/decorator/feature/SnowEroder.java @@ -28,7 +28,7 @@ package com.terraforged.mod.decorator.feature; import com.terraforged.api.chunk.column.ColumnDecorator; import com.terraforged.api.chunk.column.DecoratorContext; import com.terraforged.mod.chunk.TerraContext; -import com.terraforged.mod.decorator.base.ErosionDecorator; +import com.terraforged.mod.decorator.terrain.ErosionDecorator; import me.dags.noise.source.Rand; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -71,7 +71,7 @@ public class SnowEroder extends ErosionDecorator { float var = -ColumnDecorator.getNoise(x, z, seed1, 16, 0); float hNoise = rand.getValue(x, z, seed2) * HEIGHT_MODIFIER; float sNoise = rand.getValue(x, z, seed3) * SLOPE_MODIFIER; - float vModifier = context.cell.tag == context.terrains.volcano ? 0.15F : 0F; + float vModifier = context.cell.terrainType == context.terrains.volcano ? 0.15F : 0F; float height = context.cell.value + var + hNoise + vModifier; float steepness = context.cell.steepness + var + sNoise + vModifier; if (snowErosion(x, z, steepness, height)) { diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/BedrockDecorator.java b/src/main/java/com/terraforged/mod/decorator/terrain/BedrockDecorator.java similarity index 90% rename from TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/BedrockDecorator.java rename to src/main/java/com/terraforged/mod/decorator/terrain/BedrockDecorator.java index 9e52080..297a2ad 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/BedrockDecorator.java +++ b/src/main/java/com/terraforged/mod/decorator/terrain/BedrockDecorator.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package com.terraforged.mod.decorator.base; +package com.terraforged.mod.decorator.terrain; import com.terraforged.api.chunk.column.ColumnDecorator; import com.terraforged.api.chunk.column.DecoratorContext; @@ -44,9 +44,9 @@ public class BedrockDecorator implements ColumnDecorator { private final BlockState material; public BedrockDecorator(TerraContext context) { - minDepth = context.terraSettings.dimensions.baseLayer.minDepth; - variance = context.terraSettings.dimensions.baseLayer.variance; - material = getState(context.terraSettings.dimensions.baseLayer.material); + minDepth = context.terraSettings.dimensions.bedrockLayer.minDepth; + variance = context.terraSettings.dimensions.bedrockLayer.variance; + material = getState(context.terraSettings.dimensions.bedrockLayer.material); } @Override diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/CoastDecorator.java b/src/main/java/com/terraforged/mod/decorator/terrain/CoastDecorator.java similarity index 94% rename from TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/CoastDecorator.java rename to src/main/java/com/terraforged/mod/decorator/terrain/CoastDecorator.java index 686d4b8..b98a9c2 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/CoastDecorator.java +++ b/src/main/java/com/terraforged/mod/decorator/terrain/CoastDecorator.java @@ -23,13 +23,13 @@ * SOFTWARE. */ -package com.terraforged.mod.decorator.base; +package com.terraforged.mod.decorator.terrain; import com.terraforged.api.chunk.column.ColumnDecorator; import com.terraforged.api.chunk.column.DecoratorContext; import com.terraforged.api.material.state.States; import com.terraforged.core.util.VariablePredicate; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.world.terrain.Terrains; import com.terraforged.mod.chunk.TerraContext; import net.minecraft.block.BlockState; import net.minecraft.world.chunk.IChunk; @@ -59,7 +59,7 @@ public class CoastDecorator implements ColumnDecorator { @Override public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) { - if (context.cell.tag != terrains.beach) { + if (context.cell.terrainType != terrains.beach) { return; } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/ErosionDecorator.java b/src/main/java/com/terraforged/mod/decorator/terrain/ErosionDecorator.java similarity index 95% rename from TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/ErosionDecorator.java rename to src/main/java/com/terraforged/mod/decorator/terrain/ErosionDecorator.java index e72cd23..4b03d21 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/ErosionDecorator.java +++ b/src/main/java/com/terraforged/mod/decorator/terrain/ErosionDecorator.java @@ -23,12 +23,12 @@ * SOFTWARE. */ -package com.terraforged.mod.decorator.base; +package com.terraforged.mod.decorator.terrain; import com.terraforged.api.chunk.column.ColumnDecorator; import com.terraforged.api.chunk.column.DecoratorContext; import com.terraforged.api.material.state.States; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.world.terrain.Terrains; import com.terraforged.mod.chunk.TerraContext; import com.terraforged.mod.material.Materials; import net.minecraft.block.BlockState; @@ -69,17 +69,17 @@ public class ErosionDecorator implements ColumnDecorator { this.seed1 = context.seed.next(); this.seed2 = context.seed.next(); this.seed3 = context.seed.next(); - this.minY = context.levels.ground(4); + this.minY = context.levels.water; this.materials = context.materials; } @Override public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) { - if (context.cell.value < minY || context.cell.tag == terrain.river || context.cell.tag == terrain.riverBanks) { + if (context.cell.value < minY || context.cell.terrainType == terrain.river || context.cell.terrainType == terrain.riverBanks) { return; } - if (context.cell.tag == terrain.volcanoPipe) { + if (context.cell.terrainType == terrain.volcanoPipe) { return; } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/GeologyDecorator.java b/src/main/java/com/terraforged/mod/decorator/terrain/GeologyDecorator.java similarity index 97% rename from TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/GeologyDecorator.java rename to src/main/java/com/terraforged/mod/decorator/terrain/GeologyDecorator.java index 2d5a2f1..80f381a 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/decorator/base/GeologyDecorator.java +++ b/src/main/java/com/terraforged/mod/decorator/terrain/GeologyDecorator.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package com.terraforged.mod.decorator.base; +package com.terraforged.mod.decorator.terrain; import com.terraforged.api.chunk.column.ColumnDecorator; import com.terraforged.api.chunk.column.DecoratorContext; diff --git a/src/main/java/com/terraforged/mod/feature/BlockDataConfig.java b/src/main/java/com/terraforged/mod/feature/BlockDataConfig.java new file mode 100644 index 0000000..fcf6f54 --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/BlockDataConfig.java @@ -0,0 +1,16 @@ +package com.terraforged.mod.feature; + +import com.google.gson.JsonObject; +import net.minecraft.block.Block; + +import java.util.Optional; + +public interface BlockDataConfig { + + Block getTarget(); + + interface Parser { + + Optional parse(JsonObject data); + } +} diff --git a/src/main/java/com/terraforged/mod/feature/BlockDataManager.java b/src/main/java/com/terraforged/mod/feature/BlockDataManager.java new file mode 100644 index 0000000..bb615b5 --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/BlockDataManager.java @@ -0,0 +1,35 @@ +package com.terraforged.mod.feature; + +import com.google.common.collect.ImmutableMap; +import com.terraforged.mod.feature.manager.data.DataManager; +import com.terraforged.mod.feature.manager.util.Json; +import com.terraforged.mod.feature.sapling.SaplingConfig; +import net.minecraft.block.Block; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +public class BlockDataManager { + + private static final Map parsers = ImmutableMap.builder() + .put("terraforged:sapling", SaplingConfig::deserialize) + .build(); + + private final Map blockdata = new HashMap<>(); + + public BlockDataManager(DataManager dataManager) { + dataManager.forEachJson("blocks/saplings", (name, data) -> { + String type = Json.getString("type", data.getAsJsonObject(), ""); + BlockDataConfig.Parser parser = parsers.get(type); + if (parser == null) { + return; + } + parser.parse(data.getAsJsonObject()).ifPresent(config -> blockdata.put(config.getTarget(), config)); + }); + } + + public Optional getConfig(Block block, Class type) { + return Optional.ofNullable(blockdata.get(block)).filter(type::isInstance).map(type::cast); + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/Matchers.java b/src/main/java/com/terraforged/mod/feature/Matchers.java similarity index 84% rename from TerraForgedMod/src/main/java/com/terraforged/mod/feature/Matchers.java rename to src/main/java/com/terraforged/mod/feature/Matchers.java index 645e85f..253e793 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/Matchers.java +++ b/src/main/java/com/terraforged/mod/feature/Matchers.java @@ -25,10 +25,11 @@ package com.terraforged.mod.feature; -import com.terraforged.feature.matcher.BiomeFeatureMatcher; -import com.terraforged.feature.matcher.biome.BiomeMatcher; -import com.terraforged.feature.matcher.feature.FeatureMatcher; +import com.terraforged.mod.feature.manager.matcher.BiomeFeatureMatcher; +import com.terraforged.mod.feature.manager.matcher.biome.BiomeMatcher; +import com.terraforged.mod.feature.manager.matcher.feature.FeatureMatcher; import com.terraforged.mod.feature.feature.DiskFeature; +import net.minecraft.block.Blocks; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.feature.Feature; @@ -44,6 +45,12 @@ public class Matchers { .build(); } + public static FeatureMatcher tree() { + return FeatureMatcher.builder() + .or(Blocks.OAK_LOG).and(Blocks.OAK_LEAVES) + .build(); + } + public static BiomeFeatureMatcher sedimentDisks() { return new BiomeFeatureMatcher( BiomeMatcher.of(Biome.Category.RIVER, Biome.Category.SWAMP), diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/TerrainHelper.java b/src/main/java/com/terraforged/mod/feature/TerrainHelper.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/feature/TerrainHelper.java rename to src/main/java/com/terraforged/mod/feature/TerrainHelper.java diff --git a/src/main/java/com/terraforged/mod/feature/context/ChanceContext.java b/src/main/java/com/terraforged/mod/feature/context/ChanceContext.java new file mode 100644 index 0000000..f0b7095 --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/context/ChanceContext.java @@ -0,0 +1,83 @@ +package com.terraforged.mod.feature.context; + +import com.terraforged.core.cell.Cell; +import com.terraforged.core.region.chunk.ChunkReader; +import com.terraforged.core.concurrent.ObjectPool; +import com.terraforged.world.heightmap.Levels; +import com.terraforged.mod.chunk.util.TerraContainer; +import com.terraforged.mod.chunk.fix.RegionDelegate; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; +import net.minecraft.world.biome.BiomeContainer; +import net.minecraft.world.chunk.IChunk; +import net.minecraft.world.gen.WorldGenRegion; + +import java.util.Random; + +public class ChanceContext { + + private static final ObjectPool pool = new ObjectPool<>(10, ChanceContext::new); + + public IChunk chunk; + public Levels levels; + public ChunkReader reader; + public Cell cell = Cell.empty(); + + private int length; + private float total = 0F; + private float[] buffer; + + void setPos(BlockPos pos) { + cell = reader.getCell(pos.getX(), pos.getZ()); + } + + void init(int size) { + total = 0F; + length = 0; + if (buffer == null || buffer.length < size) { + buffer = new float[size]; + } + } + + void record(int index, float chance) { + buffer[index] = chance; + total += chance; + length++; + } + + int nextIndex(Random random) { + float value = 0F; + float chance = random.nextFloat() * total; + for (int i = 0; i < length; i++) { + value += buffer[i]; + if (value >= chance) { + return i; + } + } + return -1; + } + + public static ObjectPool.Item pooled(IWorld world) { + if (world instanceof RegionDelegate) { + Levels levels = new Levels(world.getMaxHeight(), world.getSeaLevel()); + WorldGenRegion region = ((RegionDelegate) world).getRegion(); + IChunk chunk = region.getChunk(region.getMainChunkX(), region.getMainChunkZ()); + return pooled(chunk, levels); + } + return null; + } + + public static ObjectPool.Item pooled(IChunk chunk, Levels levels) { + BiomeContainer container = chunk.getBiomes(); + if (container instanceof TerraContainer) { + ChunkReader reader = ((TerraContainer) container).getChunkReader(); + ObjectPool.Item item = pool.get(); + ChanceContext context = item.getValue(); + context.chunk = chunk; + context.levels = levels; + context.reader = reader; + return item; + } + return null; + } +} diff --git a/src/main/java/com/terraforged/mod/feature/context/ContextSelectorConfig.java b/src/main/java/com/terraforged/mod/feature/context/ContextSelectorConfig.java new file mode 100644 index 0000000..17496a2 --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/context/ContextSelectorConfig.java @@ -0,0 +1,28 @@ +package com.terraforged.mod.feature.context; + +import com.google.common.collect.ImmutableMap; +import com.mojang.datafixers.Dynamic; +import com.mojang.datafixers.types.DynamicOps; +import net.minecraft.world.gen.feature.IFeatureConfig; + +import java.util.List; + +public class ContextSelectorConfig implements IFeatureConfig { + + public final List features; + + public ContextSelectorConfig(List features) { + this.features = features; + } + + @Override + public Dynamic serialize(DynamicOps ops) { + return new Dynamic<>(ops, ops.createMap(ImmutableMap.of( + ops.createString("features"), ops.createList(features.stream().map(f -> f.serialize(ops).getValue()) + )))); + } + + public static ContextSelectorConfig deserialize(Dynamic dynamic) { + return new ContextSelectorConfig(dynamic.get("features").asList(ContextualFeature::deserialize)); + } +} diff --git a/src/main/java/com/terraforged/mod/feature/context/ContextSelectorFeature.java b/src/main/java/com/terraforged/mod/feature/context/ContextSelectorFeature.java new file mode 100644 index 0000000..6be7ad8 --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/context/ContextSelectorFeature.java @@ -0,0 +1,45 @@ +package com.terraforged.mod.feature.context; + +import com.terraforged.core.concurrent.ObjectPool; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.GenerationSettings; +import net.minecraft.world.gen.feature.Feature; + +import java.util.Random; + +public class ContextSelectorFeature extends Feature { + + public static final ContextSelectorFeature INSTANCE = new ContextSelectorFeature(); + + public ContextSelectorFeature() { + super(ContextSelectorConfig::deserialize); + setRegistryName("terraforged", "context_selector"); + } + + @Override + public boolean place(IWorld world, ChunkGenerator generator, Random random, BlockPos pos, ContextSelectorConfig config) { + try (ObjectPool.Item item = ChanceContext.pooled(world)) { + if (item == null) { + return false; + } + + ChanceContext context = item.getValue(); + context.setPos(pos); + context.init(config.features.size()); + for (int i = 0; i < config.features.size(); i++) { + ContextualFeature feature = config.features.get(i); + float chance = feature.getChance(pos, context); + context.record(i, chance); + } + + int index = context.nextIndex(random); + if (index > -1) { + return config.features.get(index).feature.place(world, generator, random, pos); + } + + return false; + } + } +} diff --git a/src/main/java/com/terraforged/mod/feature/context/ContextualFeature.java b/src/main/java/com/terraforged/mod/feature/context/ContextualFeature.java new file mode 100644 index 0000000..8d60b8c --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/context/ContextualFeature.java @@ -0,0 +1,81 @@ +package com.terraforged.mod.feature.context; + +import com.google.common.collect.ImmutableMap; +import com.mojang.datafixers.Dynamic; +import com.mojang.datafixers.OptionalDynamic; +import com.mojang.datafixers.types.DynamicOps; +import com.terraforged.mod.feature.context.modifier.ContextModifier; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.gen.feature.ConfiguredFeature; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class ContextualFeature { + + public final float chance; + public final List contexts; + public final ConfiguredFeature feature; + + public ContextualFeature(ConfiguredFeature feature, float chance, List contexts) { + this.chance = chance; + this.feature = feature; + this.contexts = contexts; + } + + public String getName() { + return "chance"; + } + + public float getChance(BlockPos pos, ChanceContext context) { + float chance = this.chance; + for (ContextModifier modifier : contexts) { + chance *= modifier.getChance(pos, context); + } + return chance; + } + + public Dynamic serialize(DynamicOps ops) { + return new Dynamic<>(ops, ops.createMap(ImmutableMap.of( + ops.createString("feature"), feature.serialize(ops).getValue(), + ops.createString("context"), serializeContext(ops).getValue() + ))); + } + + private Dynamic serializeContext(DynamicOps ops) { + Map map = new LinkedHashMap<>(); + map.put(ops.createString("chance"), ops.createFloat(chance)); + for (ContextModifier context : contexts) { + map.put(ops.createString(context.getName()), context.serialize(ops).getValue()); + } + return new Dynamic<>(ops, ops.createMap(map)); + } + + public static ContextualFeature deserialize(Dynamic dynamic) { + ConfiguredFeature feature = deserializeFeature(dynamic.get("feature")); + OptionalDynamic context = dynamic.get("context"); + float chance = context.get("chance").asFloat(0); + List contexts = deserializeContexts(context); + return new ContextualFeature(feature, chance, contexts); + } + + private static ConfiguredFeature deserializeFeature(OptionalDynamic dynamic) { + return dynamic.map(ConfiguredFeature::deserialize).orElseThrow(NullPointerException::new); + } + + private static List deserializeContexts(OptionalDynamic dynamic) { + return dynamic.map(d -> d.getMapValues().map(map -> { + List contexts = new ArrayList<>(map.size()); + map.forEach((key, value) -> { + String name = key.asString(""); + if (!name.equals("chance")) { + contexts.add(ContextModifier.parse(name, value)); + } + }); + return contexts; + }).orElse(Collections.emptyList())).orElseThrow(NullPointerException::new); + } +} diff --git a/src/main/java/com/terraforged/mod/feature/context/modifier/Biome.java b/src/main/java/com/terraforged/mod/feature/context/modifier/Biome.java new file mode 100644 index 0000000..d123c3f --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/context/modifier/Biome.java @@ -0,0 +1,29 @@ +package com.terraforged.mod.feature.context.modifier; + +import com.mojang.datafixers.Dynamic; +import com.terraforged.mod.feature.context.ChanceContext; +import net.minecraft.util.math.BlockPos; + +public class Biome extends RangeContextModifier { + + public Biome(float chance, float min, float max) { + super(min, max); + } + + @Override + public String getName() { + return "biome"; + } + + @Override + protected float getValue(BlockPos pos, ChanceContext context) { + return context.cell.biomeEdge; + } + + public static ContextModifier deserialize(Dynamic dynamic) { + float chance = dynamic.get("chance").asFloat(0F); + float min = dynamic.get("min").asFloat(0F); + float max = dynamic.get("max").asFloat(1F); + return new Biome(chance, min, max); + } +} diff --git a/src/main/java/com/terraforged/mod/feature/context/modifier/ContextModifier.java b/src/main/java/com/terraforged/mod/feature/context/modifier/ContextModifier.java new file mode 100644 index 0000000..f540823 --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/context/modifier/ContextModifier.java @@ -0,0 +1,34 @@ +package com.terraforged.mod.feature.context.modifier; + +import com.google.common.collect.ImmutableMap; +import com.mojang.datafixers.Dynamic; +import com.mojang.datafixers.types.DynamicOps; +import com.terraforged.mod.feature.context.ChanceContext; +import net.minecraft.util.math.BlockPos; + +import java.util.Map; +import java.util.function.Function; + +public interface ContextModifier { + + Map, ContextModifier>> REGISTRY = ImmutableMap.of( + "elevation", Elevation::deserialize, + "biome", Biome::deserialize + ); + + ContextModifier NONE = new None(); + + String getName(); + + float getChance(BlockPos pos, ChanceContext context); + + Dynamic serialize(DynamicOps ops); + + static ContextModifier parse(String type, Dynamic dynamic) { + Function, ContextModifier> func = REGISTRY.get(type); + if (func == null) { + return NONE; + } + return func.apply(dynamic); + } +} diff --git a/src/main/java/com/terraforged/mod/feature/context/modifier/Elevation.java b/src/main/java/com/terraforged/mod/feature/context/modifier/Elevation.java new file mode 100644 index 0000000..44119d4 --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/context/modifier/Elevation.java @@ -0,0 +1,28 @@ +package com.terraforged.mod.feature.context.modifier; + +import com.mojang.datafixers.Dynamic; +import com.terraforged.mod.feature.context.ChanceContext; +import net.minecraft.util.math.BlockPos; + +public class Elevation extends RangeContextModifier { + + public Elevation(float min, float max) { + super(min, max); + } + + @Override + public String getName() { + return "elevation"; + } + + @Override + protected float getValue(BlockPos pos, ChanceContext context) { + return context.levels.elevation(context.cell.value); + } + + public static ContextModifier deserialize(Dynamic dynamic) { + float min = dynamic.get("min").asFloat(0F); + float max = dynamic.get("max").asFloat(1F); + return new Elevation(min, max); + } +} diff --git a/src/main/java/com/terraforged/mod/feature/context/modifier/None.java b/src/main/java/com/terraforged/mod/feature/context/modifier/None.java new file mode 100644 index 0000000..6a4d572 --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/context/modifier/None.java @@ -0,0 +1,24 @@ +package com.terraforged.mod.feature.context.modifier; + +import com.mojang.datafixers.Dynamic; +import com.mojang.datafixers.types.DynamicOps; +import com.terraforged.mod.feature.context.ChanceContext; +import net.minecraft.util.math.BlockPos; + +public class None implements ContextModifier { + + @Override + public String getName() { + return "none"; + } + + @Override + public float getChance(BlockPos pos, ChanceContext context) { + return 0; + } + + @Override + public Dynamic serialize(DynamicOps ops) { + return new Dynamic<>(ops); + } +} diff --git a/src/main/java/com/terraforged/mod/feature/context/modifier/RangeContextModifier.java b/src/main/java/com/terraforged/mod/feature/context/modifier/RangeContextModifier.java new file mode 100644 index 0000000..9d9e6cb --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/context/modifier/RangeContextModifier.java @@ -0,0 +1,30 @@ +package com.terraforged.mod.feature.context.modifier; + +import com.google.common.collect.ImmutableMap; +import com.mojang.datafixers.Dynamic; +import com.mojang.datafixers.types.DynamicOps; +import com.terraforged.mod.feature.context.ChanceContext; +import com.terraforged.mod.util.RangeModifier; +import net.minecraft.util.math.BlockPos; + +public abstract class RangeContextModifier extends RangeModifier implements ContextModifier { + + public RangeContextModifier(float min, float max) { + super(min, max); + } + + @Override + public float getChance(BlockPos pos, ChanceContext context) { + return apply(getValue(pos, context)); + } + + @Override + public Dynamic serialize(DynamicOps ops) { + return new Dynamic<>(ops, ops.createMap(ImmutableMap.of( + ops.createString("min"), ops.createFloat(min), + ops.createString("max"), ops.createFloat(max) + ))); + } + + protected abstract float getValue(BlockPos pos, ChanceContext context); +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/BiomeVariance.java b/src/main/java/com/terraforged/mod/feature/decorator/poisson/BiomeVariance.java similarity index 93% rename from TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/BiomeVariance.java rename to src/main/java/com/terraforged/mod/feature/decorator/poisson/BiomeVariance.java index a54c154..85a8d14 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/BiomeVariance.java +++ b/src/main/java/com/terraforged/mod/feature/decorator/poisson/BiomeVariance.java @@ -2,7 +2,7 @@ package com.terraforged.mod.feature.decorator.poisson; import com.terraforged.core.cell.Cell; import com.terraforged.core.region.chunk.ChunkReader; -import com.terraforged.mod.chunk.TerraContainer; +import com.terraforged.mod.chunk.util.TerraContainer; import com.terraforged.mod.chunk.fix.RegionDelegate; import me.dags.noise.Module; import me.dags.noise.Source; @@ -28,7 +28,7 @@ public class BiomeVariance implements Module { @Override public float getValue(float x, float y) { - Cell cell = chunk.getCell((int) x, (int) y); + Cell cell = chunk.getCell((int) x, (int) y); return NoiseUtil.map(1 - cell.biomeEdge, MIN_FADE, fade, range); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonAtSurface.java b/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonAtSurface.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonAtSurface.java rename to src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonAtSurface.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonConfig.java b/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonConfig.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonConfig.java rename to src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonConfig.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonDecorator.java b/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonDecorator.java similarity index 95% rename from TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonDecorator.java rename to src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonDecorator.java index 7a480e0..f8a34e4 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonDecorator.java +++ b/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonDecorator.java @@ -1,5 +1,7 @@ package com.terraforged.mod.feature.decorator.poisson; +import com.terraforged.core.util.poisson.Poisson; +import com.terraforged.core.util.poisson.PoissonContext; import me.dags.noise.Module; import me.dags.noise.Source; import net.minecraft.util.math.BlockPos; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonVisitor.java b/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonVisitor.java similarity index 84% rename from TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonVisitor.java rename to src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonVisitor.java index b39b6ad..998ff1c 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonVisitor.java +++ b/src/main/java/com/terraforged/mod/feature/decorator/poisson/PoissonVisitor.java @@ -1,14 +1,15 @@ package com.terraforged.mod.feature.decorator.poisson; +import com.terraforged.core.util.poisson.Poisson; +import com.terraforged.core.util.poisson.PoissonContext; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.gen.ChunkGenerator; import net.minecraft.world.gen.feature.ConfiguredFeature; import java.util.Random; -import java.util.function.BiConsumer; -public class PoissonVisitor extends PoissonContext implements BiConsumer { +public class PoissonVisitor extends PoissonContext implements Poisson.Visitor { private final BlockPos pos; private final IWorld world; @@ -33,7 +34,7 @@ public class PoissonVisitor extends PoissonContext implements BiConsumer normal; + private final List giant; + + private SaplingConfig(Block block, List normal, List giant) { + this.block = block; + this.normal = normal; + this.giant = giant; + } + + @Override + public Block getTarget() { + return block; + } + + public boolean hasNormal() { + return !normal.isEmpty(); + } + + public boolean hasGiant() { + return !giant.isEmpty(); + } + + public TemplateFeatureConfig next(Random random, boolean giant) { + if (giant) { + TemplateFeatureConfig config = nextGiant(random); + if (config != null) { + return config; + } + } + return nextNormal(random); + } + + public TemplateFeatureConfig nextNormal(Random random) { + if (normal.isEmpty()) { + return null; + } + return normal.get(random.nextInt(normal.size())); + } + + public TemplateFeatureConfig nextGiant(Random random) { + if (giant.isEmpty()) { + return null; + } + return giant.get(random.nextInt(giant.size())); + } + + public static Optional deserialize(JsonObject data) { + String sapling = Json.getString("sapling", data, ""); + Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(sapling)); + if (block == Blocks.AIR) { + return Optional.empty(); + } + List normal = deserializeList(data.getAsJsonObject("normal")); + List giant = deserializeList(data.getAsJsonObject("giant")); + if (normal.isEmpty() && giant.isEmpty()) { + return Optional.empty(); + } + return Optional.of(new SaplingConfig(block, normal, giant)); + } + + private static List deserializeList(JsonObject object) { + List list = Collections.emptyList(); + if (object != null) { + for (Map.Entry e : object.entrySet()) { + ResourceLocation name = new ResourceLocation(e.getKey()); + TemplateFeatureConfig template = TemplateManager.getInstance().getTemplateConfig(name); + if (template != TemplateFeatureConfig.NONE) { + int weight = Json.getInt("weight", e.getValue().getAsJsonObject(), 1); + for (int i = 0; i < weight; i++) { + if (list.isEmpty()) { + list = new ArrayList<>(); + } + list.add(template); + } + } + } + } + return list; + } +} diff --git a/src/main/java/com/terraforged/mod/feature/sapling/SaplingListener.java b/src/main/java/com/terraforged/mod/feature/sapling/SaplingListener.java new file mode 100644 index 0000000..6369126 --- /dev/null +++ b/src/main/java/com/terraforged/mod/feature/sapling/SaplingListener.java @@ -0,0 +1,208 @@ +/* + * + * MIT License + * + * Copyright (c) 2020 TerraForged + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.terraforged.mod.feature.sapling; + +import com.terraforged.mod.feature.manager.template.Template; +import com.terraforged.mod.feature.manager.template.feature.TemplateFeature; +import com.terraforged.mod.feature.manager.template.feature.TemplateFeatureConfig; +import com.terraforged.mod.TerraWorld; +import com.terraforged.mod.chunk.TerraChunkGenerator; +import com.terraforged.mod.chunk.TerraContext; +import com.terraforged.mod.feature.BlockDataManager; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; +import net.minecraft.world.IWorld; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.event.world.SaplingGrowTreeEvent; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; + +import java.util.Optional; + +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE) +public class SaplingListener { + + private static final BlockPos[] CENTER = {BlockPos.ZERO}; + + private static final Vec3i[][] DIRECTIONS = { + {new Vec3i(0, 0, 1), new Vec3i(1, 0, 1), new Vec3i(1, 0, 0)}, + {new Vec3i(1, 0, 0), new Vec3i(1, 0, -1), new Vec3i(0, 0, -1)}, + {new Vec3i(0, 0, -1), new Vec3i(-1, 0, -1), new Vec3i(-1, 0, 0)}, + {new Vec3i(-1, 0, 0), new Vec3i(-1, 0, 1), new Vec3i(0, 0, 1)}, + }; + + @SubscribeEvent + public static void onTreeGrow(SaplingGrowTreeEvent event) { + Optional dataManager = getDataManger(event); + if (!dataManager.isPresent()) { + return; + } + + IWorld world = event.getWorld(); + Block block = world.getBlockState(event.getPos()).getBlock(); + Optional saplingConfig = dataManager.get().getConfig(block, SaplingConfig.class); + if (!saplingConfig.isPresent()) { + return; + } + + Mirror mirror = TemplateFeature.nextMirror(event.getRand()); + Rotation rotation = TemplateFeature.nextRotation(event.getRand()); + + // if part of a 2x2 grid get the min corner of it + BlockPos pos = getMinPos(world, block, event.getPos(), saplingConfig.get().hasGiant()); + Vec3i[] directions = getNeighbours(world, block, pos, saplingConfig.get().hasGiant()); + TemplateFeatureConfig feature = saplingConfig.get().next(event.getRand(), directions.length == 3); + if (feature == null) { + return; + } + + // translate the pos so that the mirrored/rotated 2x2 grid aligns correctly + BlockPos origin = pos.subtract(getTranslation(directions, mirror, rotation)); + + // require that directly above the sapling(s) is open air + if (!isClearOverhead(world, origin, directions)) { + event.setResult(Event.Result.DENY); + return; + } + + // attempt to paste the tree & then clear up any remaining saplings + if (TemplateFeature.pasteChecked(world, event.getRand(), origin, mirror, rotation, feature, feature.decorator)) { + event.setResult(Event.Result.DENY); + for (Vec3i dir : directions) { + BlockPos neighbour = origin.add(dir); + BlockState state = world.getBlockState(neighbour); + if (state.getBlock() == block) { + world.destroyBlock(neighbour, false); + } + } + } + } + + private static Optional getDataManger(SaplingGrowTreeEvent event) { + // ignore if client + if (event.getWorld().isRemote()) { + return Optional.empty(); + } + + // ignore other world types + if (!TerraWorld.isTerraWorld(event.getWorld())) { + return Optional.empty(); + } + + // get the data manager from the world's chunk generator + if (event.getWorld() instanceof ServerWorld) { + ServerWorld serverWorld = (ServerWorld) event.getWorld(); + ChunkGenerator generator = serverWorld.getChunkProvider().generator; + if (generator instanceof TerraChunkGenerator) { + TerraContext context = ((TerraChunkGenerator) generator).getContext(); + if (context.terraSettings.features.customBiomeFeatures) { + return Optional.of(((TerraChunkGenerator) generator).getBlockDataManager()); + } + } + } + return Optional.empty(); + } + + private static boolean isClearOverhead(IWorld world, BlockPos pos, Vec3i[] directions) { + for (Vec3i dir : directions) { + int x = pos.getX() + dir.getX(); + int z = pos.getZ() + dir.getZ(); + int y = world.getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, x, z); + if (y > pos.getY()) { + return false; + } + } + return true; + } + + private static BlockPos getMinPos(IWorld world, Block block, BlockPos pos, boolean checkNeighbours) { + if (checkNeighbours) { + for (Vec3i[] dirs : DIRECTIONS) { + boolean match = true; + for (Vec3i dir : dirs) { + BlockState state = world.getBlockState(pos.add(dir)); + if (state.getBlock() != block) { + match = false; + break; + } + } + if (match) { + return pos.add(getMin(dirs, Mirror.NONE, Rotation.NONE)); + } + } + } + return pos; + } + + private static Vec3i getTranslation(Vec3i[] directions, Mirror mirror, Rotation rotation) { + if (directions.length == 1 || mirror == Mirror.NONE && rotation == Rotation.NONE) { + return Vec3i.NULL_VECTOR; + } + return getMin(directions, mirror, rotation); + } + + private static Vec3i getMin(Vec3i[] directions, Mirror mirror, Rotation rotation) { + Vec3i min = Vec3i.NULL_VECTOR; + BlockPos.Mutable pos = new BlockPos.Mutable(); + for (Vec3i vec : directions) { + BlockPos dir = Template.transform(pos.setPos(vec), mirror, rotation); + if (dir.getX() < min.getX() && dir.getZ() <= min.getZ()) { + min = dir; + continue; + } + if (dir.getZ() < min.getZ() && dir.getX() <= min.getX()) { + min = dir; + } + } + return min; + } + + private static Vec3i[] getNeighbours(IWorld world, Block block, BlockPos pos, boolean checkNeighbours) { + if (checkNeighbours) { + for (Vec3i[] dirs : DIRECTIONS) { + boolean match = true; + for (Vec3i dir : dirs) { + BlockState state = world.getBlockState(pos.add(dir)); + if (state.getBlock() != block) { + match = false; + break; + } + } + if (match) { + return dirs; + } + } + } + return CENTER; + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/OverlayRenderer.java b/src/main/java/com/terraforged/mod/gui/OverlayRenderer.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/OverlayRenderer.java rename to src/main/java/com/terraforged/mod/gui/OverlayRenderer.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/OverlayScreen.java b/src/main/java/com/terraforged/mod/gui/OverlayScreen.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/OverlayScreen.java rename to src/main/java/com/terraforged/mod/gui/OverlayScreen.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/ScrollPane.java b/src/main/java/com/terraforged/mod/gui/ScrollPane.java similarity index 94% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/ScrollPane.java rename to src/main/java/com/terraforged/mod/gui/ScrollPane.java index dbbc9d3..2a58688 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/ScrollPane.java +++ b/src/main/java/com/terraforged/mod/gui/ScrollPane.java @@ -105,16 +105,6 @@ public class ScrollPane extends AbstractOptionList implements return option.mouseReleased(x, y, button); } - @Override - public boolean keyPressed(int i, int j, int k) { - return option.keyPressed(i, j, k); - } - - @Override - public boolean charTyped(char c, int code) { - return option.charTyped(c, code); - } - @Override public void render(int index, int top, int left, int width, int height, int mouseX, int mouseY, boolean wut, float partialTicks) { int optionWidth = Math.min(396, width); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/SettingsScreen.java b/src/main/java/com/terraforged/mod/gui/SettingsScreen.java similarity index 80% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/SettingsScreen.java rename to src/main/java/com/terraforged/mod/gui/SettingsScreen.java index cae2e4b..9a5aad0 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/SettingsScreen.java +++ b/src/main/java/com/terraforged/mod/gui/SettingsScreen.java @@ -25,17 +25,15 @@ package com.terraforged.mod.gui; -import com.terraforged.mod.gui.element.TerraButton; import com.terraforged.mod.gui.element.TerraLabel; import com.terraforged.mod.gui.page.ClimatePage; -import com.terraforged.mod.gui.page.DimensionsPage; -import com.terraforged.mod.gui.page.FeaturePage; -import com.terraforged.mod.gui.page.FilterPage; -import com.terraforged.mod.gui.page.GeneratorPage; +import com.terraforged.mod.gui.page.MiscPage; import com.terraforged.mod.gui.page.Page; +import com.terraforged.mod.gui.page.PresetsPage; import com.terraforged.mod.gui.page.RiverPage; import com.terraforged.mod.gui.page.StructurePage; import com.terraforged.mod.gui.page.TerrainPage; +import com.terraforged.mod.gui.page.WorldPage; import com.terraforged.mod.gui.preview.PreviewPage; import com.terraforged.mod.settings.SettingsHelper; import com.terraforged.mod.settings.TerraSettings; @@ -58,21 +56,19 @@ public class SettingsScreen extends OverlayScreen { private final TerraSettings settings = new TerraSettings(); private int pageIndex = 0; - private boolean hasChanged = false; public SettingsScreen(CreateWorldScreen parent) { SettingsHelper.applyDefaults(parent.chunkProviderSettingsJson, settings); this.parent = parent; this.preview = new PreviewPage(settings, getSeed(parent)); this.pages = new Page[]{ - new GeneratorPage(settings, preview), + new PresetsPage(), + new WorldPage(settings, preview), new ClimatePage(settings, preview), new TerrainPage(settings, preview), new RiverPage(settings, preview), - new FilterPage(settings, preview), - new FeaturePage(settings), new StructurePage(settings), - new DimensionsPage(settings), + new MiscPage(settings) }; } @@ -89,7 +85,6 @@ public class SettingsScreen extends OverlayScreen { if (pageIndex < pages.length) { Page page = pages[pageIndex]; - page.callback(() -> this.hasChanged = true); TerraLabel title = new TerraLabel(page.getTitle()); title.visible = true; title.x = 16; @@ -155,44 +150,6 @@ public class SettingsScreen extends OverlayScreen { } }); - addButton(new TerraButton("Set Defaults", "Use the current settings as the defaults", "CTRL + click to clear them") { - - private boolean ctrl = false; - - @Override - public void render(int mouseX, int mouseY, float partialTicks) { - if (Screen.hasControlDown()) { - if (!ctrl) { - ctrl = true; - setMessage("Clear Defaults"); - } - super.active = true; - } else { - if (ctrl) { - ctrl = false; - setMessage("Set Defaults"); - } - super.active = hasChanged; - } - super.render(mouseX, mouseY, partialTicks); - } - - @Override - public void onClick(double mouseX, double mouseY) { - super.onClick(mouseX, mouseY); - if (Screen.hasControlDown()) { - SettingsHelper.clearDefaults(); - hasChanged = true; - } else { - for (Page page : pages) { - page.save(); - } - hasChanged = false; - SettingsHelper.exportDefaults(settings); - } - } - }.init(width - buttonWidth - 55, buttonsRow, 90, buttonHeight)); - super.init(); } @@ -251,13 +208,6 @@ public class SettingsScreen extends OverlayScreen { return a || b || c; } - @Override - public boolean charTyped(char c, int code) { - boolean a = pages[pageIndex].action(pane -> pane.charTyped(c, code)); - boolean b = preview.action(pane -> pane.charTyped(c, code)); - return a || b || super.charTyped(c, code); - } - @Override public void onClose() { for (Page page : pages) { diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/CheckBox.java b/src/main/java/com/terraforged/mod/gui/element/CheckBox.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/CheckBox.java rename to src/main/java/com/terraforged/mod/gui/element/CheckBox.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/Element.java b/src/main/java/com/terraforged/mod/gui/element/Element.java similarity index 68% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/Element.java rename to src/main/java/com/terraforged/mod/gui/element/Element.java index 2596595..f3dc045 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/Element.java +++ b/src/main/java/com/terraforged/mod/gui/element/Element.java @@ -25,15 +25,12 @@ package com.terraforged.mod.gui.element; +import net.minecraft.client.resources.I18n; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraftforge.common.util.Constants; import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; public interface Element { @@ -47,13 +44,23 @@ public interface Element { return ID_COUNTER.getAndAdd(1); } - static List readTooltip(CompoundNBT value) { - if (value.contains("#comment")) { - ListNBT comment = value.getList("#comment", Constants.NBT.TAG_STRING); - return comment.stream() - .map(INBT::getString) - .collect(Collectors.toList()); - } - return Collections.emptyList(); + static String getDisplayName(String name, CompoundNBT value) { + return I18n.format(getDisplayKey(name, value)); + } + + static List getToolTip(String name, CompoundNBT value) { + return Collections.singletonList(I18n.format(getCommentKey(name, value))); + } + + static String getDisplayKey(String name, CompoundNBT value) { + return "display.terraforged." + getKey(name, value); + } + + static String getCommentKey(String name, CompoundNBT value) { + return "tooltip.terraforged." + getKey(name, value); + } + + static String getKey(String name, CompoundNBT value) { + return value.getCompound("#" + name).getString("key"); } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraButton.java b/src/main/java/com/terraforged/mod/gui/element/TerraButton.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraButton.java rename to src/main/java/com/terraforged/mod/gui/element/TerraButton.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraLabel.java b/src/main/java/com/terraforged/mod/gui/element/TerraLabel.java similarity index 87% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraLabel.java rename to src/main/java/com/terraforged/mod/gui/element/TerraLabel.java index 8acddf5..0877937 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraLabel.java +++ b/src/main/java/com/terraforged/mod/gui/element/TerraLabel.java @@ -30,17 +30,9 @@ import net.minecraft.client.gui.FontRenderer; public class TerraLabel extends TerraButton { -// private final GuiLabel label; - public TerraLabel(String text) { super(text); visible = true; -// label = new GuiLabel( -// Collections.singletonList(text), -// 0xFFFFFF, -// Minecraft.getInstance().fontRenderer -// ); -// label.visible = true; } @Override diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraSlider.java b/src/main/java/com/terraforged/mod/gui/element/TerraSlider.java similarity index 72% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraSlider.java rename to src/main/java/com/terraforged/mod/gui/element/TerraSlider.java index d0f3707..145a1ee 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraSlider.java +++ b/src/main/java/com/terraforged/mod/gui/element/TerraSlider.java @@ -32,16 +32,18 @@ import java.util.List; public abstract class TerraSlider extends Slider implements Slider.ISlider, Element { + protected final String name; private final CompoundNBT value; private final List tooltip; private Runnable callback = () -> {}; - public TerraSlider(String prefix, CompoundNBT value, boolean decimal) { - super(0, 0, 100, 20, prefix, "", value.getFloat("#min"), value.getFloat("#max"), 0F, decimal, true, b -> {}); + public TerraSlider(String name, CompoundNBT value, boolean decimal) { + super(0, 0, 100, 20, Element.getDisplayName(name, value) + ": ", "", min(name, value), max(name, value), 0F, decimal, true, b -> {}); + this.name = name; this.value = value; this.parent = this; - this.tooltip = Element.readTooltip(value); + this.tooltip = Element.getToolTip(name, value); } public TerraSlider callback(Runnable callback) { @@ -71,24 +73,24 @@ public abstract class TerraSlider extends Slider implements Slider.ISlider, Elem public static class Int extends TerraSlider { - public Int(String prefix, CompoundNBT value) { - super(prefix, value, false); - setValue(value.getInt("value")); + public Int(String name, CompoundNBT value) { + super(name, value, false); + setValue(value.getInt(name)); updateSlider(); } @Override protected void onChange(Slider slider, CompoundNBT value) { - value.putInt("value", slider.getValueInt()); + value.putInt(name, slider.getValueInt()); } } public static class Float extends TerraSlider { - public Float(String prefix, CompoundNBT value) { - super(prefix, value, true); + public Float(String name, CompoundNBT value) { + super(name, value, true); precision = 3; - setValue(value.getFloat("value")); + setValue(value.getFloat(name)); updateSlider(); } @@ -96,7 +98,17 @@ public abstract class TerraSlider extends Slider implements Slider.ISlider, Elem protected void onChange(Slider slider, CompoundNBT value) { int i = (int) (slider.getValue() * 1000); float f = i / 1000F; - value.putFloat("value", f); + value.putFloat(name, f); } } + + private static float min(String name, CompoundNBT value) { + CompoundNBT meta = value.getCompound("#" + name); + return meta.getFloat("min"); + } + + private static float max(String name, CompoundNBT value) { + CompoundNBT meta = value.getCompound("#" + name); + return meta.getFloat("max"); + } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraTextInput.java b/src/main/java/com/terraforged/mod/gui/element/TerraTextInput.java similarity index 85% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraTextInput.java rename to src/main/java/com/terraforged/mod/gui/element/TerraTextInput.java index 42c5d3e..81415f8 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraTextInput.java +++ b/src/main/java/com/terraforged/mod/gui/element/TerraTextInput.java @@ -11,16 +11,18 @@ import java.util.function.Predicate; public class TerraTextInput extends TextFieldWidget implements Element, Consumer { + private final String name; private final CompoundNBT value; private final List tooltip; private Predicate validator = s -> true; private Consumer callback = t -> {}; public TerraTextInput(String name, CompoundNBT value) { - super(Minecraft.getInstance().fontRenderer, 0, 0, 100, 20, name); + super(Minecraft.getInstance().fontRenderer, 0, 0, 100, 20, Element.getDisplayName(name, value) + ": "); + this.name = name; this.value = value; - this.tooltip = Element.readTooltip(value); - setText(value.getString("value")); + this.tooltip = Element.getToolTip(name, value); + setText(value.getString(name)); setResponder(this); } @@ -45,7 +47,7 @@ public class TerraTextInput extends TextFieldWidget implements Element, Consumer @Override public void accept(String text) { - value.put("value", StringNBT.valueOf(text)); + value.put(name, StringNBT.valueOf(text)); callback.accept(this); if (validator.test(text)) { setTextColor(14737632); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraToggle.java b/src/main/java/com/terraforged/mod/gui/element/TerraToggle.java similarity index 83% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraToggle.java rename to src/main/java/com/terraforged/mod/gui/element/TerraToggle.java index 27946e9..7a3e2b7 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/element/TerraToggle.java +++ b/src/main/java/com/terraforged/mod/gui/element/TerraToggle.java @@ -35,6 +35,7 @@ import java.util.List; public class TerraToggle extends TerraButton { private final String prefix; + private final String name; private final CompoundNBT value; private final ListNBT options; private final List tooltip; @@ -42,20 +43,22 @@ public class TerraToggle extends TerraButton { private int index; private Runnable callback = () -> {}; - public TerraToggle(String prefix, CompoundNBT value) { - super(value.getString("value")); + public TerraToggle(String name, CompoundNBT value) { + super(value.getString(name)); + this.name = name; this.value = value; - this.prefix = prefix; - this.tooltip = Element.readTooltip(value); - this.options = value.getList("#options", Constants.NBT.TAG_STRING); + this.prefix = Element.getDisplayName(name, value) + ": "; + this.tooltip = Element.getToolTip(name, value); + CompoundNBT meta = value.getCompound("#" + name); + this.options = meta.getList("options", Constants.NBT.TAG_STRING); for (int i = 0; i < options.size(); i++) { String s = options.getString(i); - if (s.equals(value.getString("value"))) { + if (s.equals(value.getString(name))) { index = i; break; } } - setMessage(prefix + value.getString("value")); + setMessage(prefix + value.getString(name)); } public TerraToggle callback(Runnable runnable) { @@ -88,7 +91,7 @@ public class TerraToggle extends TerraButton { index = options.size() - 1; } String option = options.getString(index); - value.putString("value", option); + value.putString(name, option); setMessage(prefix + option); callback.run(); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/BasePage.java b/src/main/java/com/terraforged/mod/gui/page/BasePage.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/BasePage.java rename to src/main/java/com/terraforged/mod/gui/page/BasePage.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/ClimatePage.java b/src/main/java/com/terraforged/mod/gui/page/ClimatePage.java similarity index 96% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/ClimatePage.java rename to src/main/java/com/terraforged/mod/gui/page/ClimatePage.java index 940c15e..b23869e 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/ClimatePage.java +++ b/src/main/java/com/terraforged/mod/gui/page/ClimatePage.java @@ -40,7 +40,7 @@ public class ClimatePage extends BasePage { public ClimatePage(Settings settings, PreviewPage preview) { this.settings = settings; this.preview = preview; - this.climateSettings = NBTHelper.serialize(settings.climate); + this.climateSettings = NBTHelper.serialize("climate", settings.climate); } @Override diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/FeaturePage.java b/src/main/java/com/terraforged/mod/gui/page/MiscPage.java similarity index 74% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/FeaturePage.java rename to src/main/java/com/terraforged/mod/gui/page/MiscPage.java index 2f32b62..cd7a0cc 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/FeaturePage.java +++ b/src/main/java/com/terraforged/mod/gui/page/MiscPage.java @@ -26,33 +26,40 @@ package com.terraforged.mod.gui.page; import com.terraforged.mod.gui.OverlayScreen; +import com.terraforged.mod.gui.element.TerraLabel; import com.terraforged.mod.settings.TerraSettings; import com.terraforged.mod.util.nbt.NBTHelper; import net.minecraft.nbt.CompoundNBT; -public class FeaturePage extends BasePage { +public class MiscPage extends BasePage { private final TerraSettings settings; + private final CompoundNBT filterSettings; private final CompoundNBT featureSettings; - public FeaturePage(TerraSettings settings) { + public MiscPage(TerraSettings settings) { this.settings = settings; - this.featureSettings = NBTHelper.serialize(settings.features); + this.filterSettings = NBTHelper.serialize("filters", settings.filters); + this.featureSettings = NBTHelper.serialize("features", settings.features); } @Override public String getTitle() { - return "Feature Settings"; + return "Miscellaneous Settings"; } @Override public void save() { + NBTHelper.deserialize(filterSettings, settings.filters); NBTHelper.deserialize(featureSettings, settings.features); } @Override public void init(OverlayScreen parent) { Column left = getColumn(0); + addElements(left.left, left.top, left, filterSettings, true, left.scrollPane::addButton, this::update); + + left.scrollPane.addButton(new TerraLabel("Features & Decorators")); addElements(left.left, left.top, left, featureSettings, false, left.scrollPane::addButton, this::update); } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/Page.java b/src/main/java/com/terraforged/mod/gui/page/Page.java similarity index 89% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/Page.java rename to src/main/java/com/terraforged/mod/gui/page/Page.java index 824a562..a02e5aa 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/Page.java +++ b/src/main/java/com/terraforged/mod/gui/page/Page.java @@ -28,6 +28,7 @@ package com.terraforged.mod.gui.page; import com.terraforged.mod.gui.OverlayRenderer; import com.terraforged.mod.gui.OverlayScreen; import com.terraforged.mod.gui.ScrollPane; +import com.terraforged.mod.gui.element.Element; import com.terraforged.mod.gui.element.TerraLabel; import com.terraforged.mod.gui.element.TerraSlider; import com.terraforged.mod.gui.element.TerraTextInput; @@ -40,6 +41,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.INBT; import net.minecraftforge.common.util.Constants; +import java.util.Comparator; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import java.util.function.Function; @@ -135,9 +137,8 @@ public abstract class Page implements IGuiEventListener, OverlayRenderer { public void addElements(int x, int y, Column column, CompoundNBT settings, boolean deep, Consumer consumer, Runnable callback) { AtomicInteger top = new AtomicInteger(y); - NBTHelper.stream(settings).forEach(value -> { - String name = value.getString("#display"); - Widget button = createButton(name, value, callback); + NBTHelper.streamkeys(settings).forEach(name -> { + Widget button = createButton(name, settings, callback); if (button != null) { button.setWidth(column.width); button.setHeight(SLIDER_HEIGHT); @@ -146,11 +147,11 @@ public abstract class Page implements IGuiEventListener, OverlayRenderer { consumer.accept(button); onAddWidget(button); } else if (deep) { - INBT child = value.get("value"); + INBT child = settings.get(name); if (child == null || child.getId() != Constants.NBT.TAG_COMPOUND) { return; } - TerraLabel label = new TerraLabel(name); + TerraLabel label = new TerraLabel(Element.getDisplayName(name, settings)); label.x = x; label.y = top.getAndAdd(SLIDER_HEIGHT + SLIDER_PAD); consumer.accept(label); @@ -160,18 +161,18 @@ public abstract class Page implements IGuiEventListener, OverlayRenderer { } public Widget createButton(String name, CompoundNBT value, Runnable callback) { - INBT tag = value.get("value"); + INBT tag = value.get(name); if (tag == null) { return null; } byte type = tag.getId(); if (type == Constants.NBT.TAG_INT) { - return new TerraSlider.Int(name + ": ", value).callback(callback); + return new TerraSlider.Int(name, value).callback(callback); } else if (type == Constants.NBT.TAG_FLOAT) { - return new TerraSlider.Float(name + ": ", value).callback(callback); - } else if (type == Constants.NBT.TAG_STRING && value.contains("#options")) { - return new TerraToggle(name + ": ", value).callback(callback); + return new TerraSlider.Float(name, value).callback(callback); + } else if (type == Constants.NBT.TAG_STRING && hasOptions(name, value)) { + return new TerraToggle(name, value).callback(callback); } else if (type == Constants.NBT.TAG_STRING) { return new TerraTextInput(name, value); } else { @@ -205,4 +206,8 @@ public abstract class Page implements IGuiEventListener, OverlayRenderer { this.scrollPane.setLeftPos(this.left); } } + + private static boolean hasOptions(String name, CompoundNBT value) { + return value.getCompound("#" + name).contains("options"); + } } diff --git a/src/main/java/com/terraforged/mod/gui/page/PresetPage.java b/src/main/java/com/terraforged/mod/gui/page/PresetPage.java new file mode 100644 index 0000000..12be3a8 --- /dev/null +++ b/src/main/java/com/terraforged/mod/gui/page/PresetPage.java @@ -0,0 +1,16 @@ +package com.terraforged.mod.gui.page; + +import com.terraforged.mod.gui.OverlayScreen; + +public class PresetPage extends BasePage { + + @Override + public void save() { + + } + + @Override + public void init(OverlayScreen parent) { + + } +} diff --git a/src/main/java/com/terraforged/mod/gui/page/PresetsPage.java b/src/main/java/com/terraforged/mod/gui/page/PresetsPage.java new file mode 100644 index 0000000..5c8f733 --- /dev/null +++ b/src/main/java/com/terraforged/mod/gui/page/PresetsPage.java @@ -0,0 +1,21 @@ +package com.terraforged.mod.gui.page; + +import com.terraforged.mod.gui.OverlayScreen; + +public class PresetsPage extends BasePage { + + @Override + public String getTitle() { + return "Presets & Defaults"; + } + + @Override + public void save() { + + } + + @Override + public void init(OverlayScreen parent) { + + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/RiverPage.java b/src/main/java/com/terraforged/mod/gui/page/RiverPage.java similarity index 96% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/RiverPage.java rename to src/main/java/com/terraforged/mod/gui/page/RiverPage.java index f19fc4f..94162dd 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/RiverPage.java +++ b/src/main/java/com/terraforged/mod/gui/page/RiverPage.java @@ -40,7 +40,7 @@ public class RiverPage extends BasePage { public RiverPage(Settings settings, PreviewPage preview) { this.settings = settings; this.preview = preview; - this.riverSettings = NBTHelper.serialize(settings.rivers); + this.riverSettings = NBTHelper.serialize("rivers", settings.rivers); } @Override diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/StructurePage.java b/src/main/java/com/terraforged/mod/gui/page/StructurePage.java similarity index 95% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/StructurePage.java rename to src/main/java/com/terraforged/mod/gui/page/StructurePage.java index e0a8278..e2b30af 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/StructurePage.java +++ b/src/main/java/com/terraforged/mod/gui/page/StructurePage.java @@ -37,7 +37,7 @@ public class StructurePage extends BasePage { public StructurePage(TerraSettings settings) { this.settings = settings; - this.structureSettings = NBTHelper.serialize(settings.structures); + this.structureSettings = NBTHelper.serialize("structures", settings.structures); } @Override diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/TerrainPage.java b/src/main/java/com/terraforged/mod/gui/page/TerrainPage.java similarity index 96% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/TerrainPage.java rename to src/main/java/com/terraforged/mod/gui/page/TerrainPage.java index d1e951d..2dbd732 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/page/TerrainPage.java +++ b/src/main/java/com/terraforged/mod/gui/page/TerrainPage.java @@ -40,7 +40,7 @@ public class TerrainPage extends BasePage { public TerrainPage(Settings settings, PreviewPage preview) { this.settings = settings; this.preview = preview; - this.terrainSettings = NBTHelper.serialize(settings.terrain); + this.terrainSettings = NBTHelper.serialize("terrain", settings.terrain); } @Override diff --git a/src/main/java/com/terraforged/mod/gui/page/WorldPage.java b/src/main/java/com/terraforged/mod/gui/page/WorldPage.java new file mode 100644 index 0000000..6513e1f --- /dev/null +++ b/src/main/java/com/terraforged/mod/gui/page/WorldPage.java @@ -0,0 +1,105 @@ +/* + * + * MIT License + * + * Copyright (c) 2020 TerraForged + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.terraforged.mod.gui.page; + +import com.terraforged.mod.TerraWorld; +import com.terraforged.mod.gui.OverlayScreen; +import com.terraforged.mod.gui.element.TerraTextInput; +import com.terraforged.mod.gui.preview.PreviewPage; +import com.terraforged.mod.settings.TerraSettings; +import com.terraforged.mod.util.nbt.NBTHelper; +import net.minecraft.client.gui.widget.Widget; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.StringNBT; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.WorldType; +import net.minecraftforge.registries.ForgeRegistries; + +public class WorldPage extends BasePage { + + private final TerraSettings settings; + private final PreviewPage preview; + private final CompoundNBT worldSettings; + private final CompoundNBT dimSettings; + + public WorldPage(TerraSettings settings, PreviewPage preview) { + this.settings = settings; + this.preview = preview; + this.worldSettings = NBTHelper.serialize("world", settings.world); + this.dimSettings = NBTHelper.serialize("dimensions", settings.dimensions); + + CompoundNBT generators = dimSettings.getCompound("dimensions").getCompound("value"); + for (String name : generators.keySet()) { + CompoundNBT setting = generators.getCompound(name); + setting.put("#options", getWorldTypes()); + } + } + + @Override + public String getTitle() { + return "World Settings"; + } + + @Override + public void save() { + NBTHelper.deserialize(worldSettings, settings.world); + NBTHelper.deserialize(dimSettings, settings.dimensions); + } + + @Override + public void init(OverlayScreen parent) { + Column left = getColumn(0); + addElements(left.left, left.top, left, worldSettings, true, left.scrollPane::addButton, this::update); + addElements(left.left, left.top, left, dimSettings, true, left.scrollPane::addButton, this::update); + } + + @Override + public void onAddWidget(Widget widget) { + if (widget instanceof TerraTextInput) { + TerraTextInput input = (TerraTextInput) widget; + input.setColorValidator(string -> ForgeRegistries.BLOCKS.containsKey(new ResourceLocation(string))); + } + } + + protected void update() { + super.update(); + preview.apply(settings -> NBTHelper.deserialize(worldSettings, settings.world)); + } + + private static ListNBT getWorldTypes() { + ListNBT options = new ListNBT(); + for (WorldType type : WorldType.WORLD_TYPES) { + if (type == null || (type.getId() >= 1 && type.getId() <= 6) || type.getId() == 8) { + continue; + } + if (!TerraWorld.isTerraType(type)) { + options.add(StringNBT.valueOf(type.getName())); + } + } + return options; + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/Preview.java b/src/main/java/com/terraforged/mod/gui/preview/Preview.java similarity index 85% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/Preview.java rename to src/main/java/com/terraforged/mod/gui/preview/Preview.java index 226d03d..700e8c6 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/Preview.java +++ b/src/main/java/com/terraforged/mod/gui/preview/Preview.java @@ -29,15 +29,15 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.terraforged.core.cell.Cell; import com.terraforged.core.region.Region; +import com.terraforged.core.region.Size; import com.terraforged.core.region.gen.RegionGenerator; import com.terraforged.core.settings.Settings; -import com.terraforged.core.util.concurrent.ThreadPool; -import com.terraforged.core.util.concurrent.cache.CacheEntry; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.WorldGeneratorFactory; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.core.world.terrain.Terrains; +import com.terraforged.core.concurrent.ThreadPool; +import com.terraforged.core.concurrent.cache.CacheEntry; +import com.terraforged.world.GeneratorContext; +import com.terraforged.world.continent.MutableVeci; +import com.terraforged.world.heightmap.Levels; +import com.terraforged.world.terrain.Terrains; import com.terraforged.mod.util.nbt.NBTHelper; import me.dags.noise.util.NoiseUtil; import net.minecraft.client.Minecraft; @@ -54,9 +54,9 @@ import java.util.Random; public class Preview extends Button { private static final int FACTOR = 4; - public static final int WIDTH = 256; + public static final int WIDTH = Size.chunkToBlock(1 << FACTOR); private static final int SLICE_HEIGHT = 64; - public static final int HEIGHT = WIDTH + SLICE_HEIGHT; + public static final int HEIGHT = WIDTH + SLICE_HEIGHT;//Size.chunkToBlock(1 << FACTOR); private static final float[] LEGEND_SCALES = {1, 0.9F, 0.75F, 0.6F}; private final int offsetX; @@ -65,15 +65,15 @@ public class Preview extends Button { private final PreviewSettings previewSettings = new PreviewSettings(); private final DynamicTexture texture = new DynamicTexture(new NativeImage(WIDTH, HEIGHT, true)); - private final String[] values = {"", "", ""}; - private final String[] labels = {"Area: ", "Terrain: ", "Biome: "}; - private int seed; private long lastUpdate = 0L; private Settings settings = new Settings(); private CacheEntry task = null; private Region region = null; + private String[] labels = {"Area: ", "Terrain: ", "Biome: "}; + private String[] values = {"", "", ""}; + public Preview(int seed) { super(0, 0, 0, 0, "", b -> {}); this.seed = seed == -1 ? random.nextInt() : seed; @@ -122,7 +122,7 @@ public class Preview extends Button { lastUpdate = time; NBTHelper.deserialize(prevSettings, previewSettings); - settings.generator.seed = seed; + settings.world.seed = seed; task = generate(settings, prevSettings); } @@ -147,7 +147,7 @@ public class Preview extends Button { } RenderMode renderer = previewSettings.mode; - Levels levels = new Levels(settings.generator); + Levels levels = new Levels(settings.world); int stroke = 2; int width = region.getBlockSize().size; @@ -159,8 +159,8 @@ public class Preview extends Button { float zoomUnit = 1F - (zoom / 100F); float zoomStrength = 0.5F; float unit = (1 - zoomStrength) + (zoomStrength * zoomUnit); - float heightModifier = settings.generator.world.worldHeight / 256F; - float waterLevelModifier = settings.generator.world.seaLevel / (float) settings.generator.world.worldHeight; + float heightModifier = settings.world.levels.worldHeight / 256F; + float waterLevelModifier = settings.world.levels.seaLevel / (float) settings.world.levels.worldHeight; float imageWaterLevelY = image.getHeight() - 1 - (waterLevelModifier * SLICE_HEIGHT * unit); region.iterate((cell, x, z) -> { @@ -194,18 +194,24 @@ public class Preview extends Button { private CacheEntry generate(Settings settings, CompoundNBT prevSettings) { NBTHelper.deserialize(prevSettings, previewSettings); - settings.generator.seed = seed; + settings.world.seed = seed; this.settings = settings; - GeneratorContext context = new GeneratorContext(Terrains.create(settings), settings); + GeneratorContext context = GeneratorContext.createNoCache(Terrains.create(settings), settings); + + MutableVeci center = new MutableVeci(); + context.factory.getHeightmap().getContinent().getNearestCenter(offsetX, offsetZ, center); RegionGenerator renderer = RegionGenerator.builder() - .factory(new WorldGeneratorFactory(context)) .pool(ThreadPool.getPool()) .size(FACTOR, 0) + .factory(context.factory) + .batch(6) .build(); - return renderer.queue(offsetX, offsetZ, 101 - previewSettings.zoom, false); + float zoom = 101 - previewSettings.zoom; + + return renderer.getAsync(center.x, center.z, zoom, false); } private void updateLegend(int mx ,int my) { @@ -222,7 +228,7 @@ public class Preview extends Button { float fz = (my - top) / size; int ix = NoiseUtil.round(fx * region.getBlockSize().size); int iz = NoiseUtil.round(fz * region.getBlockSize().size); - Cell cell = region.getCell(ix, iz); + Cell cell = region.getCell(ix, iz); values[1] = getTerrainName(cell); values[2] = getBiomeName(cell); } @@ -269,16 +275,16 @@ public class Preview extends Button { RenderSystem.popMatrix(); } - private static String getTerrainName(Cell cell) { - String terrain = cell.tag.getName().toLowerCase(); + private static String getTerrainName(Cell cell) { + String terrain = cell.terrainType.getName().toLowerCase(); if (terrain.contains("river")) { return "river"; } return terrain; } - private static String getBiomeName(Cell cell) { - String terrain = cell.tag.getName().toLowerCase(); + private static String getBiomeName(Cell cell) { + String terrain = cell.terrainType.getName().toLowerCase(); if (terrain.contains("ocean")) { if (cell.temperature < 0.3) { return "cold_ocean"; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/PreviewPage.java b/src/main/java/com/terraforged/mod/gui/preview/PreviewPage.java similarity index 98% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/PreviewPage.java rename to src/main/java/com/terraforged/mod/gui/preview/PreviewPage.java index 97bd7be..40d2af7 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/PreviewPage.java +++ b/src/main/java/com/terraforged/mod/gui/preview/PreviewPage.java @@ -38,7 +38,7 @@ public class PreviewPage extends BasePage { private final Preview preview; private final Settings settings; - private final CompoundNBT previewerSettings = NBTHelper.serialize(new PreviewSettings()); + private final CompoundNBT previewerSettings = NBTHelper.serialize("preview", new PreviewSettings()); public PreviewPage(Settings settings, int seed) { this.preview = new Preview(seed); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/PreviewSettings.java b/src/main/java/com/terraforged/mod/gui/preview/PreviewSettings.java similarity index 80% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/PreviewSettings.java rename to src/main/java/com/terraforged/mod/gui/preview/PreviewSettings.java index 661c80c..b283aae 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/PreviewSettings.java +++ b/src/main/java/com/terraforged/mod/gui/preview/PreviewSettings.java @@ -25,12 +25,17 @@ package com.terraforged.mod.gui.preview; -import com.terraforged.core.util.serialization.annotation.Range; +import com.terraforged.core.serialization.annotation.Comment; +import com.terraforged.core.serialization.annotation.Range; +import com.terraforged.core.serialization.annotation.Serializable; +@Serializable public class PreviewSettings { @Range(min = 1, max = 100) + @Comment("Controls the zoom level of the preview map") public int zoom = 100 - 32; + @Comment("Controls the rendering mode on the preview map") public RenderMode mode = RenderMode.BIOME_TYPE; } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/RenderMode.java b/src/main/java/com/terraforged/mod/gui/preview/RenderMode.java similarity index 83% rename from TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/RenderMode.java rename to src/main/java/com/terraforged/mod/gui/preview/RenderMode.java index 0442131..2085934 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/gui/preview/RenderMode.java +++ b/src/main/java/com/terraforged/mod/gui/preview/RenderMode.java @@ -26,8 +26,7 @@ package com.terraforged.mod.gui.preview; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; +import com.terraforged.world.heightmap.Levels; import me.dags.noise.util.NoiseUtil; import java.awt.*; @@ -35,7 +34,7 @@ import java.awt.*; public enum RenderMode { BIOME_TYPE { @Override - public int getColor(Cell cell, float scale, float bias) { + public int getColor(Cell cell, float scale, float bias) { Color color = cell.biomeType.getColor(); float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]); return rgba(hsb[0], hsb[1], (hsb[2] * scale) + bias); @@ -43,7 +42,7 @@ public enum RenderMode { }, TEMPERATURE { @Override - public int getColor(Cell cell, float scale, float bias) { + public int getColor(Cell cell, float scale, float bias) { float saturation = 0.7F; float brightness = 0.8F; return rgba(step(1 - cell.temperature, 8) * 0.65F, saturation, brightness); @@ -51,7 +50,7 @@ public enum RenderMode { }, MOISTURE { @Override - public int getColor(Cell cell, float scale, float bias) { + public int getColor(Cell cell, float scale, float bias) { float saturation = 0.7F; float brightness = 0.8F; return rgba(step(cell.moisture, 8) * 0.65F, saturation, brightness); @@ -59,15 +58,15 @@ public enum RenderMode { }, BIOME_SHAPE { @Override - public int getColor(Cell cell, float scale, float bias) { + public int getColor(Cell cell, float scale, float bias) { float saturation = 0.7F; float brightness = 0.8F; return rgba(cell.biome, saturation, brightness); } }, - TERRAIN_TYPE { + REGION_SHAPE { @Override - public int getColor(Cell cell, float scale, float bias) { + public int getColor(Cell cell, float scale, float bias) { float saturation = 0.7F; float brightness = 0.8F; return rgba(cell.region, saturation, brightness); @@ -75,7 +74,7 @@ public enum RenderMode { }, ; - public int getColor(Cell cell, Levels levels) { + public int getColor(Cell cell, Levels levels) { float baseHeight = levels.water; if (cell.value < baseHeight) { return rgba(40, 140, 200); @@ -89,7 +88,7 @@ public enum RenderMode { return getColor(cell, scale, bias); } - public abstract int getColor(Cell cell, float scale, float bias); + public abstract int getColor(Cell cell, float scale, float bias); private static float step(float value, int steps) { return ((float) NoiseUtil.round(value * steps)) / steps; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/material/MaterialHelper.java b/src/main/java/com/terraforged/mod/material/MaterialHelper.java similarity index 98% rename from TerraForgedMod/src/main/java/com/terraforged/mod/material/MaterialHelper.java rename to src/main/java/com/terraforged/mod/material/MaterialHelper.java index fdc1360..a6e68c6 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/material/MaterialHelper.java +++ b/src/main/java/com/terraforged/mod/material/MaterialHelper.java @@ -26,7 +26,7 @@ package com.terraforged.mod.material; import com.google.common.collect.Sets; -import com.terraforged.core.util.concurrent.ObjectPool; +import com.terraforged.core.concurrent.ObjectPool; import com.terraforged.mod.util.DummyBlockReader; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/material/Materials.java b/src/main/java/com/terraforged/mod/material/Materials.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/material/Materials.java rename to src/main/java/com/terraforged/mod/material/Materials.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/material/geology/GeoGenerator.java b/src/main/java/com/terraforged/mod/material/geology/GeoGenerator.java similarity index 98% rename from TerraForgedMod/src/main/java/com/terraforged/mod/material/geology/GeoGenerator.java rename to src/main/java/com/terraforged/mod/material/geology/GeoGenerator.java index a8760b9..0c6ff2d 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/material/geology/GeoGenerator.java +++ b/src/main/java/com/terraforged/mod/material/geology/GeoGenerator.java @@ -28,7 +28,7 @@ package com.terraforged.mod.material.geology; import com.terraforged.api.material.WGTags; import com.terraforged.api.material.geology.StrataConfig; import com.terraforged.api.material.geology.StrataGenerator; -import com.terraforged.core.world.geology.Strata; +import com.terraforged.world.geology.Strata; import com.terraforged.mod.material.MaterialHelper; import com.terraforged.mod.material.Materials; import me.dags.noise.Source; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/material/geology/GeoManager.java b/src/main/java/com/terraforged/mod/material/geology/GeoManager.java similarity index 95% rename from TerraForgedMod/src/main/java/com/terraforged/mod/material/geology/GeoManager.java rename to src/main/java/com/terraforged/mod/material/geology/GeoManager.java index 2b6634b..92ed10b 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/material/geology/GeoManager.java +++ b/src/main/java/com/terraforged/mod/material/geology/GeoManager.java @@ -27,9 +27,9 @@ package com.terraforged.mod.material.geology; import com.terraforged.api.material.geology.GeologyManager; import com.terraforged.api.material.geology.StrataConfig; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.geology.Geology; -import com.terraforged.core.world.geology.Strata; +import com.terraforged.core.Seed; +import com.terraforged.world.geology.Geology; +import com.terraforged.world.geology.Strata; import com.terraforged.mod.chunk.TerraContext; import com.terraforged.mod.material.Materials; import me.dags.noise.Module; @@ -49,7 +49,7 @@ public class GeoManager implements GeologyManager { private final Map> specific = new HashMap<>(); public GeoManager(TerraContext context) { - int scale = context.settings.generator.land.regionSize / 2; + int scale = context.settings.terrain.general.terrainRegionSize / 2; this.selector = Source.cell(context.seed.next(), scale) .warp(context.seed.next(), scale / 4, 2, scale / 2D) .warp(context.seed.next(), 15, 2, 30); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/settings/DimesionSettings.java b/src/main/java/com/terraforged/mod/settings/DimesionSettings.java similarity index 86% rename from TerraForgedMod/src/main/java/com/terraforged/mod/settings/DimesionSettings.java rename to src/main/java/com/terraforged/mod/settings/DimesionSettings.java index 7290350..10214ce 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/settings/DimesionSettings.java +++ b/src/main/java/com/terraforged/mod/settings/DimesionSettings.java @@ -1,8 +1,8 @@ package com.terraforged.mod.settings; -import com.terraforged.core.util.serialization.annotation.Comment; -import com.terraforged.core.util.serialization.annotation.Range; -import com.terraforged.core.util.serialization.annotation.Serializable; +import com.terraforged.core.serialization.annotation.Comment; +import com.terraforged.core.serialization.annotation.Range; +import com.terraforged.core.serialization.annotation.Serializable; import com.terraforged.mod.TerraWorld; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.StringNBT; @@ -14,9 +14,9 @@ import org.jline.utils.Log; @Serializable public class DimesionSettings { - public BaseDecorator baseLayer = new BaseDecorator(); + public BaseDecorator bedrockLayer = new BaseDecorator(); - public DimensionGenerators dimensionGenerators = new DimensionGenerators(); + public DimensionGenerators dimensions = new DimensionGenerators(); @Serializable public static class BaseDecorator { diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/settings/FeatureSettings.java b/src/main/java/com/terraforged/mod/settings/Miscellaneous.java similarity index 91% rename from TerraForgedMod/src/main/java/com/terraforged/mod/settings/FeatureSettings.java rename to src/main/java/com/terraforged/mod/settings/Miscellaneous.java index 878f360..d68e17d 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/settings/FeatureSettings.java +++ b/src/main/java/com/terraforged/mod/settings/Miscellaneous.java @@ -25,11 +25,11 @@ package com.terraforged.mod.settings; -import com.terraforged.core.util.serialization.annotation.Comment; -import com.terraforged.core.util.serialization.annotation.Serializable; +import com.terraforged.core.serialization.annotation.Comment; +import com.terraforged.core.serialization.annotation.Serializable; @Serializable -public class FeatureSettings { +public class Miscellaneous { @Comment("Modifies layer block levels (ie snow) to fit the terrain") public boolean smoothLayerDecorator = true; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/settings/SettingsHelper.java b/src/main/java/com/terraforged/mod/settings/SettingsHelper.java similarity index 78% rename from TerraForgedMod/src/main/java/com/terraforged/mod/settings/SettingsHelper.java rename to src/main/java/com/terraforged/mod/settings/SettingsHelper.java index 86af287..78ec610 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/settings/SettingsHelper.java +++ b/src/main/java/com/terraforged/mod/settings/SettingsHelper.java @@ -29,22 +29,6 @@ public class SettingsHelper { public static final File SETTINGS_FILE= new File(SETTINGS_DIR, SETTINGS_FILE_NAME); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); - public static int getVersion(WorldInfo info) { - if (info.getGeneratorOptions().isEmpty()) { - // if options have not been set then the world has been created - // during the current runtime .: is not legacy - return TerraWorld.VERSION; - } - - CompoundNBT version = info.getGeneratorOptions().getCompound("version"); - if (version.isEmpty()) { - // version tag is absent in legacy worlds .: is legacy - return 0; - } - - return version.getInt("value"); - } - public static void clearDefaults() { if (SETTINGS_FILE.exists() && SETTINGS_FILE.delete()) { Log.info("Deleted generator defaults"); @@ -93,14 +77,7 @@ public class SettingsHelper { return settings; } - public static void syncSettings(WorldInfo info, TerraSettings settings, int version) { - settings.version = version; - settings.generator.seed = info.getSeed(); - CompoundNBT options = NBTHelper.serialize(settings); - info.setGeneratorOptions(options); - } - - public static void initSettings() { + public static void init() { if (SETTINGS_FILE.exists()) { return; } @@ -121,8 +98,4 @@ public class SettingsHelper { DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () -> exportDefaults(new TerraSettings())); } } - - private static void initServerSettings() { - DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () -> exportDefaults(new TerraSettings())); - } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/settings/StructureSettings.java b/src/main/java/com/terraforged/mod/settings/StructureSettings.java similarity index 52% rename from TerraForgedMod/src/main/java/com/terraforged/mod/settings/StructureSettings.java rename to src/main/java/com/terraforged/mod/settings/StructureSettings.java index 866fe53..8201e4d 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/settings/StructureSettings.java +++ b/src/main/java/com/terraforged/mod/settings/StructureSettings.java @@ -25,38 +25,45 @@ package com.terraforged.mod.settings; -import com.terraforged.core.util.serialization.annotation.Comment; -import com.terraforged.core.util.serialization.annotation.Range; -import com.terraforged.core.util.serialization.annotation.Serializable; +import com.terraforged.core.serialization.annotation.Comment; +import com.terraforged.core.serialization.annotation.Range; +import com.terraforged.core.serialization.annotation.Serializable; @Serializable public class StructureSettings { - @Range(min = 1, max = 10) - @Comment("Controls the distance between villages") - public int villageDistance = 2; + public Structure villages = new Structure(32, 8); - @Range(min = 1, max = 10) - @Comment("Controls the distance between mansions") - public int mansionDistance = 3; + public Structure mansions = new Structure(80, 20); - @Range(min = 1, max = 10) - @Comment("Controls the distance between strongholds") - public int strongholdDistance = 3; + public Structure strongholds = new Structure(32, 3); - @Range(min = 1, max = 10) - @Comment("Controls the distance between strongholds") - public int strongholdSpread = 3; + public Structure shipwrecks = new Structure(16, 8); - @Range(min = 1, max = 10) - @Comment("Controls the distance between biome structures") - public int biomeStructureDistance = 4; + public Structure oceanRuins = new Structure(16, 8); - @Range(min = 1, max = 10) - @Comment("Controls the distance between ocean monuments") - public int oceanMonumentSpacing = 3; + public Structure oceanMonuments = new Structure(32, 5); - @Range(min = 1, max = 10) - @Comment("Controls the separation between ocean monuments") - public int oceanMonumentSeparation = 3; + public Structure otherStructures = new Structure(32, 1); + + @Serializable + public static class Structure { + + @Range(min = 1, max = 200) + @Comment("The distance (in chunks) between placements of this feature") + public int distance; + + @Range(min = 1, max = 50) + @Comment("The separation (in chunks) between placements of this feature") + public int separation; + + public Structure() { + + } + + public Structure(int distance, int separation) { + this.distance = distance; + this.separation = separation; + } + } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/settings/TerraSettings.java b/src/main/java/com/terraforged/mod/settings/TerraSettings.java similarity index 89% rename from TerraForgedMod/src/main/java/com/terraforged/mod/settings/TerraSettings.java rename to src/main/java/com/terraforged/mod/settings/TerraSettings.java index e880506..30aad9e 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/settings/TerraSettings.java +++ b/src/main/java/com/terraforged/mod/settings/TerraSettings.java @@ -26,14 +26,12 @@ package com.terraforged.mod.settings; import com.terraforged.core.settings.Settings; -import com.terraforged.core.util.serialization.annotation.Serializable; +import com.terraforged.core.serialization.annotation.Serializable; @Serializable public class TerraSettings extends Settings { - public int version = 1; - - public FeatureSettings features = new FeatureSettings(); + public Miscellaneous features = new Miscellaneous(); public StructureSettings structures = new StructureSettings(); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/DataPackFinder.java b/src/main/java/com/terraforged/mod/util/DataPackFinder.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/DataPackFinder.java rename to src/main/java/com/terraforged/mod/util/DataPackFinder.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/DummyBlockReader.java b/src/main/java/com/terraforged/mod/util/DummyBlockReader.java similarity index 97% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/DummyBlockReader.java rename to src/main/java/com/terraforged/mod/util/DummyBlockReader.java index 00254c4..43c6d1e 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/util/DummyBlockReader.java +++ b/src/main/java/com/terraforged/mod/util/DummyBlockReader.java @@ -25,7 +25,7 @@ package com.terraforged.mod.util; -import com.terraforged.core.util.concurrent.ObjectPool; +import com.terraforged.core.concurrent.ObjectPool; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.fluid.FluidState; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/Environment.java b/src/main/java/com/terraforged/mod/util/Environment.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/Environment.java rename to src/main/java/com/terraforged/mod/util/Environment.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/ListUtils.java b/src/main/java/com/terraforged/mod/util/ListUtils.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/ListUtils.java rename to src/main/java/com/terraforged/mod/util/ListUtils.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/NBTLeavesFixer.java b/src/main/java/com/terraforged/mod/util/NBTLeavesFixer.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/NBTLeavesFixer.java rename to src/main/java/com/terraforged/mod/util/NBTLeavesFixer.java diff --git a/src/main/java/com/terraforged/mod/util/RangeModifier.java b/src/main/java/com/terraforged/mod/util/RangeModifier.java new file mode 100644 index 0000000..afdaeed --- /dev/null +++ b/src/main/java/com/terraforged/mod/util/RangeModifier.java @@ -0,0 +1,35 @@ +package com.terraforged.mod.util; + +public abstract class RangeModifier { + + protected final float min; + protected final float max; + private final float range; + + public RangeModifier(float min, float max) { + this.min = min; + this.max = max; + this.range = Math.abs(max - min); + } + + public float apply(float value) { + if (min < max) { + if (value <= min) { + return 0F; + } + if (value >= max) { + return 1F; + } + return (value - min) / range; + } else if (min > max) { + if (value <= min) { + return 1F; + } + if (value >= max) { + return 0F; + } + return 1F - (value / range); + } + return 1F; + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/annotation/Name.java b/src/main/java/com/terraforged/mod/util/annotation/Name.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/annotation/Name.java rename to src/main/java/com/terraforged/mod/util/annotation/Name.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/annotation/Ref.java b/src/main/java/com/terraforged/mod/util/annotation/Ref.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/annotation/Ref.java rename to src/main/java/com/terraforged/mod/util/annotation/Ref.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/nbt/NBTHelper.java b/src/main/java/com/terraforged/mod/util/nbt/NBTHelper.java similarity index 88% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/nbt/NBTHelper.java rename to src/main/java/com/terraforged/mod/util/nbt/NBTHelper.java index a2c486f..536261a 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/util/nbt/NBTHelper.java +++ b/src/main/java/com/terraforged/mod/util/nbt/NBTHelper.java @@ -28,7 +28,7 @@ package com.terraforged.mod.util.nbt; import com.google.gson.JsonElement; import com.mojang.datafixers.Dynamic; import com.mojang.datafixers.types.JsonOps; -import com.terraforged.core.util.serialization.serializer.Serializer; +import com.terraforged.core.serialization.serializer.Serializer; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.INBT; import net.minecraft.nbt.ListNBT; @@ -53,17 +53,14 @@ public class NBTHelper { return (CompoundNBT) output.getValue(); } - public static Stream stream(CompoundNBT tag) { - return tag.keySet().stream() - .map(tag::getCompound) - .sorted(Comparator.comparing(t -> t.getInt("#order"))); - + public static CompoundNBT serialize(Object object) { + return serialize("", object); } - public static CompoundNBT serialize(Object object) { + public static CompoundNBT serialize(String owner, Object object) { try { NBTWriter writer = new NBTWriter(); - writer.readFrom(object); + Serializer.serialize(object, writer, owner, true); return writer.compound(); } catch (IllegalAccessException e) { return new CompoundNBT(); @@ -91,6 +88,12 @@ public class NBTHelper { } } + public static Stream streamkeys(CompoundNBT compound) { + return compound.keySet().stream() + .filter(name -> !name.startsWith("#")) + .sorted(Comparator.comparing(name -> compound.getCompound("#" + name).getInt("order"))); + } + public static T stripMetadata(T tag) { if (tag instanceof CompoundNBT) { CompoundNBT compound = (CompoundNBT) tag; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/nbt/NBTReader.java b/src/main/java/com/terraforged/mod/util/nbt/NBTReader.java similarity index 97% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/nbt/NBTReader.java rename to src/main/java/com/terraforged/mod/util/nbt/NBTReader.java index 2ed5270..e634bf1 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/util/nbt/NBTReader.java +++ b/src/main/java/com/terraforged/mod/util/nbt/NBTReader.java @@ -25,7 +25,7 @@ package com.terraforged.mod.util.nbt; -import com.terraforged.core.util.serialization.serializer.Reader; +import com.terraforged.core.serialization.serializer.Reader; import net.minecraft.nbt.ByteNBT; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.FloatNBT; diff --git a/src/main/java/com/terraforged/mod/util/nbt/NBTWriter.java b/src/main/java/com/terraforged/mod/util/nbt/NBTWriter.java new file mode 100644 index 0000000..4e793f8 --- /dev/null +++ b/src/main/java/com/terraforged/mod/util/nbt/NBTWriter.java @@ -0,0 +1,66 @@ +package com.terraforged.mod.util.nbt; + +import com.terraforged.core.serialization.serializer.AbstractWriter; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.FloatNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.nbt.IntNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.StringNBT; + +public class NBTWriter extends AbstractWriter { + + public CompoundNBT compound() { + return (CompoundNBT) getRoot(); + } + + @Override + protected NBTWriter self() { + return this; + } + + @Override + protected boolean isObject(INBT value) { + return value instanceof CompoundNBT; + } + + @Override + protected boolean isArray(INBT value) { + return value instanceof ListNBT; + } + + @Override + protected void add(INBT parent, String key, INBT value) { + ((CompoundNBT) parent).put(key, value); + } + + @Override + protected void add(INBT parent, INBT value) { + ((ListNBT) parent).add(value); + } + + @Override + protected INBT createObject() { + return new CompoundNBT(); + } + + @Override + protected INBT createArray() { + return new ListNBT(); + } + + @Override + protected INBT create(String value) { + return StringNBT.valueOf(value); + } + + @Override + protected INBT create(int value) { + return IntNBT.valueOf(value); + } + + @Override + protected INBT create(float value) { + return FloatNBT.valueOf(value); + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/setup/SetupDebug.java b/src/main/java/com/terraforged/mod/util/setup/SetupDebug.java similarity index 100% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/setup/SetupDebug.java rename to src/main/java/com/terraforged/mod/util/setup/SetupDebug.java diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/util/setup/SetupHooks.java b/src/main/java/com/terraforged/mod/util/setup/SetupHooks.java similarity index 94% rename from TerraForgedMod/src/main/java/com/terraforged/mod/util/setup/SetupHooks.java rename to src/main/java/com/terraforged/mod/util/setup/SetupHooks.java index f533316..e3b28f9 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/util/setup/SetupHooks.java +++ b/src/main/java/com/terraforged/mod/util/setup/SetupHooks.java @@ -32,9 +32,9 @@ import com.terraforged.api.chunk.surface.SurfaceManager; import com.terraforged.api.event.SetupEvent; import com.terraforged.api.material.geology.GeologyManager; import com.terraforged.api.material.layer.LayerManager; -import com.terraforged.core.world.GeneratorContext; -import com.terraforged.core.world.terrain.provider.TerrainProvider; -import com.terraforged.feature.modifier.FeatureModifiers; +import com.terraforged.world.GeneratorContext; +import com.terraforged.world.terrain.provider.TerrainProvider; +import com.terraforged.mod.feature.manager.modifier.FeatureModifiers; import net.minecraftforge.common.MinecraftForge; import java.util.List; diff --git a/TerraForgedMod/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml similarity index 100% rename from TerraForgedMod/src/main/resources/META-INF/mods.toml rename to src/main/resources/META-INF/mods.toml diff --git a/TerraForgedMod/src/main/resources/biomes.txt b/src/main/resources/biomes.txt similarity index 100% rename from TerraForgedMod/src/main/resources/biomes.txt rename to src/main/resources/biomes.txt diff --git a/TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_clay.json b/src/main/resources/data/forge/tags/blocks/wg_clay.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_clay.json rename to src/main/resources/data/forge/tags/blocks/wg_clay.json diff --git a/TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_dirt.json b/src/main/resources/data/forge/tags/blocks/wg_dirt.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_dirt.json rename to src/main/resources/data/forge/tags/blocks/wg_dirt.json diff --git a/TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_erodible.json b/src/main/resources/data/forge/tags/blocks/wg_erodible.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_erodible.json rename to src/main/resources/data/forge/tags/blocks/wg_erodible.json diff --git a/TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_sediment.json b/src/main/resources/data/forge/tags/blocks/wg_sediment.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_sediment.json rename to src/main/resources/data/forge/tags/blocks/wg_sediment.json diff --git a/TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_stone.json b/src/main/resources/data/forge/tags/blocks/wg_stone.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_stone.json rename to src/main/resources/data/forge/tags/blocks/wg_stone.json diff --git a/src/main/resources/data/terraforged/blocks/saplings/birch_sapling.json b/src/main/resources/data/terraforged/blocks/saplings/birch_sapling.json new file mode 100644 index 0000000..6d605e7 --- /dev/null +++ b/src/main/resources/data/terraforged/blocks/saplings/birch_sapling.json @@ -0,0 +1,12 @@ +{ + "type": "terraforged:sapling", + "sapling": "minecraft:birch_sapling", + "normal": { + "terraforged:birch_small": { + "weight": 1 + }, + "terraforged:birch_large": { + "weight": 2 + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/terraforged/blocks/saplings/jungle_sapling.json b/src/main/resources/data/terraforged/blocks/saplings/jungle_sapling.json new file mode 100644 index 0000000..2bb6b3d --- /dev/null +++ b/src/main/resources/data/terraforged/blocks/saplings/jungle_sapling.json @@ -0,0 +1,17 @@ +{ + "type": "terraforged:sapling", + "sapling": "minecraft:jungle_sapling", + "normal": { + "terraforged:jungle_small": { + "weight": 2 + }, + "terraforged:jungle_large": { + "weight": 1 + } + }, + "giant": { + "terraforged:jungle_huge": { + "weight": 1 + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/terraforged/blocks/saplings/oak_sapling.json b/src/main/resources/data/terraforged/blocks/saplings/oak_sapling.json new file mode 100644 index 0000000..b3c43eb --- /dev/null +++ b/src/main/resources/data/terraforged/blocks/saplings/oak_sapling.json @@ -0,0 +1,12 @@ +{ + "type": "terraforged:sapling", + "sapling": "minecraft:oak_sapling", + "normal": { + "terraforged:oak_small": { + "weight": 2 + }, + "terraforged:oak_large": { + "weight": 1 + } + } +} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/ores/coal.json b/src/main/resources/data/terraforged/features/ores/coal.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/ores/coal.json rename to src/main/resources/data/terraforged/features/ores/coal.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/ores/diamond.json b/src/main/resources/data/terraforged/features/ores/diamond.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/ores/diamond.json rename to src/main/resources/data/terraforged/features/ores/diamond.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/ores/gold.json b/src/main/resources/data/terraforged/features/ores/gold.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/ores/gold.json rename to src/main/resources/data/terraforged/features/ores/gold.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/ores/gold_extra.json b/src/main/resources/data/terraforged/features/ores/gold_extra.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/ores/gold_extra.json rename to src/main/resources/data/terraforged/features/ores/gold_extra.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/ores/iron.json b/src/main/resources/data/terraforged/features/ores/iron.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/ores/iron.json rename to src/main/resources/data/terraforged/features/ores/iron.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/ores/lapis.json b/src/main/resources/data/terraforged/features/ores/lapis.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/ores/lapis.json rename to src/main/resources/data/terraforged/features/ores/lapis.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/ores/redstone.json b/src/main/resources/data/terraforged/features/ores/redstone.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/ores/redstone.json rename to src/main/resources/data/terraforged/features/ores/redstone.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/sediments/clay.json b/src/main/resources/data/terraforged/features/sediments/clay.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/sediments/clay.json rename to src/main/resources/data/terraforged/features/sediments/clay.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/sediments/dirt.json b/src/main/resources/data/terraforged/features/sediments/dirt.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/sediments/dirt.json rename to src/main/resources/data/terraforged/features/sediments/dirt.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/sediments/gravel.json b/src/main/resources/data/terraforged/features/sediments/gravel.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/sediments/gravel.json rename to src/main/resources/data/terraforged/features/sediments/gravel.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/shrubs/dead_bush.json b/src/main/resources/data/terraforged/features/shrubs/dead_bush.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/shrubs/dead_bush.json rename to src/main/resources/data/terraforged/features/shrubs/dead_bush.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/shrubs/forest_grass.json b/src/main/resources/data/terraforged/features/shrubs/forest_grass.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/features/shrubs/forest_grass.json rename to src/main/resources/data/terraforged/features/shrubs/forest_grass.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/acacia.json b/src/main/resources/data/terraforged/features/trees/acacia.json similarity index 60% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/acacia.json rename to src/main/resources/data/terraforged/features/trees/acacia.json index cf5e9ac..6b9f902 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/acacia.json +++ b/src/main/resources/data/terraforged/features/trees/acacia.json @@ -13,19 +13,25 @@ "config": { "features": [ { - "name": "terraforged:acacia_large", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:acacia_large" + }, "chance": 0.4 }, { - "name": "terraforged:acacia_small", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:acacia_small" + }, "chance": 0.15 } ], "default": { - "name": "terraforged:acacia_large", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:acacia_large" + } } } }, diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/birch.json b/src/main/resources/data/terraforged/features/trees/birch.json similarity index 50% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/birch.json rename to src/main/resources/data/terraforged/features/trees/birch.json index fea9e44..957fcd9 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/birch.json +++ b/src/main/resources/data/terraforged/features/trees/birch.json @@ -17,28 +17,36 @@ "config": { "features": [ { - "name": "terraforged:birch_forest", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:birch_forest" + }, "chance": 0.2 }, { - "name": "terraforged:birch_large", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:birch_large" + }, "chance": 0.2 } ], "default": { - "name": "terraforged:birch_forest", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:birch_forest" + } } } }, "decorator": { - "name": "minecraft:count_extra_heightmap", + "name": "terraforged:poisson_surface", "config": { - "count": 21, - "extra_chance": 0.1, - "extra_count": 1 + "radius": 9, + "fade": 0.25, + "scale": 300, + "min": 0, + "max": 2 } } } diff --git a/src/main/resources/data/terraforged/features/trees/birch_oak.json b/src/main/resources/data/terraforged/features/trees/birch_oak.json new file mode 100644 index 0000000..eb1820e --- /dev/null +++ b/src/main/resources/data/terraforged/features/trees/birch_oak.json @@ -0,0 +1,69 @@ +{ + "biomes": [ + "minecraft:wooded_hills" + ], + "match": [ + [ + "minecraft:birch_log", + "minecraft:birch_leaves", + "minecraft:oak_log", + "minecraft:oak_leaves" + ] + ], + "replace": { + "name": "minecraft:decorated", + "config": { + "feature": { + "name": "minecraft:random_selector", + "config": { + "features": [ + { + "name": "terraforged:template", + "config": { + "template": "terraforged:birch_forest" + }, + "chance": 0.2 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:birch_large" + }, + "chance": 0.2 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_forest" + }, + "chance": 0.2 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_large" + }, + "chance": 0.2 + } + ], + "default": { + "name": "terraforged:template", + "config": { + "template": "terraforged:birch_forest" + } + } + } + }, + "decorator": { + "name": "terraforged:poisson_surface", + "config": { + "radius": 8, + "fade": 0.35, + "scale": 300, + "min": 0, + "max": 2 + } + } + } + } +} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/dark_oak.json b/src/main/resources/data/terraforged/features/trees/dark_oak.json similarity index 78% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/dark_oak.json rename to src/main/resources/data/terraforged/features/trees/dark_oak.json index 5c82c0e..4c45cda 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/dark_oak.json +++ b/src/main/resources/data/terraforged/features/trees/dark_oak.json @@ -87,38 +87,50 @@ "chance": 0.05 }, { - "name": "terraforged:dark_oak_large", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:dark_oak_large" + }, "chance": 0.3 }, { - "name": "terraforged:dark_oak_small", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:dark_oak_small" + }, "chance": 0.2 }, { - "name": "terraforged:birch_forest", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:birch_forest" + }, "chance": 0.05 }, { - "name": "terraforged:oak_forest", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_forest" + }, "chance": 0.025 } ], "default": { - "name": "terraforged:dark_oak_large", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:dark_oak_large" + } } } }, "decorator": { - "name": "minecraft:count_extra_heightmap", + "name": "terraforged:poisson_surface", "config": { - "count": 10, - "extra_chance": 0.1, - "extra_count": 1 + "radius": 8, + "fade": 0.4, + "scale": 200, + "min": 0, + "max": 1.85 } } } diff --git a/src/main/resources/data/terraforged/features/trees/fir_foreset.json b/src/main/resources/data/terraforged/features/trees/fir_foreset.json new file mode 100644 index 0000000..5441002 --- /dev/null +++ b/src/main/resources/data/terraforged/features/trees/fir_foreset.json @@ -0,0 +1,65 @@ +{ + "biomes": [ + "terraforged:fir_forest", + "terraforged:snowy_fir_forest" + ], + "match": [ + [ + "minecraft:normal_tree", + "minecraft:spruce_log", + "minecraft:spruce_leaves" + ] + ], + "replace": { + "name": "minecraft:decorated", + "config": { + "feature": { + "name": "terraforged:context_selector", + "config": { + "features": [ + { + "feature": { + "name": "terraforged:template", + "config": { + "template": "terraforged:spruce_small" + } + }, + "context": { + "chance": 0.2, + "elevation": { + "min": 0.75, + "max": 0.25 + } + } + }, + { + "feature": { + "name": "terraforged:template", + "config": { + "template": "terraforged:spruce_large" + } + }, + "context": { + "chance": 0.2, + "elevation": { + "min": 0.5, + "max": 0.0 + } + } + } + ] + } + }, + "decorator": { + "name": "terraforged:poisson_surface", + "config": { + "radius": 6, + "fade": 0.3, + "scale": 200, + "min": 0, + "max": 2.5 + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/terraforged/features/trees/flower_forest.json b/src/main/resources/data/terraforged/features/trees/flower_forest.json new file mode 100644 index 0000000..97aae28 --- /dev/null +++ b/src/main/resources/data/terraforged/features/trees/flower_forest.json @@ -0,0 +1,69 @@ +{ + "biomes": [ + "minecraft:flower_forest" + ], + "match": [ + [ + "minecraft:birch_log", + "minecraft:birch_leaves", + "minecraft:oak_log", + "minecraft:oak_leaves" + ] + ], + "replace": { + "name": "minecraft:decorated", + "config": { + "feature": { + "name": "minecraft:random_selector", + "config": { + "features": [ + { + "name": "terraforged:template", + "config": { + "template": "terraforged:birch_forest" + }, + "chance": 0.2 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:birch_large" + }, + "chance": 0.2 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_forest" + }, + "chance": 0.2 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_large" + }, + "chance": 0.2 + } + ], + "default": { + "name": "terraforged:template", + "config": { + "template": "terraforged:birch_forest" + } + } + } + }, + "decorator": { + "name": "terraforged:poisson_surface", + "config": { + "radius": 15, + "fade": 0.3, + "scale": 500, + "min": 0.75, + "max": 2 + } + } + } + } +} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/jungle.json b/src/main/resources/data/terraforged/features/trees/jungle.json similarity index 68% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/jungle.json rename to src/main/resources/data/terraforged/features/trees/jungle.json index 791bfe7..214ea0f 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/jungle.json +++ b/src/main/resources/data/terraforged/features/trees/jungle.json @@ -17,18 +17,24 @@ "config": { "features": [ { - "name": "terraforged:jungle_small", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_small" + }, "chance": 0.2 }, { - "name": "terraforged:jungle_large", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_large" + }, "chance": 0.3 }, { - "name": "terraforged:jungle_huge", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_huge" + }, "chance": 0.4 }, { @@ -60,17 +66,21 @@ } ], "default": { - "name": "terraforged:jungle_small", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_small" + } } } }, "decorator": { - "name": "minecraft:count_extra_heightmap", + "name": "terraforged:poisson_surface", "config": { - "count": 15, - "extra_chance": 0.25, - "extra_count": 1 + "radius": 6, + "fade": 0.2, + "scale": 400, + "min": 0.25, + "max": 2 } } } diff --git a/src/main/resources/data/terraforged/features/trees/jungle_edge.json b/src/main/resources/data/terraforged/features/trees/jungle_edge.json new file mode 100644 index 0000000..935bd77 --- /dev/null +++ b/src/main/resources/data/terraforged/features/trees/jungle_edge.json @@ -0,0 +1,53 @@ +{ + "biomes": [ + "minecraft:jungle_edge", + "minecraft:modified_jungle_edge" + ], + "match": [ + [ + "minecraft:fancy_tree" + ] + ], + "replace": { + "name": "minecraft:decorated", + "config": { + "feature": { + "name": "minecraft:random_selector", + "config": { + "features": [ + { + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_small" + }, + "chance": 0.2 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_large" + }, + "chance": 0.3 + } + ], + "default": { + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_small" + } + } + } + }, + "decorator": { + "name": "terraforged:poisson_surface", + "config": { + "radius": 9, + "fade": 0.3, + "scale": 350, + "min": 0.75, + "max": 1.5 + } + } + } + } +} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/jungle_hills.json b/src/main/resources/data/terraforged/features/trees/jungle_hills.json similarity index 66% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/jungle_hills.json rename to src/main/resources/data/terraforged/features/trees/jungle_hills.json index 6e75e30..8fe9b88 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/jungle_hills.json +++ b/src/main/resources/data/terraforged/features/trees/jungle_hills.json @@ -16,19 +16,25 @@ "config": { "features": [ { - "name": "terraforged:jungle_small", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_small" + }, + "chance": 0.3 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_large" + }, "chance": 0.4 }, { - "name": "terraforged:jungle_large", - "config": {}, - "chance": 0.2 - }, - { - "name": "terraforged:jungle_huge", - "config": {}, - "chance": 0.05 + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_huge" + }, + "chance": 0.3 }, { "name": "minecraft:jungle_ground_bush", @@ -55,21 +61,25 @@ "decorators": [], "base_height": 4 }, - "chance": 0.3 + "chance": 0.2 } ], "default": { - "name": "terraforged:jungle_small", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:jungle_small" + } } } }, "decorator": { - "name": "minecraft:count_extra_heightmap", + "name": "terraforged:poisson_surface", "config": { - "count": 6, - "extra_chance": 0.25, - "extra_count": 1 + "radius": 8, + "fade": 0.2, + "scale": 200, + "min": 0.35, + "max": 1.85 } } } diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/oak_badlands.json b/src/main/resources/data/terraforged/features/trees/oak_badlands.json similarity index 73% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/oak_badlands.json rename to src/main/resources/data/terraforged/features/trees/oak_badlands.json index 6166a24..a2eb50d 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/oak_badlands.json +++ b/src/main/resources/data/terraforged/features/trees/oak_badlands.json @@ -19,14 +19,18 @@ "config": { "features": [ { - "name": "terraforged:oak_small", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_small" + }, "chance": 0.2 } ], "default": { - "name": "terraforged:oak_small", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_small" + } } } }, diff --git a/src/main/resources/data/terraforged/features/trees/oak_forest.json b/src/main/resources/data/terraforged/features/trees/oak_forest.json new file mode 100644 index 0000000..4881be2 --- /dev/null +++ b/src/main/resources/data/terraforged/features/trees/oak_forest.json @@ -0,0 +1,52 @@ +{ + "biomes": [ + "minecraft:forest" + ], + "match": [ + [ + "minecraft:oak_log", + "minecraft:oak_leaves" + ] + ], + "replace": { + "name": "minecraft:decorated", + "config": { + "feature": { + "name": "minecraft:random_selector", + "config": { + "features": [ + { + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_forest" + }, + "chance": 0.2 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_large" + }, + "chance": 0.3 + } + ], + "default": { + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_forest" + } + } + } + }, + "decorator": { + "name": "terraforged:poisson_surface", + "config": { + "radius": 9, + "scale": 150, + "min": 0.15, + "max": 1.75 + } + } + } + } +} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/oak_plains.json b/src/main/resources/data/terraforged/features/trees/oak_plains.json similarity index 52% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/oak_plains.json rename to src/main/resources/data/terraforged/features/trees/oak_plains.json index 777f214..ad4bd9f 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/oak_plains.json +++ b/src/main/resources/data/terraforged/features/trees/oak_plains.json @@ -1,19 +1,7 @@ { "biomes": [ "minecraft:plains", - "minecraft:sunflower_plains", - "minecraft:river", - "minecraft:frozen_river", - "minecraft:ocean", - "minecraft:deep_ocean", - "minecraft:warm_ocean", - "minecraft:deep_warm_ocean", - "minecraft:lukewarm_ocean", - "minecraft:deep_lukewarm_ocean", - "minecraft:cold_ocean", - "minecraft:deep_cold_ocean", - "minecraft:frozen_ocean", - "minecraft:deep_frozen_ocean" + "minecraft:river" ], "match": [ [ @@ -29,19 +17,25 @@ "config": { "features": [ { - "name": "terraforged:oak_huge", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_huge" + }, "chance": 0.1 }, { - "name": "terraforged:oak_small", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_small" + }, "chance": 0.2 } ], "default": { - "name": "terraforged:oak_small", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:oak_small" + } } } }, @@ -55,4 +49,4 @@ } } } -} +} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/pine.json b/src/main/resources/data/terraforged/features/trees/pine.json similarity index 58% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/pine.json rename to src/main/resources/data/terraforged/features/trees/pine.json index 119dacf..f38787b 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/pine.json +++ b/src/main/resources/data/terraforged/features/trees/pine.json @@ -19,23 +19,29 @@ "config": { "features": [ { - "name": "terraforged:pine", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:pine" + }, "chance": 0.3 } ], "default": { - "name": "terraforged:pine", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:pine" + } } } }, "decorator": { - "name": "minecraft:count_extra_heightmap", + "name": "terraforged:poisson_surface", "config": { - "count": 8, - "extra_chance": 0.1, - "extra_count": 1 + "radius": 10, + "fade": 0.25, + "scale": 250, + "min": 0.0, + "max": 2.75 } } } diff --git a/src/main/resources/data/terraforged/features/trees/redwood.json b/src/main/resources/data/terraforged/features/trees/redwood.json new file mode 100644 index 0000000..93b8260 --- /dev/null +++ b/src/main/resources/data/terraforged/features/trees/redwood.json @@ -0,0 +1,59 @@ +{ + "biomes": [ + "minecraft:*" + ], + "match": [ + [ + "minecraft:mega_spruce_tree" + ] + ], + "replace": { + "name": "minecraft:decorated", + "config": { + "feature": { + "name": "minecraft:random_selector", + "config": { + "features": [ + { + "name": "terraforged:template", + "config": { + "template": "terraforged:redwood_huge" + }, + "chance": 0.025641026 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:pine" + }, + "chance": 0.15 + }, + { + "name": "terraforged:template", + "config": { + "template": "terraforged:redwood_large" + }, + "chance": 0.33333334 + } + ], + "default": { + "name": "terraforged:template", + "config": { + "template": "terraforged:redwood_large" + } + } + } + }, + "decorator": { + "name": "terraforged:poisson_surface", + "config": { + "radius": 9, + "fade": 0.2, + "scale": 250, + "min": 0.15, + "max": 2.25 + } + } + } + } +} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/spruce.json b/src/main/resources/data/terraforged/features/trees/spruce.json similarity index 58% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/spruce.json rename to src/main/resources/data/terraforged/features/trees/spruce.json index ff1b679..d8809db 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/spruce.json +++ b/src/main/resources/data/terraforged/features/trees/spruce.json @@ -19,23 +19,29 @@ "config": { "features": [ { - "name": "terraforged:pine", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:pine" + }, "chance": 0.3 } ], "default": { - "name": "terraforged:pine", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:pine" + } } } }, "decorator": { - "name": "minecraft:count_extra_heightmap", + "name": "terraforged:poisson_surface", "config": { - "count": 8, - "extra_chance": 0.1, - "extra_count": 1 + "radius": 10, + "fade": 0.3, + "scale": 250, + "min": 0.15, + "max": 1.75 } } } diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/spruce_tundra.json b/src/main/resources/data/terraforged/features/trees/spruce_tundra.json similarity index 72% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/spruce_tundra.json rename to src/main/resources/data/terraforged/features/trees/spruce_tundra.json index b746237..cbb134f 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/spruce_tundra.json +++ b/src/main/resources/data/terraforged/features/trees/spruce_tundra.json @@ -18,14 +18,18 @@ "config": { "features": [ { - "name": "terraforged:pine", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:pine" + }, "chance": 0.3 } ], "default": { - "name": "terraforged:pine", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:pine" + } } } }, diff --git a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/willow.json b/src/main/resources/data/terraforged/features/trees/willow.json similarity index 64% rename from TerraForgedMod/src/main/resources/data/terraforged/features/trees/willow.json rename to src/main/resources/data/terraforged/features/trees/willow.json index ba31490..da35439 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/features/trees/willow.json +++ b/src/main/resources/data/terraforged/features/trees/willow.json @@ -19,19 +19,25 @@ "config": { "features": [ { - "name": "terraforged:willow_small", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:willow_small" + }, "chance": 0.2 }, { - "name": "terraforged:willow_large", - "config": {}, + "name": "terraforged:template", + "config": { + "template": "terraforged:willow_large" + }, "chance": 0.35 } ], "default": { - "name": "terraforged:willow_large", - "config": {} + "name": "terraforged:template", + "config": { + "template": "terraforged:willow_large" + } } } }, diff --git a/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_1.nbt b/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_2.nbt b/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_3.nbt b/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_4.nbt b/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_5.nbt b/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_5.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_7.nbt b/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_mushroom_7.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_musroom_6.nbt b/src/main/resources/data/terraforged/structures/mushrooms/brown/brown_musroom_6.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_1.nbt b/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_2.nbt b/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_3.nbt b/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_4.nbt b/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_5.nbt b/src/main/resources/data/terraforged/structures/mushrooms/red/red_mushroom_5.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/acacia/bush/acacia_bush_1.nbt b/src/main/resources/data/terraforged/structures/trees/acacia/bush/acacia_bush_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/acacia/bush/acacia_bush_2.nbt b/src/main/resources/data/terraforged/structures/trees/acacia/bush/acacia_bush_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/acacia/large/acacia_1.nbt b/src/main/resources/data/terraforged/structures/trees/acacia/large/acacia_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/acacia/large/acacia_2.nbt b/src/main/resources/data/terraforged/structures/trees/acacia/large/acacia_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/acacia/small/acacia_small_1.nbt b/src/main/resources/data/terraforged/structures/trees/acacia/small/acacia_small_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/acacia/small/acacia_small_2.nbt b/src/main/resources/data/terraforged/structures/trees/acacia/small/acacia_small_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_1.nbt b/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_2.nbt b/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_3.nbt b/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_4.nbt b/src/main/resources/data/terraforged/structures/trees/birch/forest/forest_birch_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/large/birch_1.nbt b/src/main/resources/data/terraforged/structures/trees/birch/large/birch_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/large/birch_2.nbt b/src/main/resources/data/terraforged/structures/trees/birch/large/birch_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/large/birch_3.nbt b/src/main/resources/data/terraforged/structures/trees/birch/large/birch_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/small/birch_bush_1.nbt b/src/main/resources/data/terraforged/structures/trees/birch/small/birch_bush_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/small/birch_bush_2.nbt b/src/main/resources/data/terraforged/structures/trees/birch/small/birch_bush_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/small/birch_small_1.nbt b/src/main/resources/data/terraforged/structures/trees/birch/small/birch_small_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/birch/small/birch_small_2.nbt b/src/main/resources/data/terraforged/structures/trees/birch/small/birch_small_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_1.nbt b/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_2.nbt b/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_3.nbt b/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_4.nbt b/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_5.nbt b/src/main/resources/data/terraforged/structures/trees/dark_oak/large/dark_oak_tall_5.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_1.nbt b/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_2.nbt b/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_3.nbt b/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_bush_1.nbt b/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_bush_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_bush_2.nbt b/src/main/resources/data/terraforged/structures/trees/dark_oak/small/dark_oak_bush_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_1.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_2.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_3.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_4.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_5.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_5.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_6.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/huge/jungle_massive_6.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_1.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_2.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_3.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_4.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/large/jungle_tall_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_1.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_2.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_3.nbt b/src/main/resources/data/terraforged/structures/trees/jungle/small/jungle_small_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/forest/forest_oak_1.nbt b/src/main/resources/data/terraforged/structures/trees/oak/forest/forest_oak_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/forest/forest_oak_2.nbt b/src/main/resources/data/terraforged/structures/trees/oak/forest/forest_oak_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/huge/oak_big_1.nbt b/src/main/resources/data/terraforged/structures/trees/oak/huge/oak_big_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/huge/oak_big_2.nbt b/src/main/resources/data/terraforged/structures/trees/oak/huge/oak_big_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/large/oak_1.nbt b/src/main/resources/data/terraforged/structures/trees/oak/large/oak_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/large/oak_2.nbt b/src/main/resources/data/terraforged/structures/trees/oak/large/oak_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/large/oak_3.nbt b/src/main/resources/data/terraforged/structures/trees/oak/large/oak_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/large/oak_4.nbt b/src/main/resources/data/terraforged/structures/trees/oak/large/oak_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/large/oak_5.nbt b/src/main/resources/data/terraforged/structures/trees/oak/large/oak_5.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/small/oak_bush_1.nbt b/src/main/resources/data/terraforged/structures/trees/oak/small/oak_bush_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/small/oak_bush_2.nbt b/src/main/resources/data/terraforged/structures/trees/oak/small/oak_bush_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_1.nbt b/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_2.nbt b/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_3.nbt b/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_4.nbt b/src/main/resources/data/terraforged/structures/trees/oak/small/oak_small_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_1.nbt b/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_2.nbt b/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_3.nbt b/src/main/resources/data/terraforged/structures/trees/pine/huangshan_pine_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_1.nbt b/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_2.nbt b/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_small_1.nbt b/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_small_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_small_2.nbt b/src/main/resources/data/terraforged/structures/trees/pine/scots_pine_small_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/pine/stone_pine_1.nbt b/src/main/resources/data/terraforged/structures/trees/pine/stone_pine_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/pine/stone_pine_2.nbt b/src/main/resources/data/terraforged/structures/trees/pine/stone_pine_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_1.nbt b/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_2.nbt b/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_3.nbt b/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_4.nbt b/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_5.nbt b/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_5.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_6.nbt b/src/main/resources/data/terraforged/structures/trees/redwood/huge/redwood_massive_6.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_1.nbt b/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_2.nbt b/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_3.nbt b/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_4.nbt b/src/main/resources/data/terraforged/structures/trees/redwood/large/redwood_tall_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/bush/spruce_bush_1.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/bush/spruce_bush_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/bush/spruce_bush_2.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/bush/spruce_bush_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_1.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_2.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_3.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_4.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_5.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/large/spruce_5.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_1.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_2.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_3.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_3.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_4.nbt b/src/main/resources/data/terraforged/structures/trees/spruce/small/spruce_small_4.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_1.nbt b/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_2.nbt b/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/willow/small/weeping_willow_small_1.nbt b/src/main/resources/data/terraforged/structures/trees/willow/small/weeping_willow_small_1.nbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/data/terraforged/structures/trees/willow/small/weeping_willow_small_2.nbt b/src/main/resources/data/terraforged/structures/trees/willow/small/weeping_willow_small_2.nbt new file mode 100644 index 0000000..e69de29 diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/alpine.json b/src/main/resources/data/terraforged/tags/biomes/alpine.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/alpine.json rename to src/main/resources/data/terraforged/tags/biomes/alpine.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/cold_steppe.json b/src/main/resources/data/terraforged/tags/biomes/cold_steppe.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/cold_steppe.json rename to src/main/resources/data/terraforged/tags/biomes/cold_steppe.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/desert.json b/src/main/resources/data/terraforged/tags/biomes/desert.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/desert.json rename to src/main/resources/data/terraforged/tags/biomes/desert.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/grassland.json b/src/main/resources/data/terraforged/tags/biomes/grassland.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/grassland.json rename to src/main/resources/data/terraforged/tags/biomes/grassland.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/savanna.json b/src/main/resources/data/terraforged/tags/biomes/savanna.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/savanna.json rename to src/main/resources/data/terraforged/tags/biomes/savanna.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/steppe.json b/src/main/resources/data/terraforged/tags/biomes/steppe.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/steppe.json rename to src/main/resources/data/terraforged/tags/biomes/steppe.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/taiga.json b/src/main/resources/data/terraforged/tags/biomes/taiga.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/taiga.json rename to src/main/resources/data/terraforged/tags/biomes/taiga.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/temperate_forest.json b/src/main/resources/data/terraforged/tags/biomes/temperate_forest.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/temperate_forest.json rename to src/main/resources/data/terraforged/tags/biomes/temperate_forest.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/temperate_rainforest.json b/src/main/resources/data/terraforged/tags/biomes/temperate_rainforest.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/temperate_rainforest.json rename to src/main/resources/data/terraforged/tags/biomes/temperate_rainforest.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/tropical_rainforest.json b/src/main/resources/data/terraforged/tags/biomes/tropical_rainforest.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/tropical_rainforest.json rename to src/main/resources/data/terraforged/tags/biomes/tropical_rainforest.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/tundra.json b/src/main/resources/data/terraforged/tags/biomes/tundra.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/biomes/tundra.json rename to src/main/resources/data/terraforged/tags/biomes/tundra.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/acacia_large.json b/src/main/resources/data/terraforged/templates/trees/acacia_large.json similarity index 60% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/acacia_large.json rename to src/main/resources/data/terraforged/templates/trees/acacia_large.json index 3d3c39b..4ef9117 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/acacia_large.json +++ b/src/main/resources/data/terraforged/templates/trees/acacia_large.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:acacia_large", "paths": [ "terraforged:trees/acacia/large" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/acacia_small.json b/src/main/resources/data/terraforged/templates/trees/acacia_small.json similarity index 67% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/acacia_small.json rename to src/main/resources/data/terraforged/templates/trees/acacia_small.json index 7fd1cab..9159f1d 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/acacia_small.json +++ b/src/main/resources/data/terraforged/templates/trees/acacia_small.json @@ -1,9 +1,12 @@ { "type": "tree", - "base": 3, "name": "terraforged:acacia_small", "paths": [ "terraforged:trees/acacia/small", "terraforged:trees/acacia/bush" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/src/main/resources/data/terraforged/templates/trees/birch_forest.json b/src/main/resources/data/terraforged/templates/trees/birch_forest.json new file mode 100644 index 0000000..ca616d7 --- /dev/null +++ b/src/main/resources/data/terraforged/templates/trees/birch_forest.json @@ -0,0 +1,23 @@ +{ + "type": "tree", + "name": "terraforged:birch_forest", + "paths": [ + "terraforged:trees/birch/forest" + ], + "config": { + "extend_base": 3, + "check_bounds": true + }, + "decorators": { + "default": { + "minecraft:beehive": { + "probability": 0.002 + } + }, + "minecraft:flower_forest": { + "minecraft:beehive": { + "probability": 0.02 + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/terraforged/templates/trees/birch_large.json b/src/main/resources/data/terraforged/templates/trees/birch_large.json new file mode 100644 index 0000000..2dfd97e --- /dev/null +++ b/src/main/resources/data/terraforged/templates/trees/birch_large.json @@ -0,0 +1,23 @@ +{ + "type": "tree", + "name": "terraforged:birch_large", + "paths": [ + "terraforged:trees/birch/large" + ], + "config": { + "extend_base": 3, + "check_bounds": true + }, + "decorators": { + "default": { + "minecraft:beehive": { + "probability": 0.002 + } + }, + "minecraft:flower_forest": { + "minecraft:beehive": { + "probability": 0.02 + } + } + } +} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/birch_small.json b/src/main/resources/data/terraforged/templates/trees/birch_small.json similarity index 60% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/birch_small.json rename to src/main/resources/data/terraforged/templates/trees/birch_small.json index 285f490..c5c80e0 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/birch_small.json +++ b/src/main/resources/data/terraforged/templates/trees/birch_small.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:birch_small", "paths": [ "terraforged:trees/birch/small" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/brown_mushroom.json b/src/main/resources/data/terraforged/templates/trees/brown_mushroom.json similarity index 69% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/brown_mushroom.json rename to src/main/resources/data/terraforged/templates/trees/brown_mushroom.json index 430485a..ea95b1d 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/brown_mushroom.json +++ b/src/main/resources/data/terraforged/templates/trees/brown_mushroom.json @@ -1,8 +1,10 @@ { "type": "tree", - "base": 0, "name": "terraforged:brown_mushroom", "paths": [ "terraforged:mushrooms/brown" - ] + ], + "config": { + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/dark_oak_large.json b/src/main/resources/data/terraforged/templates/trees/dark_oak_large.json similarity index 61% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/dark_oak_large.json rename to src/main/resources/data/terraforged/templates/trees/dark_oak_large.json index 0d08afb..a48e848 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/dark_oak_large.json +++ b/src/main/resources/data/terraforged/templates/trees/dark_oak_large.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:dark_oak_large", "paths": [ "terraforged:trees/dark_oak/large" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/dark_oak_small.json b/src/main/resources/data/terraforged/templates/trees/dark_oak_small.json similarity index 61% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/dark_oak_small.json rename to src/main/resources/data/terraforged/templates/trees/dark_oak_small.json index 1cab783..eb3b102 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/dark_oak_small.json +++ b/src/main/resources/data/terraforged/templates/trees/dark_oak_small.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:dark_oak_small", "paths": [ "terraforged:trees/dark_oak/small" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/jungle_huge.json b/src/main/resources/data/terraforged/templates/trees/jungle_huge.json similarity index 60% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/jungle_huge.json rename to src/main/resources/data/terraforged/templates/trees/jungle_huge.json index 9966e5b..c61262c 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/jungle_huge.json +++ b/src/main/resources/data/terraforged/templates/trees/jungle_huge.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:jungle_huge", "paths": [ "terraforged:trees/jungle/huge" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/jungle_large.json b/src/main/resources/data/terraforged/templates/trees/jungle_large.json similarity index 60% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/jungle_large.json rename to src/main/resources/data/terraforged/templates/trees/jungle_large.json index 2158117..47916e9 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/jungle_large.json +++ b/src/main/resources/data/terraforged/templates/trees/jungle_large.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:jungle_large", "paths": [ "terraforged:trees/jungle/large" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/jungle_small.json b/src/main/resources/data/terraforged/templates/trees/jungle_small.json similarity index 60% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/jungle_small.json rename to src/main/resources/data/terraforged/templates/trees/jungle_small.json index c242c73..31ce662 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/jungle_small.json +++ b/src/main/resources/data/terraforged/templates/trees/jungle_small.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:jungle_small", "paths": [ "terraforged:trees/jungle/small" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/src/main/resources/data/terraforged/templates/trees/oak_forest.json b/src/main/resources/data/terraforged/templates/trees/oak_forest.json new file mode 100644 index 0000000..5cca2a5 --- /dev/null +++ b/src/main/resources/data/terraforged/templates/trees/oak_forest.json @@ -0,0 +1,23 @@ +{ + "type": "tree", + "name": "terraforged:oak_forest", + "paths": [ + "terraforged:trees/oak/forest" + ], + "config": { + "extend_base": 3, + "check_bounds": true + }, + "decorators": { + "default": { + "minecraft:beehive": { + "probability": 0.002 + } + }, + "minecraft:flower_forest": { + "minecraft:beehive": { + "probability": 0.02 + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/terraforged/templates/trees/oak_huge.json b/src/main/resources/data/terraforged/templates/trees/oak_huge.json new file mode 100644 index 0000000..05f1b54 --- /dev/null +++ b/src/main/resources/data/terraforged/templates/trees/oak_huge.json @@ -0,0 +1,23 @@ +{ + "type": "tree", + "name": "terraforged:oak_huge", + "paths": [ + "terraforged:trees/oak/huge" + ], + "config": { + "extend_base": 3, + "check_bounds": true + }, + "decorators": { + "default": { + "minecraft:beehive": { + "probability": 0.002 + } + }, + "minecraft:flower_forest": { + "minecraft:beehive": { + "probability": 0.02 + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/terraforged/templates/trees/oak_large.json b/src/main/resources/data/terraforged/templates/trees/oak_large.json new file mode 100644 index 0000000..ee09c8f --- /dev/null +++ b/src/main/resources/data/terraforged/templates/trees/oak_large.json @@ -0,0 +1,23 @@ +{ + "type": "tree", + "name": "terraforged:oak_large", + "paths": [ + "terraforged:trees/oak/large" + ], + "config": { + "extend_base": 3, + "check_bounds": true + }, + "decorators": { + "default": { + "minecraft:beehive": { + "probability": 0.002 + } + }, + "minecraft:flower_forest": { + "minecraft:beehive": { + "probability": 0.02 + } + } + } +} \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_small.json b/src/main/resources/data/terraforged/templates/trees/oak_small.json similarity index 59% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_small.json rename to src/main/resources/data/terraforged/templates/trees/oak_small.json index cbb9289..087b1ec 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/oak_small.json +++ b/src/main/resources/data/terraforged/templates/trees/oak_small.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:oak_small", "paths": [ "terraforged:trees/oak/small" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/pine.json b/src/main/resources/data/terraforged/templates/trees/pine.json similarity index 57% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/pine.json rename to src/main/resources/data/terraforged/templates/trees/pine.json index 8ec0f47..853e5ae 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/pine.json +++ b/src/main/resources/data/terraforged/templates/trees/pine.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:pine", "paths": [ "terraforged:trees/pine" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/red_mushroom.json b/src/main/resources/data/terraforged/templates/trees/red_mushroom.json similarity index 59% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/red_mushroom.json rename to src/main/resources/data/terraforged/templates/trees/red_mushroom.json index 6e7882b..d8ea62e 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/red_mushroom.json +++ b/src/main/resources/data/terraforged/templates/trees/red_mushroom.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 0, "name": "terraforged:red_mushroom", "paths": [ "terraforged:mushrooms/red" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/redwood_huge.json b/src/main/resources/data/terraforged/templates/trees/redwood_huge.json similarity index 85% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/redwood_huge.json rename to src/main/resources/data/terraforged/templates/trees/redwood_huge.json index f84b835..eb39293 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/redwood_huge.json +++ b/src/main/resources/data/terraforged/templates/trees/redwood_huge.json @@ -1,10 +1,13 @@ { "type": "tree", - "base": 3, "name": "terraforged:redwood_huge", "paths": [ "terraforged:trees/redwood/huge" ], + "config": { + "extend_base": 3, + "check_bounds": true + }, "decorators": { "minecraft:alter_ground": { "provider": { diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/redwood_large.json b/src/main/resources/data/terraforged/templates/trees/redwood_large.json similarity index 61% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/redwood_large.json rename to src/main/resources/data/terraforged/templates/trees/redwood_large.json index c9c829c..47b9690 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/redwood_large.json +++ b/src/main/resources/data/terraforged/templates/trees/redwood_large.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:redwood_large", "paths": [ "terraforged:trees/redwood/large" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/spruce_large.json b/src/main/resources/data/terraforged/templates/trees/spruce_large.json similarity index 60% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/spruce_large.json rename to src/main/resources/data/terraforged/templates/trees/spruce_large.json index 4738b7b..c11388b 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/spruce_large.json +++ b/src/main/resources/data/terraforged/templates/trees/spruce_large.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:spruce_large", "paths": [ "terraforged:trees/spruce/large" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/spruce_small.json b/src/main/resources/data/terraforged/templates/trees/spruce_small.json similarity index 67% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/spruce_small.json rename to src/main/resources/data/terraforged/templates/trees/spruce_small.json index 1e0c950..0ed96cf 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/spruce_small.json +++ b/src/main/resources/data/terraforged/templates/trees/spruce_small.json @@ -1,9 +1,12 @@ { "type": "tree", - "base": 3, "name": "terraforged:spruce_small", "paths": [ "terraforged:trees/spruce/small", "terraforged:trees/spruce/bush" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/willow_large.json b/src/main/resources/data/terraforged/templates/trees/willow_large.json similarity index 60% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/willow_large.json rename to src/main/resources/data/terraforged/templates/trees/willow_large.json index 467ae54..477b8b4 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/willow_large.json +++ b/src/main/resources/data/terraforged/templates/trees/willow_large.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:willow_large", "paths": [ "terraforged:trees/willow/large" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/willow_small.json b/src/main/resources/data/terraforged/templates/trees/willow_small.json similarity index 60% rename from TerraForgedMod/src/main/resources/data/terraforged/templates/trees/willow_small.json rename to src/main/resources/data/terraforged/templates/trees/willow_small.json index 1de4946..8014327 100644 --- a/TerraForgedMod/src/main/resources/data/terraforged/templates/trees/willow_small.json +++ b/src/main/resources/data/terraforged/templates/trees/willow_small.json @@ -1,8 +1,11 @@ { "type": "tree", - "base": 3, "name": "terraforged:willow_small", "paths": [ "terraforged:trees/willow/small" - ] + ], + "config": { + "extend_base": 3, + "check_bounds": true + } } \ No newline at end of file diff --git a/TerraForgedAPI/src/main/resources/license.txt b/src/main/resources/license.txt similarity index 100% rename from TerraForgedAPI/src/main/resources/license.txt rename to src/main/resources/license.txt diff --git a/TerraForgedMod/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta similarity index 100% rename from TerraForgedMod/src/main/resources/pack.mcmeta rename to src/main/resources/pack.mcmeta diff --git a/TerraForgedMod/psd/terraforged.png b/src/main/resources/terraforged.png similarity index 100% rename from TerraForgedMod/psd/terraforged.png rename to src/main/resources/terraforged.png