Noise overlay support & Post Foliage Cleaner

This commit is contained in:
Daniel Mills 2020-09-05 01:39:19 -04:00
parent fc55622cc8
commit 44d800de1e
13 changed files with 162 additions and 37 deletions

View File

@ -19,6 +19,7 @@ import com.volmit.iris.command.CommandIris;
import com.volmit.iris.command.PermissionIris; import com.volmit.iris.command.PermissionIris;
import com.volmit.iris.gen.IrisChunkGenerator; import com.volmit.iris.gen.IrisChunkGenerator;
import com.volmit.iris.gen.post.PostFloatingNibDeleter; 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.PostNibSmoother;
import com.volmit.iris.gen.post.PostPotholeFiller; import com.volmit.iris.gen.post.PostPotholeFiller;
import com.volmit.iris.gen.post.PostSlabber; import com.volmit.iris.gen.post.PostSlabber;
@ -163,6 +164,7 @@ public class Iris extends MortarPlugin
KList<Class<? extends IrisPostBlockFilter>> g = new KList<Class<? extends IrisPostBlockFilter>>(); KList<Class<? extends IrisPostBlockFilter>> g = new KList<Class<? extends IrisPostBlockFilter>>();
g.add(PostFloatingNibDeleter.class); g.add(PostFloatingNibDeleter.class);
g.add(PostFoliageCleaner.class);
g.add(PostNibSmoother.class); g.add(PostNibSmoother.class);
g.add(PostPotholeFiller.class); g.add(PostPotholeFiller.class);
g.add(PostSlabber.class); g.add(PostSlabber.class);

View File

@ -5,6 +5,7 @@ import org.bukkit.block.data.BlockData;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.gen.post.PostFloatingNibDeleter; 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.PostNibSmoother;
import com.volmit.iris.gen.post.PostPotholeFiller; import com.volmit.iris.gen.post.PostPotholeFiller;
import com.volmit.iris.gen.post.PostSlabber; import com.volmit.iris.gen.post.PostSlabber;
@ -115,6 +116,11 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
return new PostFloatingNibDeleter(this, phase); return new PostFloatingNibDeleter(this, phase);
} }
if(processor.equals("foliage-cleaner"))
{
return new PostFoliageCleaner(this, phase);
}
if(processor.equals("nib-smoother")) if(processor.equals("nib-smoother"))
{ {
return new PostNibSmoother(this, phase); return new PostNibSmoother(this, phase);

View File

@ -23,6 +23,7 @@ import com.volmit.iris.object.IrisDepositGenerator;
import com.volmit.iris.object.IrisDimension; import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.object.IrisGenerator; import com.volmit.iris.object.IrisGenerator;
import com.volmit.iris.object.IrisRegion; import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.object.IrisShapedGeneratorStyle;
import com.volmit.iris.util.B; import com.volmit.iris.util.B;
import com.volmit.iris.util.BiomeMap; import com.volmit.iris.util.BiomeMap;
import com.volmit.iris.util.CaveResult; import com.volmit.iris.util.CaveResult;
@ -755,6 +756,11 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
{ {
double h = getRawBiomeHeight(rrx, rrz); double h = getRawBiomeHeight(rrx, rrz);
for(IrisShapedGeneratorStyle i : getDimension().getOverlayNoise())
{
h += i.get(getMasterRandom(), rrx, rrz);
}
return h; return h;
} }

View File

@ -36,10 +36,10 @@ public class PostFloatingNibDeleter extends IrisPostBlockFilter
return; return;
} }
int ha = highestTerrainBlock(x + 1, z); int ha = highestTerrainOrCarvingBlock(x + 1, z);
int hb = highestTerrainBlock(x, z + 1); int hb = highestTerrainOrCarvingBlock(x, z + 1);
int hc = highestTerrainBlock(x - 1, z); int hc = highestTerrainOrCarvingBlock(x - 1, z);
int hd = highestTerrainBlock(x, z - 1); int hd = highestTerrainOrCarvingBlock(x, z - 1);
g += ha < h - 1 ? 1 : 0; g += ha < h - 1 ? 1 : 0;
g += hb < h - 1 ? 1 : 0; g += hb < h - 1 ? 1 : 0;
g += hc < h - 1 ? 1 : 0; g += hc < h - 1 ? 1 : 0;

View File

@ -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);
}
}
}
}

View File

@ -27,11 +27,11 @@ public class PostNibSmoother extends IrisPostBlockFilter
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
int g = 0; int g = 0;
int h = highestTerrainBlock(x, z); int h = highestTerrainOrCarvingBlock(x, z);
int ha = highestTerrainBlock(x + 1, z); int ha = highestTerrainOrCarvingBlock(x + 1, z);
int hb = highestTerrainBlock(x, z + 1); int hb = highestTerrainOrCarvingBlock(x, z + 1);
int hc = highestTerrainBlock(x - 1, z); int hc = highestTerrainOrCarvingBlock(x - 1, z);
int hd = highestTerrainBlock(x, z - 1); int hd = highestTerrainOrCarvingBlock(x, z - 1);
g += ha == h - 1 ? 1 : 0; g += ha == h - 1 ? 1 : 0;
g += hb == h - 1 ? 1 : 0; g += hb == h - 1 ? 1 : 0;
g += hc == h - 1 ? 1 : 0; g += hc == h - 1 ? 1 : 0;

