Config options & fix cave slabs for 2x lines

This commit is contained in:
Daniel Mills 2020-09-07 11:56:22 -04:00
parent 90a5398e98
commit 1993639bf6
18 changed files with 456 additions and 610 deletions

View File

@ -19,13 +19,6 @@ import org.bukkit.plugin.Plugin;
import com.volmit.iris.command.CommandIris; import com.volmit.iris.command.CommandIris;
import com.volmit.iris.command.PermissionIris; import com.volmit.iris.command.PermissionIris;
import com.volmit.iris.gen.IrisTerrainProvider; import com.volmit.iris.gen.IrisTerrainProvider;
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;
import com.volmit.iris.gen.post.PostWallPatcher;
import com.volmit.iris.gen.post.PostWaterlogger;
import com.volmit.iris.gen.provisions.ProvisionBukkit; import com.volmit.iris.gen.provisions.ProvisionBukkit;
import com.volmit.iris.gen.scaffold.IrisGenConfiguration; import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
import com.volmit.iris.gen.scaffold.TerrainTarget; import com.volmit.iris.gen.scaffold.TerrainTarget;
@ -35,7 +28,6 @@ import com.volmit.iris.util.Form;
import com.volmit.iris.util.GroupedExecutor; import com.volmit.iris.util.GroupedExecutor;
import com.volmit.iris.util.IO; import com.volmit.iris.util.IO;
import com.volmit.iris.util.IrisLock; import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.IrisPostBlockFilter;
import com.volmit.iris.util.J; import com.volmit.iris.util.J;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.MortarPlugin; import com.volmit.iris.util.MortarPlugin;
@ -190,21 +182,6 @@ public class Iris extends MortarPlugin
super.onDisable(); super.onDisable();
} }
public static KList<Class<? extends IrisPostBlockFilter>> loadPostProcessors()
{
KList<Class<? extends IrisPostBlockFilter>> g = new KList<Class<? extends IrisPostBlockFilter>>();
g.add(PostFloatingNibDeleter.class);
g.add(PostFoliageCleaner.class);
g.add(PostNibSmoother.class);
g.add(PostPotholeFiller.class);
g.add(PostSlabber.class);
g.add(PostWallPatcher.class);
g.add(PostWaterlogger.class);
return g;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{ {

View File

@ -28,7 +28,6 @@ import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import com.volmit.iris.gen.IrisTerrainProvider; import com.volmit.iris.gen.IrisTerrainProvider;
import com.volmit.iris.gen.nms.NMSCreator; import com.volmit.iris.gen.nms.NMSCreator;
import com.volmit.iris.gen.post.Post;
import com.volmit.iris.gen.provisions.ProvisionBukkit; import com.volmit.iris.gen.provisions.ProvisionBukkit;
import com.volmit.iris.gen.scaffold.IrisGenConfiguration; import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
import com.volmit.iris.gen.scaffold.TerrainTarget; import com.volmit.iris.gen.scaffold.TerrainTarget;
@ -57,7 +56,6 @@ import com.volmit.iris.util.DependsOn;
import com.volmit.iris.util.Desc; import com.volmit.iris.util.Desc;
import com.volmit.iris.util.Form; import com.volmit.iris.util.Form;
import com.volmit.iris.util.IO; import com.volmit.iris.util.IO;
import com.volmit.iris.util.IrisPostBlockFilter;
import com.volmit.iris.util.J; import com.volmit.iris.util.J;
import com.volmit.iris.util.JSONArray; import com.volmit.iris.util.JSONArray;
import com.volmit.iris.util.JSONException; import com.volmit.iris.util.JSONException;
@ -1823,17 +1821,10 @@ public class ProjectManager
IO.writeAll(new File(of, "interpolation-method.txt"), m.toString("\n")); IO.writeAll(new File(of, "interpolation-method.txt"), m.toString("\n"));
m = new KList<>(); m = new KList<>();
for(Class<? extends IrisPostBlockFilter> i : Iris.loadPostProcessors())
{
m.add(i.getDeclaredAnnotation(Post.class).value());
}
IO.writeAll(new File(of, "post-processors.txt"), m.toString("\n"));
m = new KList<>();
for(PotionEffectType i : PotionEffectType.values()) for(PotionEffectType i : PotionEffectType.values())
{ {
m.add(i.getName().toUpperCase().replaceAll("\\Q \\E", "_")); m.add(i.getName().toUpperCase().replaceAll("\\Q \\E", "_"));
} }
IO.writeAll(new File(of, "potioneffects.txt"), m.toString("\n"));
} }
} }

