mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Fix post
This commit is contained in:
parent
7d4b980e59
commit
0ecde9531e
@ -6,8 +6,8 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.layer.post.PostFloatingNippleDeleter;
|
||||
import com.volmit.iris.layer.post.PostNippleSmoother;
|
||||
import com.volmit.iris.layer.post.PostFloatingNibDeleter;
|
||||
import com.volmit.iris.layer.post.PostNibSmoother;
|
||||
import com.volmit.iris.layer.post.PostPotholeFiller;
|
||||
import com.volmit.iris.layer.post.PostSlabber;
|
||||
import com.volmit.iris.layer.post.PostWallPatcher;
|
||||
@ -20,6 +20,11 @@ import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator implements IPostBlockAccess
|
||||
{
|
||||
protected boolean generatingCeiling = false;
|
||||
@ -32,6 +37,8 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
|
||||
private KList<IrisPostBlockFilter> filters;
|
||||
private String postKey;
|
||||
private ReentrantLock lock;
|
||||
private int minPhase;
|
||||
private int maxPhase;
|
||||
|
||||
public PostBlockChunkGenerator(String dimensionName, int threads)
|
||||
{
|
||||
@ -44,12 +51,23 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
|
||||
public void onInit(World world, RNG rng)
|
||||
{
|
||||
super.onInit(world, rng);
|
||||
filters.add(new PostNippleSmoother(this));
|
||||
filters.add(new PostFloatingNippleDeleter(this));
|
||||
filters.add(new PostNibSmoother(this));
|
||||
filters.add(new PostFloatingNibDeleter(this));
|
||||
filters.add(new PostPotholeFiller(this));
|
||||
filters.add(new PostSlabber(this));
|
||||
filters.add(new PostWallPatcher(this));
|
||||
filters.add(new PostWaterlogger(this));
|
||||
filters.add(new PostSlabber(this));
|
||||
filters.add(new PostWaterlogger(this, 2));
|
||||
|
||||
setMinPhase(0);
|
||||
setMaxPhase(0);
|
||||
|
||||
for(IrisPostBlockFilter i : filters)
|
||||
{
|
||||
setMinPhase(Math.min(getMinPhase(), i.getPhase()));
|
||||
setMaxPhase(Math.max(getMaxPhase(), i.getPhase()));
|
||||
}
|
||||
|
||||
Iris.info("Post Processing: " + filters.size() + " filters. Phases: " + getMinPhase() + " - " + getMaxPhase());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,29 +87,39 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
|
||||
for(i = 0; i < 16; i++)
|
||||
for(int h = getMinPhase(); h <= getMaxPhase(); h++)
|
||||
{
|
||||
rx = (x * 16) + i;
|
||||
|
||||
for(j = 0; j < 16; j++)
|
||||
for(i = 0; i < 16; i++)
|
||||
{
|
||||
int rxx = rx;
|
||||
int rzz = (z * 16) + j;
|
||||
rx = (x << 4) + i;
|
||||
|
||||
getAccelerant().queue(postKey, () ->
|
||||
for(j = 0; j < 16; j++)
|
||||
{
|
||||
int rxx = rx;
|
||||
int rzz = (z << 4) + j;
|
||||
|
||||
for(IrisPostBlockFilter f : filters)
|
||||
{
|
||||
int rxxx = rxx;
|
||||
int rzzx = rzz;
|
||||
|
||||
f.onPost(rxxx, rzzx);
|
||||
if(f.getPhase() == h)
|
||||
{
|
||||
f.onPost(rxx, rzz);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisPostBlockFilter f : filters)
|
||||
{
|
||||
if(f.getPhase() == h)
|
||||
{
|
||||
while(f.getQueue().size() > 0)
|
||||
{
|
||||
f.getQueue().pop().run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getAccelerant().waitFor(postKey);
|
||||
p.end();
|
||||
getMetrics().getPost().put(p.getMilliseconds());
|
||||
}
|
||||
@ -99,7 +127,15 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
|
||||
@Override
|
||||
public void updateHeight(int x, int z, int h)
|
||||
{
|
||||
getCacheHeightMap()[(z << 4) | x] = h;
|
||||
if(x >> 4 == currentPostX && z >> 4 == currentPostZ)
|
||||
{
|
||||
getCacheHeightMap()[((z & 15) << 4) | (x & 15)] = h;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Iris.error("Invalid Heightmap set! Chunk Currently at " + currentPostX + "," + currentPostZ + ". Attempted to place at " + (x >> 4) + " " + (z >> 4) + " which is bad.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
14
src/main/java/com/volmit/iris/layer/post/Post.java
Normal file
14
src/main/java/com/volmit/iris/layer/post/Post.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.volmit.iris.layer.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();
|
||||
}
|
@ -6,13 +6,19 @@ import com.volmit.iris.generator.PostBlockChunkGenerator;
|
||||
import com.volmit.iris.util.BlockDataTools;
|
||||
import com.volmit.iris.util.IrisPostBlockFilter;
|
||||
|
||||
public class PostFloatingNippleDeleter extends IrisPostBlockFilter
|
||||
@Post("floating-block-remover")
|
||||
public class PostFloatingNibDeleter extends IrisPostBlockFilter
|
||||
{
|
||||
private static final BlockData AIR = BlockDataTools.getBlockData("AIR");
|
||||
|
||||
public PostFloatingNippleDeleter(PostBlockChunkGenerator gen)
|
||||
public PostFloatingNibDeleter(PostBlockChunkGenerator gen, int phase)
|
||||
{
|
||||
super(gen);
|
||||
super(gen, phase);
|
||||
}
|
||||
|
||||
public PostFloatingNibDeleter(PostBlockChunkGenerator gen)
|
||||
{
|
||||
this(gen, 0);
|
||||
}
|
||||
|
||||
@Override
|
@ -6,11 +6,17 @@ import org.bukkit.block.data.BlockData;
|
||||
import com.volmit.iris.generator.PostBlockChunkGenerator;
|
||||
import com.volmit.iris.util.IrisPostBlockFilter;
|
||||
|
||||
public class PostNippleSmoother extends IrisPostBlockFilter
|
||||
@Post("nib-smoother")
|
||||
public class PostNibSmoother extends IrisPostBlockFilter
|
||||
{
|
||||
public PostNippleSmoother(PostBlockChunkGenerator gen)
|
||||
public PostNibSmoother(PostBlockChunkGenerator gen, int phase)
|
||||
{
|
||||
super(gen);
|
||||
super(gen, phase);
|
||||
}
|
||||
|
||||
public PostNibSmoother(PostBlockChunkGenerator gen)
|
||||
{
|
||||
this(gen, 0);
|
||||
}
|
||||
|
||||
@Override
|
@ -3,11 +3,17 @@ package com.volmit.iris.layer.post;
|
||||
import com.volmit.iris.generator.PostBlockChunkGenerator;
|
||||
import com.volmit.iris.util.IrisPostBlockFilter;
|
||||
|
||||
@Post("pothole-filler")
|
||||
public class PostPotholeFiller extends IrisPostBlockFilter
|
||||
{
|
||||
public PostPotholeFiller(PostBlockChunkGenerator gen, int phase)
|
||||
{
|
||||
super(gen, phase);
|
||||
}
|
||||
|
||||
public PostPotholeFiller(PostBlockChunkGenerator gen)
|
||||
{
|
||||
super(gen);
|
||||
this(gen, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,16 +7,22 @@ import com.volmit.iris.generator.PostBlockChunkGenerator;
|
||||
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;
|
||||
|
||||
public PostSlabber(PostBlockChunkGenerator gen, int phase)
|
||||
{
|
||||
super(gen, phase);
|
||||
rng = gen.getMasterRandom().nextParallelRNG(166456);
|
||||
}
|
||||
|
||||
public PostSlabber(PostBlockChunkGenerator gen)
|
||||
{
|
||||
super(gen);
|
||||
rng = gen.getMasterRandom().nextParallelRNG(1239456);
|
||||
this(gen, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,8 +47,11 @@ public class PostSlabber extends IrisPostBlockFilter
|
||||
|
||||
if(isAir(x, h + 2, z) || getPostBlock(x, h + 2, z).getMaterial().equals(WATER))
|
||||
{
|
||||
setPostBlock(x, h + 1, z, d);
|
||||
updateHeight(x, z, h + 1);
|
||||
queue(() ->
|
||||
{
|
||||
setPostBlock(x, h + 1, z, d);
|
||||
updateHeight(x, z, h + 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,15 +8,21 @@ import com.volmit.iris.object.IrisBiome;
|
||||
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;
|
||||
|
||||
public PostWallPatcher(PostBlockChunkGenerator gen, int phase)
|
||||
{
|
||||
super(gen, phase);
|
||||
rng = gen.getMasterRandom().nextParallelRNG(1239456);
|
||||
}
|
||||
|
||||
public PostWallPatcher(PostBlockChunkGenerator gen)
|
||||
{
|
||||
super(gen);
|
||||
rng = gen.getMasterRandom().nextParallelRNG(1239456);
|
||||
this(gen, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -40,8 +46,11 @@ public class PostWallPatcher extends IrisPostBlockFilter
|
||||
|
||||
if(s != null)
|
||||
{
|
||||
setPostBlock(x, h + 1, z, s);
|
||||
updateHeight(x, z, h + 1);
|
||||
if(!s.getMaterial().equals(AIR))
|
||||
{
|
||||
setPostBlock(x, h + 1, z, s);
|
||||
updateHeight(x, z, h + 1);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = h; i > h - max; i--)
|
||||
|
@ -1,14 +1,23 @@
|
||||
package com.volmit.iris.layer.post;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.generator.PostBlockChunkGenerator;
|
||||
import com.volmit.iris.util.BlockDataTools;
|
||||
import com.volmit.iris.util.IrisPostBlockFilter;
|
||||
|
||||
@Post("waterlogger")
|
||||
public class PostWaterlogger extends IrisPostBlockFilter
|
||||
{
|
||||
private static final BlockData WATER = BlockDataTools.getBlockData("WATER");
|
||||
|
||||
public PostWaterlogger(PostBlockChunkGenerator gen, int phase)
|
||||
{
|
||||
super(gen, phase);
|
||||
}
|
||||
|
||||
public PostWaterlogger(PostBlockChunkGenerator gen)
|
||||
{
|
||||
super(gen);
|
||||
@ -23,32 +32,31 @@ public class PostWaterlogger extends IrisPostBlockFilter
|
||||
if(b instanceof Waterlogged)
|
||||
{
|
||||
Waterlogged ww = (Waterlogged) b;
|
||||
boolean w = ww.isWaterlogged();
|
||||
|
||||
if(isWater(x, h + 1, z))
|
||||
if(ww.isWaterlogged())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(isWaterOrWaterlogged(x, h + 1, z) && !ww.isWaterlogged())
|
||||
{
|
||||
ww.setWaterlogged(true);
|
||||
}
|
||||
|
||||
else if(h < 98)
|
||||
{
|
||||
Iris.info("Data is " + getPostBlock(x, h + 1, z).getAsString());
|
||||
}
|
||||
|
||||
else if(isWater(x + 1, h, z) || isWater(x - 1, h, z) || isWater(x, h, z + 1) || isWater(x, h, z - 1))
|
||||
{
|
||||
ww.setWaterlogged(true);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ww.setWaterlogged(false);
|
||||
}
|
||||
|
||||
if(ww.isWaterlogged() != w)
|
||||
{
|
||||
setPostBlock(x, h, z, ww);
|
||||
}
|
||||
|
||||
else if(!ww.isWaterlogged() && (isWaterOrWaterlogged(x + 1, h, z) || isWaterOrWaterlogged(x - 1, h, z) || isWaterOrWaterlogged(x, h, z + 1) || isWaterOrWaterlogged(x, h, z - 1)))
|
||||
{
|
||||
ww.setWaterlogged(true);
|
||||
setPostBlock(x, h, z, ww);
|
||||
}
|
||||
}
|
||||
|
||||
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)))
|
||||
{
|
||||
setPostBlock(x, h, z, WATER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,16 @@ public class IrisBiomePaletteLayer
|
||||
cacheGenerator(rng);
|
||||
}
|
||||
|
||||
if(getBlockData().isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(getBlockData().size() == 1)
|
||||
{
|
||||
return getBlockData().get(0);
|
||||
}
|
||||
|
||||
if(layerGenerator != null)
|
||||
{
|
||||
if(dispersion.equals(Dispersion.SCATTER))
|
||||
@ -72,11 +82,6 @@ public class IrisBiomePaletteLayer
|
||||
}
|
||||
}
|
||||
|
||||
if(getBlockData().isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return getBlockData().get(0);
|
||||
}
|
||||
|
||||
|
@ -2,16 +2,31 @@ package com.volmit.iris.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
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 com.volmit.iris.generator.PostBlockChunkGenerator;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public abstract class IrisPostBlockFilter implements IPostBlockAccess
|
||||
{
|
||||
public PostBlockChunkGenerator gen;
|
||||
private int phase;
|
||||
private KList<Runnable> queue;
|
||||
|
||||
public IrisPostBlockFilter(PostBlockChunkGenerator gen, int phase)
|
||||
{
|
||||
this.gen = gen;
|
||||
this.phase = phase;
|
||||
queue = new KList<>();
|
||||
}
|
||||
|
||||
public IrisPostBlockFilter(PostBlockChunkGenerator gen)
|
||||
{
|
||||
this.gen = gen;
|
||||
this(gen, 0);
|
||||
}
|
||||
|
||||
public abstract void onPost(int x, int z);
|
||||
@ -46,18 +61,41 @@ public abstract class IrisPostBlockFilter implements IPostBlockAccess
|
||||
return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR);
|
||||
}
|
||||
|
||||
public boolean isSlab(int x, int y, int z)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z);
|
||||
return d instanceof Slab;
|
||||
}
|
||||
|
||||
public boolean isWater(int x, int y, int z)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z);
|
||||
return d.getMaterial().equals(Material.WATER);
|
||||
}
|
||||
|
||||
public boolean isWaterOrWaterlogged(int x, int y, int z)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z);
|
||||
return d.getMaterial().equals(Material.WATER) || (d instanceof Waterlogged && ((Waterlogged) d).isWaterlogged());
|
||||
}
|
||||
|
||||
public boolean isLiquid(int x, int y, int z)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z);
|
||||
return d instanceof Levelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KList<CaveResult> caveFloors(int x, int z)
|
||||
{
|
||||
return gen.caveFloors(x, z);
|
||||
}
|
||||
|
||||
public void queue(Runnable a)
|
||||
{
|
||||
queue.add(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHeight(int x, int z, int h)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user