Tweaking carves

This commit is contained in:
Daniel Mills
2020-01-14 01:16:33 -05:00
parent 8e28c59163
commit 90846401a5
18 changed files with 449 additions and 224 deletions

View File

@@ -8,6 +8,7 @@ import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import net.md_5.bungee.api.ChatColor;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.iris.generator.genobject.GenObjectDecorator;
@@ -19,8 +20,8 @@ import ninja.bytecode.iris.generator.layer.GenLayerCaves;
import ninja.bytecode.iris.generator.layer.GenLayerLayeredNoise;
import ninja.bytecode.iris.generator.layer.GenLayerRidge;
import ninja.bytecode.iris.generator.layer.GenLayerSnow;
import ninja.bytecode.iris.pack.CompiledDimension;
import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.iris.pack.IrisDimension;
import ninja.bytecode.iris.util.AtomicChunkData;
import ninja.bytecode.iris.util.ChunkPlan;
import ninja.bytecode.iris.util.IrisInterpolation;
@@ -64,21 +65,16 @@ public class IrisGenerator extends ParallelChunkGenerator
private GenLayerCarving glCarving;
private GenLayerSnow glSnow;
private RNG rTerrain;
private IrisDimension dim;
private CompiledDimension dim;
private World world;
private GMap<String, GenObjectGroup> schematicCache = new GMap<>();
public IrisGenerator()
{
this(Iris.getController(PackController.class).getDimensions().get("overworld"));
this(Iris.getController(PackController.class).getDimension("overworld"));
}
public GList<IrisBiome> getLoadedBiomes()
{
return internal;
}
public IrisGenerator(IrisDimension dim)
public IrisGenerator(CompiledDimension dim)
{
this.dim = dim;
L.i("Preparing Dimension: " + dim.getName() + " With " + dim.getBiomes().size() + " Biomes...");
@@ -91,7 +87,7 @@ public class IrisGenerator extends ParallelChunkGenerator
if(j.getName().equals(i.getName()))
{
internal.remove(j);
L.i("Internal Biome: " + j.getName() + " overwritten by dimension " + dim.getName());
L.i(ChatColor.LIGHT_PURPLE + "Internal Biome: " + ChatColor.WHITE+ j.getName() + ChatColor.LIGHT_PURPLE + " overwritten by dimension " + ChatColor.WHITE + dim.getName());
}
}
}
@@ -104,6 +100,11 @@ public class IrisGenerator extends ParallelChunkGenerator
}
}
public GList<IrisBiome> getLoadedBiomes()
{
return internal;
}
@Override
public void onInit(World world, Random random)
{
@@ -273,11 +274,6 @@ public class IrisGenerator extends ParallelChunkGenerator
return p;
}
public GenObjectGroup loadSchematics(String folder)
{
return Iris.getController(PackController.class).getGenObjectGroups().get(folder);
}
private double getBiomedHeight(int x, int z, ChunkPlan plan)
{
double xh = plan.getHeight(x, z);
@@ -321,4 +317,9 @@ public class IrisGenerator extends ParallelChunkGenerator
{
return glBase;
}
public CompiledDimension getDimension()
{
return dim;
}
}

View File

@@ -15,7 +15,6 @@ import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import mortar.compute.math.M;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.generator.placer.NMSPlacer;
import ninja.bytecode.iris.util.Direction;
import ninja.bytecode.iris.util.IPlacer;
@@ -38,14 +37,12 @@ public class GenObject
private BlockVector mount;
private int mountHeight;
private BlockVector shift;
private boolean cascading;
public GenObject(int w, int h, int d)
{
this.w = w;
this.h = h;
this.d = d;
cascading = false;
shift = new BlockVector();
s = new GMap<>();
centeredHeight = false;
@@ -137,40 +134,21 @@ public class GenObject
return d;
}
public int getAntiCascadeWidth()
public void read(InputStream in, boolean gzip) throws IOException
{
if(isCascading())
{
return -1;
}
return 16 - w;
}
public int getAntiCascadeDepth()
{
if(isCascading())
{
return -1;
}
return 16 - d;
}
public boolean isCascading()
{
return cascading;
@SuppressWarnings("resource")
GZIPInputStream gzi = gzip ? new GZIPInputStream(in) : null;
DataInputStream din = new DataInputStream(gzip ? gzi : in);
readDirect(din);
din.close();
}
@SuppressWarnings("deprecation")
public void read(InputStream in) throws IOException
public void readDirect(DataInputStream din) throws IOException
{
GZIPInputStream gzi = new GZIPInputStream(in);
DataInputStream din = new DataInputStream(gzi);
w = din.readInt();
h = din.readInt();
d = din.readInt();
cascading = w > Iris.settings.performance.cascadeLimit || d > Iris.settings.performance.cascadeLimit;
int l = din.readInt();
clear();
@@ -178,15 +156,11 @@ public class GenObject
{
s.put(new BlockVector(din.readInt(), din.readInt(), din.readInt()), new MB(Material.getMaterial((int) din.readInt()), din.readInt()));
}
din.close();
}
@SuppressWarnings("deprecation")
public void write(OutputStream out) throws IOException
public void writeDirect(DataOutputStream dos) throws IOException
{
CustomOutputStream cos = new CustomOutputStream(out, 9);
DataOutputStream dos = new DataOutputStream(cos);
dos.writeInt(w);
dos.writeInt(h);
dos.writeInt(d);
@@ -200,7 +174,13 @@ public class GenObject
dos.writeInt(s.get(i).material.getId());
dos.writeInt(s.get(i).data);
}
}
public void write(OutputStream out, boolean gzip) throws IOException
{
CustomOutputStream cos = gzip ? new CustomOutputStream(out, 9) : null;
DataOutputStream dos = new DataOutputStream(gzip ? cos : out);
writeDirect(dos);
dos.close();
}
@@ -319,7 +299,7 @@ public class GenObject
public static GenObject load(InputStream in) throws IOException
{
GenObject s = new GenObject(1, 1, 1);
s.read(in);
s.read(in, true);
return s;
}
@@ -329,7 +309,7 @@ public class GenObject
GenObject s = new GenObject(1, 1, 1);
s.name = f.getName().replaceAll("\\Q.ish\\E", "");
FileInputStream fin = new FileInputStream(f);
s.read(fin);
s.read(fin, true);
return s;
}