View File

@ -414,7 +414,7 @@ public class IrisTerrainProvider extends PostBlockTerrainProvider implements Iri
{ {
int x = (c.getX() * 16) + rng.nextInt(15); int x = (c.getX() * 16) + rng.nextInt(15);
int z = (c.getZ() * 16) + rng.nextInt(15); int z = (c.getZ() * 16) + rng.nextInt(15);
int y = getCarvedHeight(x, z); int y = getCarvedHeight(x, z) + 1;
IrisDimension dim = getDimension(); IrisDimension dim = getDimension();
IrisRegion region = sampleRegion(x, z); IrisRegion region = sampleRegion(x, z);
IrisBiome above = sampleTrueBiome(x, z); IrisBiome above = sampleTrueBiome(x, z);

View File

@ -4,19 +4,12 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData; import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.gen.post.PostFloatingNibDeleter; import com.volmit.iris.gen.post.PostMasterPatcher;
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;
import com.volmit.iris.gen.post.PostWallPatcher;
import com.volmit.iris.gen.post.PostWaterlogger;
import com.volmit.iris.gen.scaffold.TerrainChunk; import com.volmit.iris.gen.scaffold.TerrainChunk;
import com.volmit.iris.gen.scaffold.TerrainTarget; import com.volmit.iris.gen.scaffold.TerrainTarget;
import com.volmit.iris.util.CaveResult; import com.volmit.iris.util.CaveResult;
import com.volmit.iris.util.IPostBlockAccess; import com.volmit.iris.util.IPostBlockAccess;
import com.volmit.iris.util.IrisLock; import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.IrisPostBlockFilter;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.PrecisionStopwatch; import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
@ -30,6 +23,7 @@ public abstract class PostBlockTerrainProvider extends ParallaxTerrainProvider i
{ {
private String postKey; private String postKey;
private IrisLock postLock; private IrisLock postLock;
private PostMasterPatcher patcher;
private int minPhase; private int minPhase;
private int maxPhase; private int maxPhase;
@ -43,6 +37,7 @@ public abstract class PostBlockTerrainProvider extends ParallaxTerrainProvider i
public void onInit(RNG rng) public void onInit(RNG rng)
{ {
super.onInit(rng); super.onInit(rng);
patcher = new PostMasterPatcher(this);
} }
@Override @Override
@ -55,13 +50,9 @@ public abstract class PostBlockTerrainProvider extends ParallaxTerrainProvider i
return; return;
} }
KList<IrisPostBlockFilter> filters = getDimension().getPostBlockProcessors(this);
int rx, i, j; int rx, i, j;
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
KList<Runnable> q = new KList<>();
for(int h = getMinPhase(); h <= getMaxPhase(); h++)
{
for(i = 0; i < 16; i++) for(i = 0; i < 16; i++)
{ {
rx = (x << 4) + i; rx = (x << 4) + i;
@ -70,89 +61,25 @@ public abstract class PostBlockTerrainProvider extends ParallaxTerrainProvider i
{ {
int rxx = rx; int rxx = rx;
int rzz = (z << 4) + j; int rzz = (z << 4) + j;
int hh = h;
getAccelerant().queue("post", () -> getAccelerant().queue("post", () ->
{ {
for(IrisPostBlockFilter f : filters) patcher.onPost(rxx, rzz, x, z, terrain, q);
{
if(f.getPhase() == hh)
{
f.onPost(rxx, rzz, x, z, terrain);
}
}
}); });
} }
} }
getAccelerant().waitFor("post"); getAccelerant().waitFor("post");
for(IrisPostBlockFilter f : filters) for(Runnable v : q)
{ {
if(f.getPhase() == h) v.run();
{
while(f.getQueue().size() > 0)
{
try
{
f.getQueue().pop().run();
}
catch(Throwable e)
{
}
}
}
}
} }
p.end(); p.end();
getMetrics().getPost().put(p.getMilliseconds()); getMetrics().getPost().put(p.getMilliseconds());
} }
public IrisPostBlockFilter createProcessor(String processor, int phase)
{
if(processor.equals("floating-block-remover"))
{
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);
}
if(processor.equals("pothole-filler"))
{
return new PostPotholeFiller(this, phase);
}
if(processor.equals("slabber"))
{
return new PostSlabber(this, phase);
}
if(processor.equals("wall-painter"))
{
return new PostWallPatcher(this, phase);
}
if(processor.equals("waterlogger"))
{
return new PostWaterlogger(this, phase);
}
Iris.error("Failed to find post processor: " + processor);
fail(new RuntimeException("Failed to find post processor: " + processor));
return null;
}
@Override @Override
public void updateHeight(int x, int z, int h) public void updateHeight(int x, int z, int h)
{ {

View File

@ -286,6 +286,13 @@ public abstract class TopographicTerrainProvider extends ParallelTerrainProvider
// Carve out biomes // Carve out biomes
KList<CaveResult> caveResults = glCave.genCaves(rx, rz, x, z, sliver); KList<CaveResult> caveResults = glCave.genCaves(rx, rz, x, z, sliver);
KList<CaveResult> caveResults1 = glCave.genCaves(rx, rz, x, z, null);
if(caveResults.size() != caveResults1.size())
{
Iris.warn("REAL: " + caveResults.size() + " Guess: " + caveResults1.size());
}
IrisBiome caveBiome = glBiome.generateData(InferredType.CAVE, wx, wz, rx, rz, region); IrisBiome caveBiome = glBiome.generateData(InferredType.CAVE, wx, wz, rx, rz, region);
// Decorate Cave Biome Height Sections // Decorate Cave Biome Height Sections

View File

@ -4,6 +4,7 @@ import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import com.volmit.iris.gen.DimensionalTerrainProvider; import com.volmit.iris.gen.DimensionalTerrainProvider;
import com.volmit.iris.gen.IrisTerrainProvider;
import com.volmit.iris.gen.atomics.AtomicSliver; import com.volmit.iris.gen.atomics.AtomicSliver;
import com.volmit.iris.noise.FastNoise; import com.volmit.iris.noise.FastNoise;
import com.volmit.iris.noise.FastNoise.CellularDistanceFunction; import com.volmit.iris.noise.FastNoise.CellularDistanceFunction;
@ -57,7 +58,7 @@ public class GenLayerCave extends GenLayer
{ {
double scale = layer.getCaveZoom(); double scale = layer.getCaveZoom();
int surface = data.getHighestBlock(); int surface = (int) Math.round(((IrisTerrainProvider) iris).getTerrainHeight((int) wxx, (int) wzz));
double wx = wxx + layer.getHorizontalSlope().get(rng, wxx, wzz); double wx = wxx + layer.getHorizontalSlope().get(rng, wxx, wzz);
double wz = wzz + layer.getHorizontalSlope().get(rng, -wzz, -wxx); double wz = wzz + layer.getHorizontalSlope().get(rng, -wzz, -wxx);
double baseWidth = (14 * scale); double baseWidth = (14 * scale);

View File

@ -1,14 +0,0 @@
package com.volmit.iris.gen.post;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Retention(RUNTIME)
@Target(TYPE)
public @interface Post
{
String value();
}

View File

@ -1,62 +0,0 @@
package com.volmit.iris.gen.post;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockTerrainProvider;
import com.volmit.iris.util.B;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IrisPostBlockFilter;
@Post("floating-block-remover")
public class PostFloatingNibDeleter extends IrisPostBlockFilter
{
private static final BlockData AIR = B.getBlockData("AIR");
@DontObfuscate
public PostFloatingNibDeleter(PostBlockTerrainProvider gen, int phase)
{
super(gen, phase);
}
@DontObfuscate
public PostFloatingNibDeleter(PostBlockTerrainProvider gen)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
int g = 0;
int h = highestTerrainBlock(x, z);
if(h < 1)
{
return;
}
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;
g += hd < h - 1 ? 1 : 0;
if(g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData))
{
setPostBlock(x, h, z, AIR, currentPostX, currentPostZ, currentData);
for(int i = h - 1; i > 0; i--)
{
if(!isAir(x, i, z, currentPostX, currentPostZ, currentData))
{
updateHeight(x, z, i);
break;
}
}
}
}
}

View File

@ -1,45 +0,0 @@
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.PostBlockTerrainProvider;
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(PostBlockTerrainProvider gen, int phase)
{
super(gen, phase);
}
@DontObfuscate
public PostFoliageCleaner(PostBlockTerrainProvider 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

@ -0,0 +1,407 @@
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.block.data.type.Slab;
import org.bukkit.block.data.type.Slab.Type;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockTerrainProvider;
import com.volmit.iris.object.InferredType;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.util.B;
import com.volmit.iris.util.CaveResult;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IrisPostBlockFilter;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.RNG;
public class PostMasterPatcher extends IrisPostBlockFilter
{
private static final BlockData WATER = B.getBlockData("WATER");
private static final BlockData AIR = B.getBlockData("AIR");
private RNG rng;
@DontObfuscate
public PostMasterPatcher(PostBlockTerrainProvider gen, int phase)
{
super(gen, phase);
rng = gen.getMasterRandom().nextParallelRNG(1239456);
}
@DontObfuscate
public PostMasterPatcher(PostBlockTerrainProvider gen)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData, KList<Runnable> q)
{
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);
// Floating Nibs
int g = 0;
if(h < 1)
{
return;
}
g += ha < h - 1 ? 1 : 0;
g += hb < h - 1 ? 1 : 0;
g += hc < h - 1 ? 1 : 0;
g += hd < h - 1 ? 1 : 0;
if(g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData))
{
setPostBlock(x, h, z, AIR, currentPostX, currentPostZ, currentData);
for(int i = h - 1; i > 0; i--)
{
if(!isAir(x, i, z, currentPostX, currentPostZ, currentData))
{
updateHeight(x, z, i);
h = i;
break;
}
}
}
// Nibs
g = 0;
g += ha == h - 1 ? 1 : 0;
g += hb == h - 1 ? 1 : 0;
g += hc == h - 1 ? 1 : 0;
g += hd == h - 1 ? 1 : 0;
if(g >= 3)
{
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, currentPostX, currentPostZ, currentData);
updateHeight(x, z, h - 1);
h--;
}
}
else
{
// Potholes
g = 0;
g += ha == h + 1 ? 1 : 0;
g += hb == h + 1 ? 1 : 0;
g += hc == h + 1 ? 1 : 0;
g += hd == h + 1 ? 1 : 0;
if(g >= 3)
{
BlockData ba = getPostBlock(x, ha, z, currentPostX, currentPostZ, currentData);
BlockData bb = getPostBlock(x, hb, z, currentPostX, currentPostZ, currentData);
BlockData bc = getPostBlock(x, hc, z, currentPostX, currentPostZ, currentData);
BlockData bd = getPostBlock(x, hd, z, currentPostX, currentPostZ, currentData);
g = 0;
g = B.isSolid(ba) ? g + 1 : g;
g = B.isSolid(bb) ? g + 1 : g;
g = B.isSolid(bc) ? g + 1 : g;
g = B.isSolid(bd) ? g + 1 : g;
if(g >= 3)
{
setPostBlock(x, h + 1, z, getPostBlock(x, h, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData);
updateHeight(x, z, h + 1);
h++;
}
}
}
// Wall Patcher
IrisBiome biome = gen.sampleTrueBiome(x, z);
if(gen.getDimension().isPostProcessingWalls())
{
if(!biome.getWall().getPalette().isEmpty())
{
if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2)
{
boolean brokeGround = false;
int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd))));
for(int i = h; i > h - max; i--)
{
BlockData d = biome.getWall().get(rng, x + i, i + h, z + i);
if(d != null)
{
if(isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData))
{
if(brokeGround)
{
break;
}
continue;
}
setPostBlock(x, i, z, d, currentPostX, currentPostZ, currentData);
brokeGround = true;
}
}
}
}
}
// Slab
if(gen.getDimension().isPostProcessingSlabs())
{
//@builder
if((ha == h + 1 && isSolidNonSlab(x + 1, ha, z, currentPostX, currentPostZ, currentData))
|| (hb == h + 1 && isSolidNonSlab(x, hb, z + 1, currentPostX, currentPostZ, currentData))
|| (hc == h + 1 && isSolidNonSlab(x - 1, hc, z, currentPostX, currentPostZ, currentData))
|| (hd == h + 1 && isSolidNonSlab(x, hd, z - 1, currentPostX, currentPostZ, currentData)))
//@done
{
BlockData d = biome.getSlab().get(rng, x, h, z);
if(d != null)
{
boolean cancel = false;
if(B.isAir(d))
{
cancel = true;
}
if(d.getMaterial().equals(Material.SNOW) && h + 1 <= gen.getFluidHeight())
{
cancel = true;
}
if(isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData))
{
cancel = true;
}
if(!cancel && isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData))
{
setPostBlock(x, h + 1, z, d, currentPostX, currentPostZ, currentData);
updateHeight(x, z, h + 1);
h++;
}
}
}
}
// Waterlogging
BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
if(b instanceof Waterlogged)
{
Waterlogged ww = (Waterlogged) b;
boolean w = false;
if(isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData))
{
w = true;
}
else 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)))
{
w = true;
}
if(w != ww.isWaterlogged())
{
ww.setWaterlogged(w);
setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData);
}
}
else if(b.getMaterial().equals(Material.AIR) && h <= gen.getFluidHeight())
{
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, currentPostX, currentPostZ, currentData);
}
}
// Foliage
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);
}
}
if(gen.getDimension().isPostProcessCaves())
{
IrisBiome cave = gen.sampleTrueBiome(x, 1, z);
if(cave.getInferredType().equals(InferredType.CAVE))
{
for(CaveResult i : gen.getCaves(x, z))
{
if(i.getCeiling() > 256 || i.getFloor() < 0)
{
continue;
}
int f = i.getFloor();
int fa = nearestCaveFloor(f, x + 1, z, currentPostX, currentPostZ, currentData);
int fb = nearestCaveFloor(f, x, z + 1, currentPostX, currentPostZ, currentData);
int fc = nearestCaveFloor(f, x - 1, z, currentPostX, currentPostZ, currentData);
int fd = nearestCaveFloor(f, x, z - 1, currentPostX, currentPostZ, currentData);
int c = i.getCeiling();
int ca = nearestCaveCeiling(c, x + 1, z, currentPostX, currentPostZ, currentData);
int cb = nearestCaveCeiling(c, x, z + 1, currentPostX, currentPostZ, currentData);
int cc = nearestCaveCeiling(c, x - 1, z, currentPostX, currentPostZ, currentData);
int cd = nearestCaveCeiling(c, x, z - 1, currentPostX, currentPostZ, currentData);
if(gen.getDimension().isPostProcessingSlabs())
{
//@builder
if((fa == f + 1 && isSolidNonSlab(x + 1, fa, z, currentPostX, currentPostZ, currentData))
|| (fb == f + 1 && isSolidNonSlab(x, fb, z + 1, currentPostX, currentPostZ, currentData))
|| (fc == f + 1 && isSolidNonSlab(x - 1, fc, z, currentPostX, currentPostZ, currentData))
|| (fd == f + 1 && isSolidNonSlab(x, fd, z - 1, currentPostX, currentPostZ, currentData)))
//@done
{
BlockData d = cave.getSlab().get(rng, x, f, z);
if(d != null)
{
boolean cancel = false;
if(B.isAir(d))
{
cancel = true;
}
if(d.getMaterial().equals(Material.SNOW) && f + 1 <= gen.getFluidHeight())
{
cancel = true;
}
if(isSnowLayer(x, f, z, currentPostX, currentPostZ, currentData))
{
cancel = true;
}
if(!cancel && isAirOrWater(x, f + 1, z, currentPostX, currentPostZ, currentData))
{
setPostBlock(x, f + 1, z, d, currentPostX, currentPostZ, currentData);
}
}
}
//@builder
if((ca == c - 1 && isSolidNonSlab(x + 1, ca, z, currentPostX, currentPostZ, currentData))
|| (cb == c - 1 && isSolidNonSlab(x, cb, z + 1, currentPostX, currentPostZ, currentData))
|| (cc == c - 1 && isSolidNonSlab(x - 1, cc, z, currentPostX, currentPostZ, currentData))
|| (cd == c - 1 && isSolidNonSlab(x, cd, z - 1, currentPostX, currentPostZ, currentData)))
//@done
{
BlockData d = cave.getSlab().get(rng, x, c, z);
if(d != null)
{
boolean cancel = false;
if(B.isAir(d))
{
cancel = true;
}
if(!(d instanceof Slab))
{
cancel = true;
}
if(isSnowLayer(x, c, z, currentPostX, currentPostZ, currentData))
{
cancel = true;
}
if(!cancel && isAirOrWater(x, c, z, currentPostX, currentPostZ, currentData))
{
Slab slab = (Slab) d.clone();
slab.setType(Type.TOP);
setPostBlock(x, c, z, slab, currentPostX, currentPostZ, currentData);
}
}
}
}
}
}
}
}
private int nearestCaveFloor(int floor, int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
if(B.isAir(getPostBlock(x, floor, z, currentPostX, currentPostZ, currentData)))
{
if(B.isAir(getPostBlock(x, floor - 1, z, currentPostX, currentPostZ, currentData)))
{
return floor - 2;
}
return floor - 1;
}
else
{
if(!B.isAir(getPostBlock(x, floor + 1, z, currentPostX, currentPostZ, currentData)))
{
if(!B.isAir(getPostBlock(x, floor + 2, z, currentPostX, currentPostZ, currentData)))
{
return floor + 2;
}
return floor + 1;
}
return floor;
}
}
private int nearestCaveCeiling(int ceiling, int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
if(B.isAir(getPostBlock(x, ceiling, z, currentPostX, currentPostZ, currentData)))
{
if(B.isAir(getPostBlock(x, ceiling + 1, z, currentPostX, currentPostZ, currentData)))
{
return ceiling + 2;
}
return ceiling + 1;
}
else
{
if(!B.isAir(getPostBlock(x, ceiling - 1, z, currentPostX, currentPostZ, currentData)))
{
if(!B.isAir(getPostBlock(x, ceiling - 2, z, currentPostX, currentPostZ, currentData)))
{
return ceiling - 2;
}
return ceiling - 1;
}
return ceiling;
}
}
}

