diff --git a/src/main/java/com/volmit/iris/gen/CeilingChunkGenerator.java b/src/main/java/com/volmit/iris/gen/CeilingChunkGenerator.java deleted file mode 100644 index c22757fbd..000000000 --- a/src/main/java/com/volmit/iris/gen/CeilingChunkGenerator.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.volmit.iris.gen; - -import org.bukkit.Material; -import org.bukkit.block.data.BlockData; - -import com.volmit.iris.object.IrisDimension; -import com.volmit.iris.util.InvertedBiomeGrid; -import com.volmit.iris.util.RNG; - -public abstract class CeilingChunkGenerator extends PostBlockChunkGenerator -{ - protected boolean generatingCeiling = false; - protected boolean ceilingCached = false; - protected IrisDimension cacheCeiling = null; - protected IrisDimension cacheFloor = null; - - public CeilingChunkGenerator(String dimensionName, int threads) - { - super(dimensionName, threads); - } - - @Override - protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid) - { - targetFloor(); - generate(random, x, z, data, grid); - - if(getFloorDimension().isMirrorCeiling()) - { - writeInverted(copy(data), data); - } - - else if(getCeilingDimension() != null) - { - ChunkData ceiling = createChunkData(world); - InvertedBiomeGrid ceilingGrid = new InvertedBiomeGrid(grid); - targetCeiling(); - generate(random, x, z, ceiling, ceilingGrid); - writeInverted(ceiling, data); - } - } - - @Override - public void onHotload() - { - super.onHotload(); - ceilingCached = false; - cacheCeiling = null; - cacheFloor = null; - getCache().targetChunk(0, 0); - } - - private void targetFloor() - { - generatingCeiling = false; - } - - private void targetCeiling() - { - generatingCeiling = true; - } - - private void generate(RNG random, int x, int z, ChunkData ceiling, BiomeGrid grid) - { - super.onGenerate(random, x, z, ceiling, grid); - } - - @Override - public IrisDimension getDimension() - { - return generatingCeiling ? getCeilingDimension() : getFloorDimension(); - } - - public IrisDimension getFloorDimension() - { - if(cacheFloor != null) - { - return cacheFloor; - } - - return cacheFloor = super.getDimension(); - } - - public IrisDimension getCeilingDimension() - { - if(ceilingCached) - { - return cacheCeiling; - } - - if(getFloorDimension().getCeiling().isEmpty()) - { - return null; - } - - IrisDimension c = loadDimension(getFloorDimension().getCeiling()); - - if(c != null) - { - c.setInverted(true); - } - - ceilingCached = true; - cacheCeiling = c; - - return c; - } - - public void writeInverted(ChunkData data, ChunkData into) - { - for(int i = 0; i < 16; i++) - { - for(int j = 0; j < data.getMaxHeight(); j++) - { - for(int k = 0; k < 16; k++) - { - BlockData b = data.getBlockData(i, j, k); - - if(b == null || b.getMaterial().equals(Material.AIR)) - { - continue; - } - - into.setBlock(i, data.getMaxHeight() - j, k, b); - } - } - } - } - - public ChunkData copy(ChunkData d) - { - ChunkData copy = createChunkData(world); - - for(int i = 0; i < 16; i++) - { - for(int j = 0; j < d.getMaxHeight(); j++) - { - for(int k = 0; k < 16; k++) - { - BlockData b = d.getBlockData(i, j, k); - - if(b == null || b.getMaterial().equals(Material.AIR)) - { - continue; - } - - copy.setBlock(i, j, k, b); - } - } - } - - return copy; - } -} diff --git a/src/main/java/com/volmit/iris/gen/IrisChunkGenerator.java b/src/main/java/com/volmit/iris/gen/IrisChunkGenerator.java index 9cf163988..9e6bc29f1 100644 --- a/src/main/java/com/volmit/iris/gen/IrisChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/IrisChunkGenerator.java @@ -30,7 +30,7 @@ import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) -public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisContext +public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisContext { private Method initLighting; private IrisLock lock; @@ -139,11 +139,8 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon try { parallaxMap.saveAll(); - ceilingParallaxMap.saveAll(); parallaxMap.getLoadedChunks().clear(); parallaxMap.getLoadedRegions().clear(); - ceilingParallaxMap.getLoadedChunks().clear(); - ceilingParallaxMap.getLoadedRegions().clear(); } catch(IOException e) @@ -152,7 +149,6 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon } setAvailableFilters(null); - setCeilingSliverCache(null); setSliverCache(null); Iris.info("Closing Iris Dimension " + getWorld().getName()); } @@ -217,14 +213,8 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon bytes += i.guessMemoryUsage(); } - for(AtomicRegionData i : ceilingParallaxMap.getLoadedRegions().values()) - { - bytes += i.guessMemoryUsage(); - } - bytes += getCache().getSize() * 65; bytes += parallaxMap.getLoadedChunks().size() * 256 * 4 * 460; - bytes += ceilingParallaxMap.getLoadedChunks().size() * 256 * 4 * 460; bytes += getSliverBuffer() * 220; bytes += 823 * getData().getObjectLoader().getTotalStorage(); diff --git a/src/main/java/com/volmit/iris/gen/ParallaxChunkGenerator.java b/src/main/java/com/volmit/iris/gen/ParallaxChunkGenerator.java index 23f5e6bbd..172f9b263 100644 --- a/src/main/java/com/volmit/iris/gen/ParallaxChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/ParallaxChunkGenerator.java @@ -37,8 +37,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple { protected KMap sliverCache; protected AtomicWorldData parallaxMap; - protected KMap ceilingSliverCache; - protected AtomicWorldData ceilingParallaxMap; private MasterLock masterLock; private IrisLock lock = new IrisLock("ParallaxLock"); private IrisLock lockq = new IrisLock("ParallaxQueueLock"); @@ -48,7 +46,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple { super(dimensionName, threads); sliverCache = new KMap<>(); - ceilingSliverCache = new KMap<>(); sliverBuffer = 0; masterLock = new MasterLock(); } @@ -57,12 +54,11 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple { super.onInit(world, rng); parallaxMap = new AtomicWorldData(world, "floor"); - ceilingParallaxMap = new AtomicWorldData(world, "ceiling"); } protected KMap getSliverCache() { - return getDimension().isInverted() ? ceilingSliverCache : sliverCache; + return sliverCache; } protected void onClose() @@ -72,7 +68,6 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple try { parallaxMap.unloadAll(true); - ceilingParallaxMap.unloadAll(true); } catch(IOException e) @@ -150,7 +145,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple public AtomicWorldData getParallaxMap() { - return getDimension().isInverted() ? ceilingParallaxMap : parallaxMap; + return parallaxMap; } public AtomicSliverMap getParallaxChunk(int x, int z) diff --git a/src/main/java/com/volmit/iris/gen/PostBlockChunkGenerator.java b/src/main/java/com/volmit/iris/gen/PostBlockChunkGenerator.java index 31fcf0698..17980f0b8 100644 --- a/src/main/java/com/volmit/iris/gen/PostBlockChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/PostBlockChunkGenerator.java @@ -4,7 +4,6 @@ import org.bukkit.World; import org.bukkit.block.data.BlockData; import com.volmit.iris.Iris; -import com.volmit.iris.object.IrisDimension; import com.volmit.iris.util.CaveResult; import com.volmit.iris.util.IPostBlockAccess; import com.volmit.iris.util.IrisLock; @@ -18,36 +17,35 @@ import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) -public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator implements IPostBlockAccess { - protected boolean generatingCeiling = false; - protected boolean ceilingCached = false; - protected IrisDimension cacheCeiling = null; - protected IrisDimension cacheFloor = null; - private int currentPostX; - private int currentPostZ; - private ChunkData currentData; +public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator implements IPostBlockAccess +{ private KList availableFilters; private String postKey; private IrisLock lock; private int minPhase; private int maxPhase; - public PostBlockChunkGenerator(String dimensionName, int threads) { + public PostBlockChunkGenerator(String dimensionName, int threads) + { super(dimensionName, threads); availableFilters = new KList<>(); postKey = "post-" + dimensionName; lock = new IrisLock("PostChunkGenerator"); } - public void onInit(World world, RNG rng) { + public void onInit(World world, RNG rng) + { super.onInit(world, rng); - for (Class i : Iris.postProcessors) { - try { + for(Class i : Iris.postProcessors) + { + try + { availableFilters.add(i.getConstructor(PostBlockChunkGenerator.class).newInstance(this)); } - catch (Throwable e) { + catch(Throwable e) + { Iris.error("Failed to initialize post processor: " + i.getCanonicalName()); fail(e); } @@ -55,33 +53,39 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp } @Override - protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid) { + protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid) + { super.onGenerate(random, x, z, data, grid); - if (!getDimension().isPostProcessing()) { + if(!getDimension().isPostProcessing()) + { return; } KList filters = getDimension().getPostBlockProcessors(this); - currentData = data; - currentPostX = x; - currentPostZ = z; + int rx, i, j; PrecisionStopwatch p = PrecisionStopwatch.start(); - for (int h = getMinPhase(); h <= getMaxPhase(); h++) { - for (i = 0; i < 16; i++) { + for(int h = getMinPhase(); h <= getMaxPhase(); h++) + { + for(i = 0; i < 16; i++) + { rx = (x << 4) + i; - for (j = 0; j < 16; j++) { + for(j = 0; j < 16; j++) + { int rxx = rx; int rzz = (z << 4) + j; int hh = h; - getAccelerant().queue("post", () -> { - for (IrisPostBlockFilter f : filters) { - if (f.getPhase() == hh) { - f.onPost(rxx, rzz); + getAccelerant().queue("post", () -> + { + for(IrisPostBlockFilter f : filters) + { + if(f.getPhase() == hh) + { + f.onPost(rxx, rzz, x, z, data); } } }); @@ -90,14 +94,19 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp getAccelerant().waitFor("post"); - for (IrisPostBlockFilter f : filters) { - if (f.getPhase() == h) { - while (f.getQueue().size() > 0) { - try { + for(IrisPostBlockFilter f : filters) + { + if(f.getPhase() == h) + { + while(f.getQueue().size() > 0) + { + try + { f.getQueue().pop().run(); } - catch (Throwable e) { + catch(Throwable e) + { } } @@ -109,15 +118,19 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp getMetrics().getPost().put(p.getMilliseconds()); } - public IrisPostBlockFilter createProcessor(String processor, int phase) { - for (IrisPostBlockFilter i : availableFilters) { - if (i.getKey().equals(processor)) { - try { - return i.getClass().getConstructor(PostBlockChunkGenerator.class, int.class).newInstance(this, - phase); + public IrisPostBlockFilter createProcessor(String processor, int phase) + { + for(IrisPostBlockFilter i : availableFilters) + { + if(i.getKey().equals(processor)) + { + try + { + return i.getClass().getConstructor(PostBlockChunkGenerator.class, int.class).newInstance(this, phase); } - catch (Throwable e) { + catch(Throwable e) + { Iris.error("Failed initialize find post processor: " + processor); fail(e); } @@ -130,13 +143,16 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp } @Override - public void updateHeight(int x, int z, int h) { + public void updateHeight(int x, int z, int h) + { getCache().updateHeight(x, z, h); } @Override - public BlockData getPostBlock(int x, int y, int z) { - if (x >> 4 == currentPostX && z >> 4 == currentPostZ) { + public BlockData getPostBlock(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) + { + if(x >> 4 == currentPostX && z >> 4 == currentPostZ) + { lock.lock(); BlockData d = currentData.getBlockData(x & 15, y, z & 15); lock.unlock(); @@ -147,31 +163,36 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp } @Override - public void setPostBlock(int x, int y, int z, BlockData d) { - if (x >> 4 == currentPostX && z >> 4 == currentPostZ) { + public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, ChunkData currentData) + { + if(x >> 4 == currentPostX && z >> 4 == currentPostZ) + { lock.lock(); currentData.setBlock(x & 15, y, z & 15, d); lock.unlock(); } - else { - Iris.warn("Post Block Overdraw: " + currentPostX + "," + currentPostZ + " into " + (x >> 4) + ", " - + (z >> 4)); + else + { + Iris.warn("Post Block Overdraw: " + currentPostX + "," + currentPostZ + " into " + (x >> 4) + ", " + (z >> 4)); } } @Override - public int highestTerrainOrFluidBlock(int x, int z) { + public int highestTerrainOrFluidBlock(int x, int z) + { return getHighest(x, z, false); } @Override - public int highestTerrainBlock(int x, int z) { + public int highestTerrainBlock(int x, int z) + { return getHighest(x, z, true); } @Override - public KList caveFloors(int x, int z) { + public KList caveFloors(int x, int z) + { return getCaves(x, z); } } diff --git a/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java b/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java index 7523a9a99..1d3cecdc3 100644 --- a/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java @@ -49,7 +49,6 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator private RNG rockRandom; protected IrisLock regLock; private KMap generators; - private KMap ceilingGenerators; protected GenLayerBiome glBiome; protected CNG masterFracture; protected ChronoLatch cwarn = new ChronoLatch(1000); @@ -58,7 +57,6 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator { super(dimensionName, threads); generators = new KMap<>(); - ceilingGenerators = new KMap<>(); regLock = new IrisLock("BiomeChunkGenerator"); } @@ -654,7 +652,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator public void registerGenerator(IrisGenerator g, IrisDimension dim) { - KMap generators = dim.isInverted() ? ceilingGenerators : this.generators; + KMap generators = this.generators; regLock.lock(); if(g.getLoadKey() == null || generators.containsKey(g.getLoadKey())) @@ -669,7 +667,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator protected KMap getGenerators() { - return getDimension().isInverted() ? ceilingGenerators : generators; + return generators; } protected double getBiomeHeight(double rx, double rz, int x, int z) @@ -740,9 +738,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator protected void loadGenerators() { generators.clear(); - ceilingGenerators.clear(); - loadGenerators(((CeilingChunkGenerator) this).getFloorDimension()); - loadGenerators(((CeilingChunkGenerator) this).getCeilingDimension()); + loadGenerators(getDimension()); } protected void loadGenerators(IrisDimension dim) diff --git a/src/main/java/com/volmit/iris/gen/post/PostFloatingNibDeleter.java b/src/main/java/com/volmit/iris/gen/post/PostFloatingNibDeleter.java index 6826396d8..d7164b42d 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostFloatingNibDeleter.java +++ b/src/main/java/com/volmit/iris/gen/post/PostFloatingNibDeleter.java @@ -1,6 +1,7 @@ package com.volmit.iris.gen.post; import org.bukkit.block.data.BlockData; +import org.bukkit.generator.ChunkGenerator.ChunkData; import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.util.B; @@ -22,7 +23,7 @@ public class PostFloatingNibDeleter extends IrisPostBlockFilter } @Override - public void onPost(int x, int z) + public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) { int g = 0; int h = highestTerrainBlock(x, z); @@ -41,13 +42,13 @@ public class PostFloatingNibDeleter extends IrisPostBlockFilter g += hc < h - 1 ? 1 : 0; g += hd < h - 1 ? 1 : 0; - if(g == 4 && isAir(x, h - 1, z)) + if(g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData)) { - setPostBlock(x, h, z, AIR); + setPostBlock(x, h, z, AIR, currentPostX, currentPostZ, currentData); for(int i = h - 1; i > 0; i--) { - if(!isAir(x, i, z)) + if(!isAir(x, i, z, currentPostX, currentPostZ, currentData)) { updateHeight(x, z, i); break; diff --git a/src/main/java/com/volmit/iris/gen/post/PostNibSmoother.java b/src/main/java/com/volmit/iris/gen/post/PostNibSmoother.java index 06a85f5b3..e482b729f 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostNibSmoother.java +++ b/src/main/java/com/volmit/iris/gen/post/PostNibSmoother.java @@ -2,6 +2,7 @@ package com.volmit.iris.gen.post; import org.bukkit.Material; import org.bukkit.block.data.BlockData; +import org.bukkit.generator.ChunkGenerator.ChunkData; import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.util.IrisPostBlockFilter; @@ -20,7 +21,7 @@ public class PostNibSmoother extends IrisPostBlockFilter } @Override - public void onPost(int x, int z) + public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) { int g = 0; int h = highestTerrainBlock(x, z); @@ -35,13 +36,13 @@ public class PostNibSmoother extends IrisPostBlockFilter if(g >= 3) { - BlockData bc = getPostBlock(x, h, z); - BlockData b = getPostBlock(x, h + 1, z); + BlockData bc = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData); + BlockData b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData); Material m = bc.getMaterial(); if(m.isSolid()) { - setPostBlock(x, h, z, b); + setPostBlock(x, h, z, b, currentPostX, currentPostZ, currentData); updateHeight(x, z, h - 1); } } diff --git a/src/main/java/com/volmit/iris/gen/post/PostPotholeFiller.java b/src/main/java/com/volmit/iris/gen/post/PostPotholeFiller.java index b3c87048b..215dc1b34 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostPotholeFiller.java +++ b/src/main/java/com/volmit/iris/gen/post/PostPotholeFiller.java @@ -1,5 +1,7 @@ package com.volmit.iris.gen.post; +import org.bukkit.generator.ChunkGenerator.ChunkData; + import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.util.IrisPostBlockFilter; @@ -17,7 +19,7 @@ public class PostPotholeFiller extends IrisPostBlockFilter } @Override - public void onPost(int x, int z) + public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) { int g = 0; int h = highestTerrainBlock(x, z); @@ -32,7 +34,7 @@ public class PostPotholeFiller extends IrisPostBlockFilter if(g >= 3) { - setPostBlock(x, h + 1, z, getPostBlock(x, h, z)); + setPostBlock(x, h + 1, z, getPostBlock(x, h, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData); updateHeight(x, z, h + 1); } } diff --git a/src/main/java/com/volmit/iris/gen/post/PostSlabber.java b/src/main/java/com/volmit/iris/gen/post/PostSlabber.java index 98eaae1a1..fb69fe5dc 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostSlabber.java +++ b/src/main/java/com/volmit/iris/gen/post/PostSlabber.java @@ -2,6 +2,7 @@ package com.volmit.iris.gen.post; import org.bukkit.Material; import org.bukkit.block.data.BlockData; +import org.bukkit.generator.ChunkGenerator.ChunkData; import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.util.IrisPostBlockFilter; @@ -26,7 +27,7 @@ public class PostSlabber extends IrisPostBlockFilter } @Override - public void onPost(int x, int z) + public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) { int h = highestTerrainBlock(x, z); int ha = highestTerrainBlock(x + 1, z); @@ -34,7 +35,7 @@ public class PostSlabber extends IrisPostBlockFilter int hc = highestTerrainBlock(x - 1, z); int hd = highestTerrainBlock(x, z - 1); - if((ha == h + 1 && isSolid(x + 1, ha, z)) || (hb == h + 1 && isSolid(x, hb, z + 1)) || (hc == h + 1 && isSolid(x - 1, hc, z)) || (hd == h + 1 && isSolid(x, hd, z - 1))) + if((ha == h + 1 && isSolid(x + 1, ha, z, currentPostX, currentPostZ, currentData)) || (hb == h + 1 && isSolid(x, hb, z + 1, currentPostX, currentPostZ, currentData)) || (hc == h + 1 && isSolid(x - 1, hc, z, currentPostX, currentPostZ, currentData)) || (hd == h + 1 && isSolid(x, hd, z - 1, currentPostX, currentPostZ, currentData))) { BlockData d = gen.sampleTrueBiome(x, z).getBiome().getSlab().get(rng, x, h, z); @@ -50,16 +51,16 @@ public class PostSlabber extends IrisPostBlockFilter return; } - if(isSnowLayer(x, h, z)) + if(isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData)) { return; } - if(isAirOrWater(x, h + 2, z)) + if(isAirOrWater(x, h + 2, z, currentPostX, currentPostZ, currentData)) { queue(() -> { - setPostBlock(x, h + 1, z, d); + setPostBlock(x, h + 1, z, d, currentPostX, currentPostZ, currentData); updateHeight(x, z, h + 1); }); } diff --git a/src/main/java/com/volmit/iris/gen/post/PostWallPatcher.java b/src/main/java/com/volmit/iris/gen/post/PostWallPatcher.java index bc7b47f6a..cd15fdf6b 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostWallPatcher.java +++ b/src/main/java/com/volmit/iris/gen/post/PostWallPatcher.java @@ -2,6 +2,7 @@ package com.volmit.iris.gen.post; import org.bukkit.Material; import org.bukkit.block.data.BlockData; +import org.bukkit.generator.ChunkGenerator.ChunkData; import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.object.IrisBiome; @@ -26,7 +27,7 @@ public class PostWallPatcher extends IrisPostBlockFilter } @Override - public void onPost(int x, int z) + public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) { IrisBiome biome = gen.sampleTrueBiome(x, z).getBiome(); int h, ha, hb, hc, hd; @@ -48,7 +49,7 @@ public class PostWallPatcher extends IrisPostBlockFilter { if(!s.getMaterial().equals(AIR)) { - setPostBlock(x, h + 1, z, s); + setPostBlock(x, h + 1, z, s, currentPostX, currentPostZ, currentData); updateHeight(x, z, h + 1); } } @@ -64,12 +65,12 @@ public class PostWallPatcher extends IrisPostBlockFilter continue; } - if(isAirOrWater(x, i, z)) + if(isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData)) { continue; } - setPostBlock(x, i, z, d); + setPostBlock(x, i, z, d, currentPostX, currentPostZ, currentData); } } } diff --git a/src/main/java/com/volmit/iris/gen/post/PostWaterlogger.java b/src/main/java/com/volmit/iris/gen/post/PostWaterlogger.java index 089633ae5..c9dae5ddb 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostWaterlogger.java +++ b/src/main/java/com/volmit/iris/gen/post/PostWaterlogger.java @@ -3,6 +3,7 @@ package com.volmit.iris.gen.post; import org.bukkit.Material; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Waterlogged; +import org.bukkit.generator.ChunkGenerator.ChunkData; import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.util.B; @@ -24,10 +25,10 @@ public class PostWaterlogger extends IrisPostBlockFilter } @Override - public void onPost(int x, int z) + public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) { int h = highestTerrainBlock(x, z); - BlockData b = getPostBlock(x, h, z); + BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData); if(b instanceof Waterlogged) { @@ -38,24 +39,24 @@ public class PostWaterlogger extends IrisPostBlockFilter return; } - if(isWaterOrWaterlogged(x, h + 1, z) && !ww.isWaterlogged()) + if(isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData) && !ww.isWaterlogged()) { ww.setWaterlogged(true); - setPostBlock(x, h, z, ww); + setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData); } - else if(!ww.isWaterlogged() && (isWaterOrWaterlogged(x + 1, h, z) || isWaterOrWaterlogged(x - 1, h, z) || isWaterOrWaterlogged(x, h, z + 1) || isWaterOrWaterlogged(x, h, z - 1))) + else if(!ww.isWaterlogged() && (isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) { ww.setWaterlogged(true); - setPostBlock(x, h, z, ww); + setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData); } } else if(b.getMaterial().equals(Material.AIR) && h <= gen.getFluidHeight()) { - if((isWaterOrWaterlogged(x + 1, h, z) || isWaterOrWaterlogged(x - 1, h, z) || isWaterOrWaterlogged(x, h, z + 1) || isWaterOrWaterlogged(x, h, z - 1))) + if((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) { - setPostBlock(x, h, z, WATER); + setPostBlock(x, h, z, WATER, currentPostX, currentPostZ, currentData); } } } diff --git a/src/main/java/com/volmit/iris/object/IrisDimension.java b/src/main/java/com/volmit/iris/object/IrisDimension.java index 6327513d4..613397220 100644 --- a/src/main/java/com/volmit/iris/object/IrisDimension.java +++ b/src/main/java/com/volmit/iris/object/IrisDimension.java @@ -22,7 +22,6 @@ import com.volmit.iris.util.MaxNumber; import com.volmit.iris.util.MinNumber; import com.volmit.iris.util.RNG; import com.volmit.iris.util.RegistryListBiome; -import com.volmit.iris.util.RegistryListDimension; import com.volmit.iris.util.RegistryListRegion; import com.volmit.iris.util.Required; @@ -145,15 +144,6 @@ public class IrisDimension extends IrisRegistrant @Desc("Compatability filters") private KList compatability = getDefaultCompatability(); - @RegistryListDimension - @DontObfuscate - @Desc("The ceiling dimension. Leave blank for normal sky.") - private String ceiling = ""; - - @DontObfuscate - @Desc("Mirrors the generator floor into the ceiling. Think nether but worse...") - private boolean mirrorCeiling = false; - @Required @DontObfuscate @Desc("The world environment") @@ -289,7 +279,6 @@ public class IrisDimension extends IrisRegistrant private transient AtomicCache sinr = new AtomicCache<>(); private transient AtomicCache cosr = new AtomicCache<>(); private transient AtomicCache rad = new AtomicCache<>(); - private transient boolean inverted = false; public KList getPostBlockProcessors(PostBlockChunkGenerator g) { diff --git a/src/main/java/com/volmit/iris/util/IPostBlockAccess.java b/src/main/java/com/volmit/iris/util/IPostBlockAccess.java index ba3c314ed..631d341ad 100644 --- a/src/main/java/com/volmit/iris/util/IPostBlockAccess.java +++ b/src/main/java/com/volmit/iris/util/IPostBlockAccess.java @@ -1,12 +1,13 @@ package com.volmit.iris.util; import org.bukkit.block.data.BlockData; +import org.bukkit.generator.ChunkGenerator.ChunkData; public interface IPostBlockAccess { - public BlockData getPostBlock(int x, int y, int z); + public BlockData getPostBlock(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData); - public void setPostBlock(int x, int y, int z, BlockData d); + public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, ChunkData currentData); public int highestTerrainOrFluidBlock(int x, int z); diff --git a/src/main/java/com/volmit/iris/util/IrisPostBlockFilter.java b/src/main/java/com/volmit/iris/util/IrisPostBlockFilter.java index efadf2ce8..5140dd6f1 100644 --- a/src/main/java/com/volmit/iris/util/IrisPostBlockFilter.java +++ b/src/main/java/com/volmit/iris/util/IrisPostBlockFilter.java @@ -5,6 +5,7 @@ import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Levelled; import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.type.Slab; +import org.bukkit.generator.ChunkGenerator.ChunkData; import com.volmit.iris.gen.PostBlockChunkGenerator; import com.volmit.iris.gen.post.Post; @@ -32,18 +33,18 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess this(gen, 0); } - public abstract void onPost(int x, int z); + public abstract void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData); @Override - public BlockData getPostBlock(int x, int y, int z) + public BlockData getPostBlock(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - return gen.getPostBlock(x, y, z); + return gen.getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); } @Override - public void setPostBlock(int x, int y, int z, BlockData d) + public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, ChunkData currentData) { - gen.setPostBlock(x, y, z, d); + gen.setPostBlock(x, y, z, d, currentPostX, currentPostZ, currentData); } @Override @@ -58,57 +59,57 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess return gen.highestTerrainBlock(x, z); } - public boolean isAir(int x, int y, int z) + public boolean isAir(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - BlockData d = getPostBlock(x, y, z); + BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR); } - public boolean hasGravity(int x, int y, int z) + public boolean hasGravity(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - BlockData d = getPostBlock(x, y, z); + BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); return d.getMaterial().equals(Material.SAND) || d.getMaterial().equals(Material.RED_SAND) || d.getMaterial().equals(Material.BLACK_CONCRETE_POWDER) || d.getMaterial().equals(Material.BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.BROWN_CONCRETE_POWDER) || d.getMaterial().equals(Material.CYAN_CONCRETE_POWDER) || d.getMaterial().equals(Material.GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.GREEN_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIME_CONCRETE_POWDER) || d.getMaterial().equals(Material.MAGENTA_CONCRETE_POWDER) || d.getMaterial().equals(Material.ORANGE_CONCRETE_POWDER) || d.getMaterial().equals(Material.PINK_CONCRETE_POWDER) || d.getMaterial().equals(Material.PURPLE_CONCRETE_POWDER) || d.getMaterial().equals(Material.RED_CONCRETE_POWDER) || d.getMaterial().equals(Material.WHITE_CONCRETE_POWDER) || d.getMaterial().equals(Material.YELLOW_CONCRETE_POWDER); } - public boolean isSolid(int x, int y, int z) + public boolean isSolid(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - BlockData d = getPostBlock(x, y, z); + BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); return d.getMaterial().isSolid(); } - public boolean isAirOrWater(int x, int y, int z) + public boolean isAirOrWater(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - BlockData d = getPostBlock(x, y, z); + BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); return d.getMaterial().equals(Material.WATER) || d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR); } - public boolean isSlab(int x, int y, int z) + public boolean isSlab(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - BlockData d = getPostBlock(x, y, z); + BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); return d instanceof Slab; } - public boolean isSnowLayer(int x, int y, int z) + public boolean isSnowLayer(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - BlockData d = getPostBlock(x, y, z); + BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); return d.getMaterial().equals(Material.SNOW); } - public boolean isWater(int x, int y, int z) + public boolean isWater(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - BlockData d = getPostBlock(x, y, z); + BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); return d.getMaterial().equals(Material.WATER); } - public boolean isWaterOrWaterlogged(int x, int y, int z) + public boolean isWaterOrWaterlogged(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - BlockData d = getPostBlock(x, y, z); + BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); return d.getMaterial().equals(Material.WATER) || (d instanceof Waterlogged && ((Waterlogged) d).isWaterlogged()); } - public boolean isLiquid(int x, int y, int z) + public boolean isLiquid(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - BlockData d = getPostBlock(x, y, z); + BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); return d instanceof Levelled; }