diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index 24ff491fc..05d697aa2 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -19,6 +19,7 @@ import com.volmit.iris.command.CommandIris; import com.volmit.iris.command.PermissionIris; import com.volmit.iris.gen.IrisChunkGenerator; import com.volmit.iris.gen.post.PostFloatingNibDeleter; +import com.volmit.iris.gen.post.PostFoliageCleaner; import com.volmit.iris.gen.post.PostNibSmoother; import com.volmit.iris.gen.post.PostPotholeFiller; import com.volmit.iris.gen.post.PostSlabber; @@ -150,7 +151,7 @@ public class Iris extends MortarPlugin i.close(); } } - + executors.clear(); board.disable(); Bukkit.getScheduler().cancelTasks(this); @@ -163,6 +164,7 @@ public class Iris extends MortarPlugin KList> g = new KList>(); g.add(PostFloatingNibDeleter.class); + g.add(PostFoliageCleaner.class); g.add(PostNibSmoother.class); g.add(PostPotholeFiller.class); g.add(PostSlabber.class); diff --git a/src/main/java/com/volmit/iris/gen/PostBlockChunkGenerator.java b/src/main/java/com/volmit/iris/gen/PostBlockChunkGenerator.java index e2f4bed17..d18ec4867 100644 --- a/src/main/java/com/volmit/iris/gen/PostBlockChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/PostBlockChunkGenerator.java @@ -5,6 +5,7 @@ import org.bukkit.block.data.BlockData; import com.volmit.iris.Iris; import com.volmit.iris.gen.post.PostFloatingNibDeleter; +import com.volmit.iris.gen.post.PostFoliageCleaner; import com.volmit.iris.gen.post.PostNibSmoother; import com.volmit.iris.gen.post.PostPotholeFiller; import com.volmit.iris.gen.post.PostSlabber; @@ -115,6 +116,11 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp return new PostFloatingNibDeleter(this, phase); } + if(processor.equals("foliage-cleaner")) + { + return new PostFoliageCleaner(this, phase); + } + if(processor.equals("nib-smoother")) { return new PostNibSmoother(this, phase); diff --git a/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java b/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java index 7d8fa1765..78742075d 100644 --- a/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java @@ -23,6 +23,7 @@ import com.volmit.iris.object.IrisDepositGenerator; import com.volmit.iris.object.IrisDimension; import com.volmit.iris.object.IrisGenerator; import com.volmit.iris.object.IrisRegion; +import com.volmit.iris.object.IrisShapedGeneratorStyle; import com.volmit.iris.util.B; import com.volmit.iris.util.BiomeMap; import com.volmit.iris.util.CaveResult; @@ -755,6 +756,11 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator { double h = getRawBiomeHeight(rrx, rrz); + for(IrisShapedGeneratorStyle i : getDimension().getOverlayNoise()) + { + h += i.get(getMasterRandom(), rrx, rrz); + } + return h; } 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 92d389ba0..2efc48089 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostFloatingNibDeleter.java +++ b/src/main/java/com/volmit/iris/gen/post/PostFloatingNibDeleter.java @@ -36,10 +36,10 @@ public class PostFloatingNibDeleter extends IrisPostBlockFilter return; } - int ha = highestTerrainBlock(x + 1, z); - int hb = highestTerrainBlock(x, z + 1); - int hc = highestTerrainBlock(x - 1, z); - int hd = highestTerrainBlock(x, z - 1); + int ha = highestTerrainOrCarvingBlock(x + 1, z); + int hb = highestTerrainOrCarvingBlock(x, z + 1); + int hc = highestTerrainOrCarvingBlock(x - 1, z); + int hd = highestTerrainOrCarvingBlock(x, z - 1); g += ha < h - 1 ? 1 : 0; g += hb < h - 1 ? 1 : 0; g += hc < h - 1 ? 1 : 0; diff --git a/src/main/java/com/volmit/iris/gen/post/PostFoliageCleaner.java b/src/main/java/com/volmit/iris/gen/post/PostFoliageCleaner.java new file mode 100644 index 000000000..6b81e4459 --- /dev/null +++ b/src/main/java/com/volmit/iris/gen/post/PostFoliageCleaner.java @@ -0,0 +1,45 @@ +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.B; +import com.volmit.iris.util.DontObfuscate; +import com.volmit.iris.util.IrisPostBlockFilter; + +@Post("foliage-cleaner") +public class PostFoliageCleaner extends IrisPostBlockFilter +{ + public static final BlockData AIR = B.get("AIR"); + + @DontObfuscate + public PostFoliageCleaner(PostBlockChunkGenerator gen, int phase) + { + super(gen, phase); + } + + @DontObfuscate + public PostFoliageCleaner(PostBlockChunkGenerator gen) + { + this(gen, 0); + } + + @Override + public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) + { + int h = highestTerrainOrCarvingBlock(x, z); + BlockData b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData); + + if(B.isFoliage(b) || b.getMaterial().equals(Material.DEAD_BUSH)) + { + Material onto = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData).getMaterial(); + + if(!B.canPlaceOnto(b.getMaterial(), onto)) + { + setPostBlock(x, h + 1, z, AIR, currentPostX, currentPostZ, currentData); + } + } + } +} 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 2b5874adc..74c4402a4 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostNibSmoother.java +++ b/src/main/java/com/volmit/iris/gen/post/PostNibSmoother.java @@ -27,11 +27,11 @@ public class PostNibSmoother extends IrisPostBlockFilter public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) { int g = 0; - int h = highestTerrainBlock(x, z); - int ha = highestTerrainBlock(x + 1, z); - int hb = highestTerrainBlock(x, z + 1); - int hc = highestTerrainBlock(x - 1, z); - int hd = highestTerrainBlock(x, z - 1); + int h = highestTerrainOrCarvingBlock(x, z); + int ha = highestTerrainOrCarvingBlock(x + 1, z); + int hb = highestTerrainOrCarvingBlock(x, z + 1); + int hc = highestTerrainOrCarvingBlock(x - 1, z); + int hd = highestTerrainOrCarvingBlock(x, z - 1); g += ha == h - 1 ? 1 : 0; g += hb == h - 1 ? 1 : 0; g += hc == h - 1 ? 1 : 0; 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 ca48b514d..99a557e4a 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostPotholeFiller.java +++ b/src/main/java/com/volmit/iris/gen/post/PostPotholeFiller.java @@ -25,11 +25,11 @@ public class PostPotholeFiller extends IrisPostBlockFilter public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) { int g = 0; - int h = highestTerrainBlock(x, z); - int ha = highestTerrainBlock(x + 1, z); - int hb = highestTerrainBlock(x, z + 1); - int hc = highestTerrainBlock(x - 1, z); - int hd = highestTerrainBlock(x, z - 1); + int h = highestTerrainOrCarvingBlock(x, z); + int ha = highestTerrainOrCarvingBlock(x + 1, z); + int hb = highestTerrainOrCarvingBlock(x, z + 1); + int hc = highestTerrainOrCarvingBlock(x - 1, z); + int hd = highestTerrainOrCarvingBlock(x, z - 1); g += ha == h + 1 ? 1 : 0; g += hb == h + 1 ? 1 : 0; g += hc == h + 1 ? 1 : 0; 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 03dfc36ba..bfb129f54 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostSlabber.java +++ b/src/main/java/com/volmit/iris/gen/post/PostSlabber.java @@ -32,11 +32,11 @@ public class PostSlabber extends IrisPostBlockFilter @Override public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - int h = highestTerrainBlock(x, z); - int ha = highestTerrainBlock(x + 1, z); - int hb = highestTerrainBlock(x, z + 1); - int hc = highestTerrainBlock(x - 1, z); - int hd = highestTerrainBlock(x, z - 1); + int h = highestTerrainOrCarvingBlock(x, z); + int ha = highestTerrainOrCarvingBlock(x + 1, z); + int hb = highestTerrainOrCarvingBlock(x, z + 1); + int hc = highestTerrainOrCarvingBlock(x - 1, z); + int hd = highestTerrainOrCarvingBlock(x, 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))) { 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 a53ff5d8e..e1e32da02 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostWallPatcher.java +++ b/src/main/java/com/volmit/iris/gen/post/PostWallPatcher.java @@ -37,11 +37,11 @@ public class PostWallPatcher extends IrisPostBlockFilter if(!biome.getWall().getPalette().isEmpty()) { - h = highestTerrainBlock(x, z); - ha = highestTerrainBlock(x + 1, z); - hb = highestTerrainBlock(x, z + 1); - hc = highestTerrainBlock(x - 1, z); - hd = highestTerrainBlock(x, z - 1); + h = highestTerrainOrCarvingBlock(x, z); + ha = highestTerrainOrCarvingBlock(x + 1, z); + hb = highestTerrainOrCarvingBlock(x, z + 1); + hc = highestTerrainOrCarvingBlock(x - 1, z); + hd = highestTerrainOrCarvingBlock(x, z - 1); if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2) { 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 b568aaa95..2a0293dfa 100644 --- a/src/main/java/com/volmit/iris/gen/post/PostWaterlogger.java +++ b/src/main/java/com/volmit/iris/gen/post/PostWaterlogger.java @@ -30,7 +30,7 @@ public class PostWaterlogger extends IrisPostBlockFilter @Override public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) { - int h = highestTerrainBlock(x, z); + int h = highestTerrainOrCarvingBlock(x, z); BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData); if(b instanceof Waterlogged) diff --git a/src/main/java/com/volmit/iris/object/IrisDimension.java b/src/main/java/com/volmit/iris/object/IrisDimension.java index 1f7e9d64b..362f3c76a 100644 --- a/src/main/java/com/volmit/iris/object/IrisDimension.java +++ b/src/main/java/com/volmit/iris/object/IrisDimension.java @@ -251,6 +251,11 @@ public class IrisDimension extends IrisRegistrant @Desc("Define global deposit generators") private KList deposits = new KList<>(); + @ArrayType(min = 1, type = IrisShapedGeneratorStyle.class) + @DontObfuscate + @Desc("Overlay additional noise on top of the interoplated terrain.") + private KList overlayNoise = new KList<>(); + @DontObfuscate @Desc("The noise style for rock types") private IrisGeneratorStyle rockStyle = NoiseStyle.STATIC.style(); diff --git a/src/main/java/com/volmit/iris/util/B.java b/src/main/java/com/volmit/iris/util/B.java index 6f729a9d3..d4cdf487b 100644 --- a/src/main/java/com/volmit/iris/util/B.java +++ b/src/main/java/com/volmit/iris/util/B.java @@ -52,6 +52,11 @@ public class B }); } + public static boolean isSolid(BlockData mat) + { + return isSolid(mat.getMaterial()); + } + public static boolean isSolid(Material mat) { if(!solid.containsKey(mat)) @@ -311,6 +316,47 @@ public class B return false; } + public static boolean isFoliage(BlockData d) + { + if(isFluid(d) || isAir(d) || isSolid(d)) + { + return false; + } + + Material mat = d.getMaterial(); + //@builder + return mat.equals(Material.POPPY) + || mat.equals(Material.DANDELION) + || mat.equals(B.mat("CORNFLOWER")) + || mat.equals(B.mat("SWEET_BERRY_BUSH")) + || mat.equals(B.mat("CRIMSON_ROOTS")) + || mat.equals(B.mat("WARPED_ROOTS")) + || mat.equals(B.mat("NETHER_SPROUTS")) + || mat.equals(B.mat("ALLIUM")) + || mat.equals(B.mat("AZURE_BLUET")) + || mat.equals(B.mat("BLUE_ORCHID")) + || mat.equals(B.mat("POPPY")) + || mat.equals(B.mat("DANDELION")) + || mat.equals(B.mat("OXEYE_DAISY")) + || mat.equals(B.mat("LILY_OF_THE_VALLEY")) + || mat.equals(B.mat("WITHER_ROSE")) + || mat.equals(Material.DARK_OAK_SAPLING) + || mat.equals(Material.ACACIA_SAPLING) + || mat.equals(Material.JUNGLE_SAPLING) + || mat.equals(Material.BIRCH_SAPLING) + || mat.equals(Material.SPRUCE_SAPLING) + || mat.equals(Material.OAK_SAPLING) + || mat.equals(Material.ORANGE_TULIP) + || mat.equals(Material.PINK_TULIP) + || mat.equals(Material.RED_TULIP) + || mat.equals(Material.WHITE_TULIP) + || mat.equals(Material.FERN) + || mat.equals(Material.LARGE_FERN) + || mat.equals(Material.GRASS) + || mat.equals(Material.TALL_GRASS); + //@done + } + public static boolean canPlaceOnto(Material mat, Material onto) { String key = mat.name() + "" + onto.name(); @@ -320,6 +366,17 @@ public class B return false; } + if(isFoliage(B.get(mat.name()))) + { + if(!isFoliagePlantable(B.get(onto.name()))) + { + lock.lock(); + canPlaceOn.add(key); + lock.unlock(); + return false; + } + } + if(onto.equals(Material.AIR) || onto.equals(B.mat("CAVE_AIR"))) { lock.lock(); @@ -347,17 +404,6 @@ public class B } } - if(onto.equals(Material.STONE) || onto.equals(Material.GRAVEL) || onto.equals(Material.GRAVEL) || onto.equals(Material.ANDESITE) || onto.equals(Material.GRANITE) || onto.equals(Material.DIORITE) || onto.equals(B.mat("BLACKSTONE")) || onto.equals(B.mat("BASALT"))) - { - if(mat.equals(Material.POPPY) || mat.equals(Material.DANDELION) || mat.equals(B.mat("CORNFLOWER")) || mat.equals(Material.ORANGE_TULIP) || mat.equals(Material.PINK_TULIP) || mat.equals(Material.RED_TULIP) || mat.equals(Material.WHITE_TULIP) || mat.equals(Material.FERN) || mat.equals(Material.LARGE_FERN) || mat.equals(Material.GRASS) || mat.equals(Material.TALL_GRASS)) - { - lock.lock(); - canPlaceOn.add(key); - lock.unlock(); - return false; - } - } - if(onto.equals(Material.ACACIA_LEAVES) || onto.equals(Material.BIRCH_LEAVES) || onto.equals(Material.DARK_OAK_LEAVES) || onto.equals(Material.JUNGLE_LEAVES) || onto.equals(Material.OAK_LEAVES) || onto.equals(Material.SPRUCE_LEAVES)) { if(!mat.isSolid()) @@ -460,6 +506,16 @@ public class B return b; } + public static boolean isFoliagePlantable(BlockData d) + { + return d.getMaterial().equals(Material.GRASS_BLOCK) || d.getMaterial().equals(Material.DIRT) || d.getMaterial().equals(Material.COARSE_DIRT) || d.getMaterial().equals(Material.PODZOL); + } + + public static boolean isFluid(BlockData d) + { + return d.getMaterial().equals(Material.WATER) || d.getMaterial().equals(Material.LAVA); + } + public static boolean isAir(BlockData d) { return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR) || d.getMaterial().equals(Material.VOID_AIR); diff --git a/src/main/java/com/volmit/iris/util/IrisPostBlockFilter.java b/src/main/java/com/volmit/iris/util/IrisPostBlockFilter.java index 867e3b6e4..d1ae75175 100644 --- a/src/main/java/com/volmit/iris/util/IrisPostBlockFilter.java +++ b/src/main/java/com/volmit/iris/util/IrisPostBlockFilter.java @@ -61,6 +61,11 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess return gen.highestTerrainBlock(x, z); } + public int highestTerrainOrCarvingBlock(int x, int z) + { + return gen.getCarvedHeight(x, z, true); + } + public boolean isAir(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) { BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);