View File

@ -1,53 +0,0 @@
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.PostBlockTerrainProvider;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IrisPostBlockFilter;
@Post("nib-smoother")
public class PostNibSmoother extends IrisPostBlockFilter
{
@DontObfuscate
public PostNibSmoother(PostBlockTerrainProvider gen, int phase)
{
super(gen, phase);
}
@DontObfuscate
public PostNibSmoother(PostBlockTerrainProvider gen)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
int g = 0;
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;
g += hd == h - 1 ? 1 : 0;
if(g >= 3)
{
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, currentPostX, currentPostZ, currentData);
updateHeight(x, z, h - 1);
}
}
}
}

View File

@ -1,44 +0,0 @@
package com.volmit.iris.gen.post;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockTerrainProvider;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IrisPostBlockFilter;
@Post("pothole-filler")
public class PostPotholeFiller extends IrisPostBlockFilter
{
@DontObfuscate
public PostPotholeFiller(PostBlockTerrainProvider gen, int phase)
{
super(gen, phase);
}
@DontObfuscate
public PostPotholeFiller(PostBlockTerrainProvider gen)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
int g = 0;
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;
g += hd == h + 1 ? 1 : 0;
if(g >= 3)
{
setPostBlock(x, h + 1, z, getPostBlock(x, h, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData);
updateHeight(x, z, h + 1);
}
}
}

