From e0a5ecc156c1f846ce6c395542a4dab0e37ed91b Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Wed, 15 Jan 2020 22:34:02 -0500 Subject: [PATCH] RTP Fixes --- .../java/ninja/bytecode/iris/CommandIris.java | 20 ++++- .../java/ninja/bytecode/iris/Settings.java | 2 +- .../iris/generator/IrisGenerator.java | 39 ++++++++- .../bytecode/iris/generator/IrisSample.java | 81 +++++++++++++++++++ .../ninja/bytecode/iris/pack/IrisBiome.java | 17 +++- .../ninja/bytecode/iris/util/ChunkPlan.java | 34 ++++++-- .../iris/util/ParallelChunkGenerator.java | 5 +- 7 files changed, 181 insertions(+), 17 deletions(-) create mode 100644 src/main/java/ninja/bytecode/iris/generator/IrisSample.java diff --git a/src/main/java/ninja/bytecode/iris/CommandIris.java b/src/main/java/ninja/bytecode/iris/CommandIris.java index 788da8384..6dc29d276 100644 --- a/src/main/java/ninja/bytecode/iris/CommandIris.java +++ b/src/main/java/ninja/bytecode/iris/CommandIris.java @@ -75,6 +75,7 @@ public class CommandIris implements CommandExecutor { msg(sender, "Looking for " + b.getName() + "..."); boolean f = false; + int t = 0; for(int i = 0; i < 10000; i++) { int x = (int) ((int) (29999983 / 1.2) * Math.random()); @@ -83,8 +84,23 @@ public class CommandIris implements CommandExecutor if(g.getBiome(x, z).equals(b)) { f = true; - p.teleport(w.getHighestBlockAt(x, z).getLocation()); - break; + + if(w.getHighestBlockYAt(x, z) > 66) + { + p.teleport(w.getHighestBlockAt(x, z).getLocation()); + break; + } + + else + { + t++; + + if(t > 30) + { + msg(sender, "Checked 30 " + b.getName() + " bearing chunks. All of them were underwater. Try Again!"); + break; + } + } } } diff --git a/src/main/java/ninja/bytecode/iris/Settings.java b/src/main/java/ninja/bytecode/iris/Settings.java index 762bdf59f..b6929625d 100644 --- a/src/main/java/ninja/bytecode/iris/Settings.java +++ b/src/main/java/ninja/bytecode/iris/Settings.java @@ -40,7 +40,7 @@ public class Settings public double caveDensity = 4; public double caveScale = 1.45; public double biomeScale = 2; - public boolean flatBedrock = false; + public boolean flatBedrock = true; public boolean genObjects = true; public boolean genCarving = true; public boolean genCaverns = true; diff --git a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java index ce359eb3d..6dfa1db48 100644 --- a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java @@ -174,14 +174,24 @@ public class IrisGenerator extends ParallelChunkGenerator return biomeCache.get(name); } + public double getOffsetX(double x) + { + return Math.round((double) x * (Iris.settings.gen.horizontalZoom / 1.90476190476)); + } + + public double getOffsetZ(double z) + { + return Math.round((double) z * (Iris.settings.gen.horizontalZoom / 1.90476190476)); + } + @Override public Biome genColumn(int wxx, int wzx, int x, int z, ChunkPlan plan) { //@builder int highest = 0; int seaLevel = Iris.settings.gen.seaLevel; - double wx = Math.round((double) wxx * (Iris.settings.gen.horizontalZoom / 1.90476190476)); - double wz = Math.round((double) wzx * (Iris.settings.gen.horizontalZoom / 1.90476190476)); + double wx = getOffsetX(wxx); + double wz = getOffsetZ(wzx); IrisBiome biome = getBiome(wxx, wzx); double hv = IrisInterpolation.getNoise(wxx, wzx, Iris.settings.gen.hermiteSampleRadius, @@ -260,11 +270,13 @@ public class IrisGenerator extends ParallelChunkGenerator { if(j == snowHeight - 1) { + highest = highest < j ? j : highest; setBlock(x, i + j + 1, z, Material.SNOW, (byte) layers); } else { + highest = highest < j + 1 ? j + 1 : highest; setBlock(x, i + j + 1, z, Material.SNOW_BLOCK); } } @@ -299,7 +311,28 @@ public class IrisGenerator extends ParallelChunkGenerator glCaves.genCaves(wxx, wzx, x, z, height, this); glCarving.genCarves(wxx, wzx, x, z, height, this, biome); glCaverns.genCaverns(wxx, wzx, x, z, height, this, biome); - plan.setRealHeight(x, z, highest); + int hw = 0; + int hl = 0; + + for(int i = highest; i > 0; i--) + { + Material t = getType(x, i, z); + + if(i > seaLevel && hw == 0 && (t.equals(Material.WATER) || t.equals(Material.STATIONARY_WATER))) + { + hw = i; + } + + else if(hl == 0 && !t.equals(Material.AIR)) + { + hl = i; + } + } + + plan.setRealHeight(x, z, hl); + plan.setRealWaterHeight(x, z, hw == 0 ? seaLevel : hw); + plan.setBiome(x, z, biome); + return biome.getRealBiome(); } diff --git a/src/main/java/ninja/bytecode/iris/generator/IrisSample.java b/src/main/java/ninja/bytecode/iris/generator/IrisSample.java new file mode 100644 index 000000000..40afbc7bb --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/generator/IrisSample.java @@ -0,0 +1,81 @@ +package ninja.bytecode.iris.generator; + +import ninja.bytecode.iris.pack.IrisBiome; +import ninja.bytecode.iris.util.MB; + +public class IrisSample +{ + public MB surface; + public int height; + public IrisBiome biome; + + public MB getSurface() + { + return surface; + } + + public void setSurface(MB surface) + { + this.surface = surface; + } + + public int getHeight() + { + return height; + } + + public void setHeight(int height) + { + this.height = height; + } + + public IrisBiome getBiome() + { + return biome; + } + + public void setBiome(IrisBiome biome) + { + this.biome = biome; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((biome == null) ? 0 : biome.hashCode()); + result = prime * result + height; + result = prime * result + ((surface == null) ? 0 : surface.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if(this == obj) + return true; + if(obj == null) + return false; + if(getClass() != obj.getClass()) + return false; + IrisSample other = (IrisSample) obj; + if(biome == null) + { + if(other.biome != null) + return false; + } + else if(!biome.equals(other.biome)) + return false; + if(height != other.height) + return false; + if(surface == null) + { + if(other.surface != null) + return false; + } + else if(!surface.equals(other.surface)) + return false; + return true; + } +} diff --git a/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java b/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java index bba3d2af2..e46b98b5a 100644 --- a/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java +++ b/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java @@ -141,13 +141,24 @@ public class IrisBiome J.attempt(() -> scatterSurface = o.getString("surfaceType").equalsIgnoreCase("scatter")); J.attempt(() -> { - schematicGroups = strFromJSON(o.getJSONArray("objects")); + if(Iris.settings.gen.genObjects) + { + schematicGroups = strFromJSON(o.getJSONArray("objects")); + } + + else + { + schematicGroups = new GMap<>(); + } if(chain) { - for(String i : schematicGroups.k()) + if(Iris.settings.gen.genObjects) { - Iris.getController(PackController.class).loadSchematicGroup(i); + for(String i : schematicGroups.k()) + { + Iris.getController(PackController.class).loadSchematicGroup(i); + } } } }); diff --git a/src/main/java/ninja/bytecode/iris/util/ChunkPlan.java b/src/main/java/ninja/bytecode/iris/util/ChunkPlan.java index 71b5d4c2e..2dd5e8b31 100644 --- a/src/main/java/ninja/bytecode/iris/util/ChunkPlan.java +++ b/src/main/java/ninja/bytecode/iris/util/ChunkPlan.java @@ -6,12 +6,14 @@ import ninja.bytecode.shuriken.collections.GMap; public class ChunkPlan { private final GMap realHeightCache; + private final GMap realWaterHeightCache; private final GMap heightCache; private final GMap biomeCache; public ChunkPlan() { this.realHeightCache = new GMap<>(); + this.realWaterHeightCache = new GMap<>(); this.heightCache = new GMap<>(); this.biomeCache = new GMap<>(); } @@ -48,6 +50,18 @@ public class ChunkPlan return 0; } + public int getRealWaterHeight(int x, int z) + { + ChunkedVector c = new ChunkedVector(x, z); + + if(realWaterHeightCache.containsKey(c)) + { + return realWaterHeightCache.get(c); + } + + return 0; + } + public boolean hasHeight(ChunkedVector c) { return heightCache.containsKey(c); @@ -68,13 +82,23 @@ public class ChunkPlan realHeightCache.put(c, h); } - public void setHeight(int x, int z, double h) - { - setHeight(new ChunkedVector(x, z), h); - } - public void setRealHeight(int x, int z, int h) { setRealHeight(new ChunkedVector(x, z), h); } + + public void setRealWaterHeight(ChunkedVector c, int h) + { + realWaterHeightCache.put(c, h); + } + + public void setRealWaterHeight(int x, int z, int h) + { + setRealWaterHeight(new ChunkedVector(x, z), h); + } + + public void setHeight(int x, int z, double h) + { + setHeight(new ChunkedVector(x, z), h); + } } diff --git a/src/main/java/ninja/bytecode/iris/util/ParallelChunkGenerator.java b/src/main/java/ninja/bytecode/iris/util/ParallelChunkGenerator.java index 41884e11d..e05f932e7 100644 --- a/src/main/java/ninja/bytecode/iris/util/ParallelChunkGenerator.java +++ b/src/main/java/ninja/bytecode/iris/util/ParallelChunkGenerator.java @@ -99,7 +99,7 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator } } } - + return data.toChunkData(); } @@ -113,10 +113,9 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator public abstract void decorateColumn(int wx, int wz, int x, int z, ChunkPlan plan); - @SuppressWarnings("deprecation") public void setBlock(int x, int y, int z, Material b) { - setBlock(x, y, z, b.getId(), (byte) 0); + setBlock(x, y, z, b, (byte) 0); } @SuppressWarnings("deprecation")