View File

@ -25,11 +25,11 @@ public class PostPotholeFiller extends IrisPostBlockFilter
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
int g = 0; int g = 0;
int h = highestTerrainBlock(x, z); int h = highestTerrainOrCarvingBlock(x, z);
int ha = highestTerrainBlock(x + 1, z); int ha = highestTerrainOrCarvingBlock(x + 1, z);
int hb = highestTerrainBlock(x, z + 1); int hb = highestTerrainOrCarvingBlock(x, z + 1);
int hc = highestTerrainBlock(x - 1, z); int hc = highestTerrainOrCarvingBlock(x - 1, z);
int hd = highestTerrainBlock(x, z - 1); int hd = highestTerrainOrCarvingBlock(x, z - 1);
g += ha == h + 1 ? 1 : 0; g += ha == h + 1 ? 1 : 0;
g += hb == h + 1 ? 1 : 0; g += hb == h + 1 ? 1 : 0;
g += hc == h + 1 ? 1 : 0; g += hc == h + 1 ? 1 : 0;

View File

@ -32,11 +32,11 @@ public class PostSlabber extends IrisPostBlockFilter
@Override @Override
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
int h = highestTerrainBlock(x, z); int h = highestTerrainOrCarvingBlock(x, z);
int ha = highestTerrainBlock(x + 1, z); int ha = highestTerrainOrCarvingBlock(x + 1, z);
int hb = highestTerrainBlock(x, z + 1); int hb = highestTerrainOrCarvingBlock(x, z + 1);
int hc = highestTerrainBlock(x - 1, z); int hc = highestTerrainOrCarvingBlock(x - 1, z);
int hd = highestTerrainBlock(x, z - 1); 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))) 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)))
{ {

View File

@ -37,11 +37,11 @@ public class PostWallPatcher extends IrisPostBlockFilter
if(!biome.getWall().getPalette().isEmpty()) if(!biome.getWall().getPalette().isEmpty())
{ {
h = highestTerrainBlock(x, z); h = highestTerrainOrCarvingBlock(x, z);
ha = highestTerrainBlock(x + 1, z); ha = highestTerrainOrCarvingBlock(x + 1, z);
hb = highestTerrainBlock(x, z + 1); hb = highestTerrainOrCarvingBlock(x, z + 1);
hc = highestTerrainBlock(x - 1, z); hc = highestTerrainOrCarvingBlock(x - 1, z);
hd = highestTerrainBlock(x, z - 1); hd = highestTerrainOrCarvingBlock(x, z - 1);
if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2) if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2)
{ {

View File

@ -30,7 +30,7 @@ public class PostWaterlogger extends IrisPostBlockFilter
@Override @Override
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData) 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); BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
if(b instanceof Waterlogged) if(b instanceof Waterlogged)

View File

@ -251,6 +251,11 @@ public class IrisDimension extends IrisRegistrant
@Desc("Define global deposit generators") @Desc("Define global deposit generators")
private KList<IrisDepositGenerator> deposits = new KList<>(); private KList<IrisDepositGenerator> deposits = new KList<>();
@ArrayType(min = 1, type = IrisShapedGeneratorStyle.class)
@DontObfuscate
@Desc("Overlay additional noise on top of the interoplated terrain.")
private KList<IrisShapedGeneratorStyle> overlayNoise = new KList<>();
@DontObfuscate @DontObfuscate
@Desc("The noise style for rock types") @Desc("The noise style for rock types")
private IrisGeneratorStyle rockStyle = NoiseStyle.STATIC.style(); private IrisGeneratorStyle rockStyle = NoiseStyle.STATIC.style();

View File

@ -52,6 +52,11 @@ public class B
}); });
} }
public static boolean isSolid(BlockData mat)
{
return isSolid(mat.getMaterial());
}
public static boolean isSolid(Material mat) public static boolean isSolid(Material mat)
{ {
if(!solid.containsKey(mat)) if(!solid.containsKey(mat))
@ -311,6 +316,47 @@ public class B
return false; 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) public static boolean canPlaceOnto(Material mat, Material onto)
{ {
String key = mat.name() + "" + onto.name(); String key = mat.name() + "" + onto.name();
@ -320,6 +366,17 @@ public class B
return false; 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"))) if(onto.equals(Material.AIR) || onto.equals(B.mat("CAVE_AIR")))
{ {
lock.lock(); 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(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()) if(!mat.isSolid())
@ -460,6 +506,16 @@ public class B
return 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) public static boolean isAir(BlockData d)
{ {
return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR) || d.getMaterial().equals(Material.VOID_AIR); return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR) || d.getMaterial().equals(Material.VOID_AIR);

View File

@ -61,6 +61,11 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess
return gen.highestTerrainBlock(x, z); 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) public boolean isAir(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{ {
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData); BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);