View File

@ -1,70 +0,0 @@
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.PostBlockTerrainProvider;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IrisPostBlockFilter;
import com.volmit.iris.util.RNG;
@Post("slabber")
public class PostSlabber extends IrisPostBlockFilter
{
public static final Material AIR = Material.AIR;
public static final Material WATER = Material.WATER;
private RNG rng;
@DontObfuscate
public PostSlabber(PostBlockTerrainProvider gen, int phase)
{
super(gen, phase);
rng = gen.getMasterRandom().nextParallelRNG(166456);
}
@DontObfuscate
public PostSlabber(PostBlockTerrainProvider gen)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
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)))
{
BlockData d = gen.sampleTrueBiome(x, z).getSlab().get(rng, x, h, z);
if(d != null)
{
if(d.getMaterial().equals(AIR))
{
return;
}
if(d.getMaterial().equals(Material.SNOW) && h + 1 <= gen.getFluidHeight())
{
return;
}
if(isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData))
{
return;
}
if(isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData))
{
setPostBlock(x, h + 1, z, d, currentPostX, currentPostZ, currentData);
updateHeight(x, z, h + 1);
}
}
}
}
}

View File

@ -1,74 +0,0 @@
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.PostBlockTerrainProvider;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IrisPostBlockFilter;
import com.volmit.iris.util.RNG;
@Post("wall-painter")
public class PostWallPatcher extends IrisPostBlockFilter
{
public static final Material AIR = Material.AIR;
private RNG rng;
@DontObfuscate
public PostWallPatcher(PostBlockTerrainProvider gen, int phase)
{
super(gen, phase);
rng = gen.getMasterRandom().nextParallelRNG(1239456);
}
@DontObfuscate
public PostWallPatcher(PostBlockTerrainProvider gen)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
IrisBiome biome = gen.sampleTrueBiome(x, z);
int h, ha, hb, hc, hd;
if(!biome.getWall().getPalette().isEmpty())
{
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)
{
boolean brokeGround = false;
int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd))));
for(int i = h; i > h - max; i--)
{
BlockData d = biome.getWall().get(rng, x + i, i + h, z + i);
if(d != null)
{
if(isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData))
{
if(brokeGround)
{
return;
}
continue;
}
setPostBlock(x, i, z, d, currentPostX, currentPostZ, currentData);
brokeGround = true;
}
}
}
}
}
}