View File

@@ -47,25 +47,13 @@ public class GenObjectDecorator extends BlockPopulator
for(String j : i.getSchematicGroups().k())
{
double c = i.getSchematicGroups().get(j);
try
{
GenObjectGroup g = Iris.getController(PackController.class).getGenObjectGroups().get(j);
GenObjectGroup g = generator.getDimension().getObjectGroup(j);
if(i.isSnowy())
{
String v = g.getName() + "-" + i.getSnow();
if(!snowCache.containsKey(v))
{
GenObjectGroup gog = g.copy("-snowy-" + i.getSnow());
gog.applySnowFilter((int) (i.getSnow() * 4));
snowCache.put(v, gog);
}
g = snowCache.get(v);
}
gc.put(g, i.getSchematicGroups().get(j));
gc.put(g, c);
}
catch(Throwable e)

View File

@@ -1,8 +1,13 @@
package ninja.bytecode.iris.generator.genobject;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
import net.md_5.bungee.api.ChatColor;
import ninja.bytecode.iris.Iris;
@@ -20,21 +25,75 @@ public class GenObjectGroup
private GList<GenObject> schematics;
private GList<String> flags;
private String name;
private int priority;
private boolean noCascade;
public GenObjectGroup(String name)
{
this.schematics = new GList<>();
this.flags = new GList<>();
priority = 0;
this.name = name;
this.noCascade = false;
}
public void read(DataInputStream din) throws IOException
{
flags.clear();
schematics.clear();
name = din.readUTF();
int fl = din.readInt();
int sc = din.readInt();
for(int i = 0; i < fl; i++)
{
flags.add(din.readUTF());
}
for(int i = 0; i < sc; i++)
{
GenObject g = new GenObject(0, 0, 0);
g.readDirect(din);
schematics.add(g);
}
}
public void write(DataOutputStream dos, Consumer<Double> progress) throws IOException
{
dos.writeUTF(name);
dos.writeInt(flags.size());
dos.writeInt(schematics.size());
for(String i : flags)
{
dos.writeUTF(i);
}
int of = 0;
if(progress != null)
{
progress.accept((double) of / (double) schematics.size());
}
for(GenObject i : schematics)
{
i.writeDirect(dos);
of++;
if(progress != null)
{
progress.accept((double) of / (double) schematics.size());
}
}
}
public void applySnowFilter(int factor)
{
if(flags.contains("no snow"))
{
L.i(ChatColor.DARK_AQUA + "Skipping Snow Filter for " + ChatColor.GRAY + getName());
return;
}
L.i(ChatColor.AQUA + "Applying Snow Filter to " + ChatColor.WHITE + getName());
for(GenObject i : schematics)
{
i.applySnowFilter(factor);
@@ -46,8 +105,6 @@ public class GenObjectGroup
GenObjectGroup gog = new GenObjectGroup(name + suffix);
gog.schematics = new GList<>();
gog.flags = flags.copy();
gog.priority = priority;
gog.noCascade = noCascade;
for(GenObject i : schematics)
{
@@ -89,16 +146,6 @@ public class GenObjectGroup
this.flags = flags;
}
public int getPriority()
{
return priority;
}
public void setPriority(int priority)
{
this.priority = priority;
}
public int size()
{
return getSchematics().size();
@@ -192,62 +239,7 @@ public class GenObjectGroup
gg.execute();
ex.close();
noCascade = true;
for(GenObject i : getSchematics())
{
if(i.isCascading())
{
noCascade = false;
break;
}
}
L.i(ChatColor.LIGHT_PURPLE + "Processed " + ChatColor.WHITE + F.f(schematics.size()) + ChatColor.LIGHT_PURPLE + " Schematics in " + ChatColor.WHITE + name + (noCascade ? ChatColor.AQUA + "*" : ChatColor.YELLOW + "^"));
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((flags == null) ? 0 : flags.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + priority;
return result;
}
@Override
public boolean equals(Object obj)
{
if(this == obj)
return true;
if(obj == null)
return false;
if(getClass() != obj.getClass())
return false;
GenObjectGroup other = (GenObjectGroup) obj;
if(flags == null)
{
if(other.flags != null)
return false;
}
else if(!flags.equals(other.flags))
return false;
if(name == null)
{
if(other.name != null)
return false;
}
else if(!name.equals(other.name))
return false;
if(priority != other.priority)
return false;
return true;
}
public boolean isCascading()
{
return !noCascade;
L.i(ChatColor.LIGHT_PURPLE + "Processed " + ChatColor.WHITE + F.f(schematics.size()) + ChatColor.LIGHT_PURPLE + " Schematics in " + ChatColor.WHITE + name);
}
}

View File

@@ -25,25 +25,25 @@ public class GenLayerCarving extends GenLayer
super(iris, world, random, rng);
//@builder
carver = new CNG(rng.nextParallelRNG(116), 1D, 3)
.scale(0.0135)
.scale(0.0285)
.amp(0.5)
.freq(1.1)
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 3)
.scale(0.018)
.scale(0.005)
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
.scale(0.1))
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 3)
.scale(0.15), 24), 44);
.scale(0.08), 12), 33);
clipper = new CNG(rng.nextParallelRNG(117), 1D, 1)
.scale(0.005)
.amp(0.5)
.scale(0.0009)
.amp(0.0)
.freq(1.1)
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 3)
.scale(0.018)
.scale(0.005)
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
.scale(0.1))
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 3)
.scale(0.15), 24), 44);
.scale(0.08), 12), 33);
//@done
}
@@ -87,7 +87,7 @@ public class GenLayerCarving extends GenLayer
continue;
}
if(carver.noise(wxx, i, wzx) < IrisInterpolation.lerpBezier(0.01, 0.465, hill))
if(carver.noise(wxx, i, wzx) < IrisInterpolation.lerpBezier(0.01, 0.425, hill))
{
carved++;
g.setBlock(x, i, z, Material.AIR);
@@ -97,6 +97,8 @@ public class GenLayerCarving extends GenLayer
if(carved > 4)
{
boolean fail = false;
for(int i = Iris.settings.gen.maxCarvingHeight; i > Iris.settings.gen.minCarvingHeight; i--)
{
Material m = g.getType(x, i, z);
@@ -106,14 +108,44 @@ public class GenLayerCarving extends GenLayer
if(hit == 1)
{
MB mb = biome.getSurface(wxx, wzx, g.getRTerrain());
g.setBlock(x, i, z, mb.material, mb.data);
fail = false;
if(i > 5)
{
for(int j = i; j > i - 5; j--)
{
if(g.getType(x, j, z).equals(Material.AIR))
{
fail = true;
break;
}
}
}
if(!fail)
{
MB mb = biome.getSurface(wxx, wzx, g.getRTerrain());
g.setBlock(x, i, z, mb.material, mb.data);
}
else
{
g.setBlock(x, i, z, Material.AIR);
}
}
else if(hit > 1 && hit < g.getGlBase().scatterInt(x, i, z, 4) + 3)
{
MB mb = biome.getDirtRNG();
g.setBlock(x, i, z, mb.material, mb.data);
if(!fail)
{
MB mb = biome.getDirtRNG();
g.setBlock(x, i, z, mb.material, mb.data);
}
else
{
g.setBlock(x, i, z, Material.AIR);
}
}
}

View File

@@ -18,12 +18,12 @@ public class GenLayerLayeredNoise extends GenLayer
{
//@builder
super(iris, world, random, rng);
fract = new CNG(rng.nextParallelRNG(16), 1D, 3).scale(0.0181);
gen = new CNG(rng.nextParallelRNG(17), 0.19D, 6)
fract = new CNG(rng.nextParallelRNG(16), 1D, 9).scale(0.0181);
gen = new CNG(rng.nextParallelRNG(17), 0.19D, 12)
.scale(0.012)
.amp(0.5)
.freq(1.1)
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 3)
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 5)
.scale(0.018)
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
.scale(0.1))