mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Noise overlay support & Post Foliage Cleaner
This commit is contained in:
parent
fc55622cc8
commit
44d800de1e
@ -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<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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)))
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -251,6 +251,11 @@ public class IrisDimension extends IrisRegistrant
|
||||
@Desc("Define global deposit generators")
|
||||
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
|
||||
@Desc("The noise style for rock types")
|
||||
private IrisGeneratorStyle rockStyle = NoiseStyle.STATIC.style();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user