View File

@ -1,65 +0,0 @@
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.PostBlockTerrainProvider;
import com.volmit.iris.util.B;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IrisPostBlockFilter;
@Post("waterlogger")
public class PostWaterlogger extends IrisPostBlockFilter
{
private static final BlockData WATER = B.getBlockData("WATER");
@DontObfuscate
public PostWaterlogger(PostBlockTerrainProvider gen, int phase)
{
super(gen, phase);
}
@DontObfuscate
public PostWaterlogger(PostBlockTerrainProvider gen)
{
super(gen);
}
@Override
public void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
int h = highestTerrainOrCarvingBlock(x, z);
BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
if(b instanceof Waterlogged)
{
Waterlogged ww = (Waterlogged) b;
boolean w = false;
if(isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData))
{
w = true;
}
else 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)))
{
w = true;
}
if(w != ww.isWaterlogged())
{
ww.setWaterlogged(w);
setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData);
}
}
else if(b.getMaterial().equals(Material.AIR) && h <= gen.getFluidHeight())
{
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, currentPostX, currentPostZ, currentData);
}
}
}
}

View File

@ -8,7 +8,6 @@ import org.bukkit.util.BlockVector;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.gen.ContextualTerrainProvider; import com.volmit.iris.gen.ContextualTerrainProvider;
import com.volmit.iris.gen.ParallelTerrainProvider; import com.volmit.iris.gen.ParallelTerrainProvider;
import com.volmit.iris.gen.PostBlockTerrainProvider;
import com.volmit.iris.gen.atomics.AtomicCache; import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.noise.CNG; import com.volmit.iris.noise.CNG;
import com.volmit.iris.util.ArrayType; import com.volmit.iris.util.ArrayType;
@ -159,10 +158,17 @@ public class IrisDimension extends IrisRegistrant
@Desc("Use post processing or not") @Desc("Use post processing or not")
private boolean postProcessing = true; private boolean postProcessing = true;
@ArrayType(min = 1, type = IrisPostProcessor.class)
@DontObfuscate @DontObfuscate
@Desc("Post Processors") @Desc("Add slabs in post processing")
private KList<IrisPostProcessor> postProcessors = getDefaultPostProcessors(); private boolean postProcessingSlabs = true;
@DontObfuscate
@Desc("Add painted walls in post processing")
private boolean postProcessingWalls = true;
@DontObfuscate
@Desc("Use post processing for caves or not")
private boolean postProcessCaves = true;
@ArrayType(min = 1, type = IrisCompatabilityFilter.class) @ArrayType(min = 1, type = IrisCompatabilityFilter.class)
@DontObfuscate @DontObfuscate
@ -315,31 +321,6 @@ public class IrisDimension extends IrisRegistrant
private transient AtomicCache<Double> cosr = new AtomicCache<>(); private transient AtomicCache<Double> cosr = new AtomicCache<>();
private transient AtomicCache<Double> rad = new AtomicCache<>(); private transient AtomicCache<Double> rad = new AtomicCache<>();
public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockTerrainProvider g)
{
return cacheFilters.aquire(() ->
{
KList<IrisPostBlockFilter> cacheFilters = new KList<>();
for(IrisPostProcessor i : getPostProcessors())
{
cacheFilters.add(g.createProcessor(i.getProcessor(), i.getPhase()));
}
g.setMinPhase(0);
g.setMaxPhase(0);
for(IrisPostBlockFilter i : cacheFilters)
{
g.setMinPhase(Math.min(g.getMinPhase(), i.getPhase()));
g.setMaxPhase(Math.max(g.getMaxPhase(), i.getPhase()));
}
Iris.info("Post Processing: " + cacheFilters.size() + " filters. Phases: " + g.getMinPhase() + " - " + g.getMaxPhase());
return cacheFilters;
});
}
public static KList<IrisCompatabilityFilter> getDefaultCompatability() public static KList<IrisCompatabilityFilter> getDefaultCompatability()
{ {
KList<IrisCompatabilityFilter> filters = new KList<>(); KList<IrisCompatabilityFilter> filters = new KList<>();
@ -490,17 +471,6 @@ public class IrisDimension extends IrisRegistrant
}); });
} }
private KList<IrisPostProcessor> getDefaultPostProcessors()
{
KList<IrisPostProcessor> p = new KList<IrisPostProcessor>();
p.add(new IrisPostProcessor("wall-painter"));
p.add(new IrisPostProcessor("slabber"));
p.add(new IrisPostProcessor("waterlogger", 1));
return p;
}
public BlockData getRock(RNG rng, double x, double y, double z) public BlockData getRock(RNG rng, double x, double y, double z)
{ {
if(getRockData().isEmpty()) if(getRockData().isEmpty())

View File

@ -43,8 +43,7 @@ public class IrisEntityInitialSpawn
private transient AtomicCache<RNG> rng = new AtomicCache<>(); private transient AtomicCache<RNG> rng = new AtomicCache<>();
private transient AtomicCache<IrisEntity> ent = new AtomicCache<>(); private transient AtomicCache<IrisEntity> ent = new AtomicCache<>();
@SuppressWarnings("unused") public void spawn(ParallaxTerrainProvider gen, Chunk c, RNG rng)
public boolean spawn(ParallaxTerrainProvider gen, Chunk c, RNG rng)
{ {
int spawns = rng.i(1, rarity) == 1 ? rng.i(minSpawns, maxSpawns) : 0; int spawns = rng.i(1, rarity) == 1 ? rng.i(minSpawns, maxSpawns) : 0;
@ -55,11 +54,9 @@ public class IrisEntityInitialSpawn
int x = (c.getX() * 16) + rng.i(15); int x = (c.getX() * 16) + rng.i(15);
int z = (c.getZ() * 16) + rng.i(15); int z = (c.getZ() * 16) + rng.i(15);
int h = gen.getCarvedHeight(x, z, false); int h = gen.getCarvedHeight(x, z, false);
return spawn100(gen, new Location(c.getWorld(), x, h, z)) != null; spawn100(gen, new Location(c.getWorld(), x, h, z));
} }
} }
return false;
} }
public IrisEntity getRealEntity(ParallaxTerrainProvider g) public IrisEntity getRealEntity(ParallaxTerrainProvider g)

