Total rotation support

This commit is contained in:
Daniel Mills
2020-08-01 08:46:52 -04:00
parent 71c90c6d31
commit f3d87f09d7
77 changed files with 264 additions and 178 deletions

View 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();
}

View File

@@ -0,0 +1,58 @@
package com.volmit.iris.layer.post;
import org.bukkit.block.data.BlockData;
import com.volmit.iris.generator.PostBlockChunkGenerator;
import com.volmit.iris.util.BlockDataTools;
import com.volmit.iris.util.IrisPostBlockFilter;
@Post("floating-block-remover")
public class PostFloatingNibDeleter extends IrisPostBlockFilter
{
private static final BlockData AIR = BlockDataTools.getBlockData("AIR");
public PostFloatingNibDeleter(PostBlockChunkGenerator gen, int phase)
{
super(gen, phase);
}
public PostFloatingNibDeleter(PostBlockChunkGenerator gen)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z)
{
int g = 0;
int h = highestTerrainBlock(x, z);
if(h < 1)
{
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);
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))
{
setPostBlock(x, h, z, AIR);
for(int i = h - 1; i > 0; i--)
{
if(!isAir(x, i, z))
{
updateHeight(x, z, i);
break;
}
}
}
}
}

View File

@@ -0,0 +1,49 @@
package com.volmit.iris.layer.post;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import com.volmit.iris.generator.PostBlockChunkGenerator;
import com.volmit.iris.util.IrisPostBlockFilter;
@Post("nib-smoother")
public class PostNibSmoother extends IrisPostBlockFilter
{
public PostNibSmoother(PostBlockChunkGenerator gen, int phase)
{
super(gen, phase);
}
public PostNibSmoother(PostBlockChunkGenerator gen)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z)
{
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);
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);
BlockData b = getPostBlock(x, h + 1, z);
Material m = bc.getMaterial();
if(m.isSolid())
{
setPostBlock(x, h, z, b);
updateHeight(x, z, h - 1);
}
}
}
}

View File

@@ -0,0 +1,39 @@
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)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z)
{
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);
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));
updateHeight(x, z, h + 1);
}
}
}

View File

@@ -0,0 +1,69 @@
package com.volmit.iris.layer.post;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
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)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z)
{
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);
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)))
{
BlockData d = gen.sampleTrueBiome(x, z).getBiome().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))
{
return;
}
if(isAirOrWater(x, h + 2, z))
{
queue(() ->
{
setPostBlock(x, h + 1, z, d);
updateHeight(x, z, h + 1);
});
}
}
}
}
}

View File

@@ -0,0 +1,78 @@
package com.volmit.iris.layer.post;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import com.volmit.iris.generator.PostBlockChunkGenerator;
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)
{
this(gen, 0);
}
@Override
public void onPost(int x, int z)
{
IrisBiome biome = gen.sampleTrueBiome(x, z).getBiome();
int h, ha, hb, hc, hd;
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);
if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2)
{
int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd))));
BlockData s = gen.sampleTrueBiome(x, z).getBiome().getSlab().get(rng, x, h, z);
if(s != null)
{
if(!s.getMaterial().equals(AIR))
{
setPostBlock(x, h + 1, z, s);
updateHeight(x, z, h + 1);
}
}
for(int i = h; i > h - max; i--)
{
BlockData d = biome.getWall().get(rng, x + i, i + h, z + i);
if(d != null)
{
if(d.getMaterial().equals(AIR))
{
continue;
}
if(isAirOrWater(x, i, z))
{
continue;
}
setPostBlock(x, i, z, d);
}
}
}
}
}
}

View File

@@ -0,0 +1,62 @@
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.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);
}
@Override
public void onPost(int x, int z)
{
int h = highestTerrainBlock(x, z);
BlockData b = getPostBlock(x, h, z);
if(b instanceof Waterlogged)
{
Waterlogged ww = (Waterlogged) b;
if(ww.isWaterlogged())
{
return;
}
if(isWaterOrWaterlogged(x, h + 1, z) && !ww.isWaterlogged())
{
ww.setWaterlogged(true);
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);
}
}
}
}