View File

@ -8,7 +8,6 @@ import org.bukkit.block.data.type.Slab;
import org.bukkit.generator.ChunkGenerator.ChunkData; import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.gen.PostBlockTerrainProvider; import com.volmit.iris.gen.PostBlockTerrainProvider;
import com.volmit.iris.gen.post.Post;
import lombok.Data; import lombok.Data;
@ -17,16 +16,12 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess
{ {
public PostBlockTerrainProvider gen; public PostBlockTerrainProvider gen;
private int phase; private int phase;
private String key;
private KList<Runnable> queue = new KList<>();
@DontObfuscate @DontObfuscate
public IrisPostBlockFilter(PostBlockTerrainProvider gen, int phase) public IrisPostBlockFilter(PostBlockTerrainProvider gen, int phase)
{ {
this.gen = gen; this.gen = gen;
this.phase = phase; this.phase = phase;
queue = new KList<>();
key = getClass().getDeclaredAnnotation(Post.class).value();
} }
@DontObfuscate @DontObfuscate
@ -35,7 +30,7 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess
this(gen, 0); this(gen, 0);
} }
public abstract void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData); public abstract void onPost(int x, int z, int currentPostX, int currentPostZ, ChunkData currentData, KList<Runnable> q);
@Override @Override
public BlockData getPostBlock(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) public BlockData getPostBlock(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
@ -84,6 +79,12 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess
return d.getMaterial().isSolid(); return d.getMaterial().isSolid();
} }
public boolean isSolidNonSlab(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData)
{
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d.getMaterial().isSolid() && !(d instanceof Slab);
}
public boolean isAirOrWater(int x, int y, int z, int currentPostX, int currentPostZ, ChunkData currentData) public boolean isAirOrWater(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);
@ -126,11 +127,6 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess
return gen.caveFloors(x, z); return gen.caveFloors(x, z);
} }
public void queue(Runnable a)
{
queue.add(a);
}
@Override @Override
public void updateHeight(int x, int z, int h) public void updateHeight(int x, int z, int h)
{ {