mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Tweaking carves
This commit is contained in:
parent
8e28c59163
commit
90846401a5
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mortar.api.nms.NMP;
|
||||
import ninja.bytecode.iris.controller.PackController;
|
||||
import ninja.bytecode.iris.controller.TimingsController;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.pack.IrisBiome;
|
||||
|
@ -72,7 +72,7 @@ public class CommandIsh implements CommandExecutor
|
||||
try
|
||||
{
|
||||
FileOutputStream fos = new FileOutputStream(f);
|
||||
s.write(fos);
|
||||
s.write(fos, true);
|
||||
msg(p, "Saved " + args[1] + " (" + F.f(s.getSchematic().size()) + " Entries)");
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 0.45f);
|
||||
}
|
||||
@ -96,7 +96,7 @@ public class CommandIsh implements CommandExecutor
|
||||
try
|
||||
{
|
||||
FileInputStream fin = new FileInputStream(f);
|
||||
s.read(fin);
|
||||
s.read(fin, true);
|
||||
|
||||
boolean cursor = false;
|
||||
for(String i : args)
|
||||
|
@ -49,7 +49,7 @@ public class Iris extends JavaPlugin implements Listener
|
||||
|
||||
if(!settings.performance.debugMode)
|
||||
{
|
||||
getController(PackController.class).loadContent();
|
||||
getController(PackController.class).compile();
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,8 @@ public class Iris extends JavaPlugin implements Listener
|
||||
|
||||
public void reload()
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () ->
|
||||
{
|
||||
onDisable();
|
||||
onEnable();
|
||||
});
|
||||
|
@ -9,7 +9,7 @@ public class Settings
|
||||
|
||||
public static class PerformanceSettings
|
||||
{
|
||||
public PerformanceMode performanceMode = PerformanceMode.HALF_CPU;
|
||||
public PerformanceMode performanceMode = PerformanceMode.MATCH_CPU;
|
||||
public boolean fastDecoration = true;
|
||||
public int threadPriority = Thread.MIN_PRIORITY;
|
||||
public int compilerPriority = Thread.MIN_PRIORITY;
|
||||
@ -27,7 +27,7 @@ public class Settings
|
||||
public double beachScale = 76;
|
||||
public double landScale = 0.325;
|
||||
public double landChance = 0.62;
|
||||
public double roughness = 1;
|
||||
public double roughness = 1.25;
|
||||
public double heightMultiplier = 0.806;
|
||||
public double heightExponentBase = 1;
|
||||
public double heightExponentMultiplier = 1.41;
|
||||
@ -41,7 +41,7 @@ public class Settings
|
||||
public boolean flatBedrock = false;
|
||||
public boolean genObjects = true;
|
||||
public int minCarvingHeight = 75;
|
||||
public int maxCarvingHeight = 175;
|
||||
public int maxCarvingHeight = 155;
|
||||
public double carvingChance = 0.6;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class CommandIsh implements CommandExecutor
|
||||
try
|
||||
{
|
||||
FileOutputStream fos = new FileOutputStream(f);
|
||||
s.write(fos);
|
||||
s.write(fos, true);
|
||||
msg(p, "Saved " + args[1] + " (" + F.f(s.getSchematic().size()) + " Entries)");
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 0.45f);
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class CommandIsh implements CommandExecutor
|
||||
try
|
||||
{
|
||||
FileInputStream fin = new FileInputStream(f);
|
||||
s.read(fin);
|
||||
s.read(fin, true);
|
||||
|
||||
boolean cursor = false;
|
||||
for(String i : args)
|
||||
|
@ -71,7 +71,7 @@ public class DebugController implements IrisController
|
||||
}
|
||||
}, 1);
|
||||
});
|
||||
Iris.getController(PackController.class).loadContent();
|
||||
Iris.getController(PackController.class).compile();
|
||||
});
|
||||
}
|
||||
}, 1);
|
||||
|
@ -1,14 +1,21 @@
|
||||
package ninja.bytecode.iris.controller;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import mortar.logic.queue.ChronoLatch;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.genobject.GenObject;
|
||||
import ninja.bytecode.iris.generator.genobject.GenObjectGroup;
|
||||
import ninja.bytecode.iris.pack.CompiledDimension;
|
||||
import ninja.bytecode.iris.pack.IrisBiome;
|
||||
import ninja.bytecode.iris.pack.IrisDimension;
|
||||
import ninja.bytecode.iris.pack.IrisPack;
|
||||
@ -16,24 +23,29 @@ import ninja.bytecode.iris.util.IrisController;
|
||||
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
import ninja.bytecode.shuriken.execution.TaskExecutor;
|
||||
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
|
||||
import ninja.bytecode.shuriken.format.F;
|
||||
import ninja.bytecode.shuriken.io.IO;
|
||||
import ninja.bytecode.shuriken.io.VoidOutputStream;
|
||||
import ninja.bytecode.shuriken.json.JSONException;
|
||||
import ninja.bytecode.shuriken.json.JSONObject;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
|
||||
public class PackController implements IrisController
|
||||
{
|
||||
private GMap<String, CompiledDimension> compiledDimensions;
|
||||
private GMap<String, IrisDimension> dimensions;
|
||||
private GMap<String, IrisBiome> biomes;
|
||||
private GMap<String, GenObjectGroup> genObjectGroups;
|
||||
private ChronoLatch ll = new ChronoLatch(3000);
|
||||
private boolean ready;
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
compiledDimensions = new GMap<>();
|
||||
dimensions = new GMap<>();
|
||||
biomes = new GMap<>();
|
||||
genObjectGroups = new GMap<>();
|
||||
@ -51,14 +63,43 @@ public class PackController implements IrisController
|
||||
return ready;
|
||||
}
|
||||
|
||||
public void loadContent()
|
||||
public GList<File> getFiles(File folder)
|
||||
{
|
||||
GList<File> buf = new GList<File>();
|
||||
|
||||
if(!folder.exists())
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
|
||||
if(folder.isDirectory())
|
||||
{
|
||||
for(File i : folder.listFiles())
|
||||
{
|
||||
if(i.isFile())
|
||||
{
|
||||
buf.add(i);
|
||||
}
|
||||
|
||||
else if(i.isDirectory())
|
||||
{
|
||||
buf.addAll(getFiles(folder));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
public void compile()
|
||||
{
|
||||
dimensions = new GMap<>();
|
||||
biomes = new GMap<>();
|
||||
genObjectGroups = new GMap<>();
|
||||
ready = false;
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
L.i("Loading Content");
|
||||
File dims = new File(Iris.instance.getDataFolder(), "dimensions");
|
||||
dims.mkdirs();
|
||||
|
||||
try
|
||||
{
|
||||
@ -75,30 +116,65 @@ public class PackController implements IrisController
|
||||
|
||||
TaskExecutor exf = new TaskExecutor(Iris.settings.performance.compilerThreads, Iris.settings.performance.compilerPriority, "Iris Compiler");
|
||||
TaskGroup gg = exf.startWork();
|
||||
for(GenObjectGroup i : getGenObjectGroups().v())
|
||||
for(GenObjectGroup i : genObjectGroups.v())
|
||||
{
|
||||
gg.queue(i::processVariants);
|
||||
}
|
||||
|
||||
gg.execute();
|
||||
exf.close();
|
||||
int m = 0;
|
||||
|
||||
for(GenObjectGroup i : getGenObjectGroups().v())
|
||||
for(String i : dimensions.k())
|
||||
{
|
||||
m += i.size();
|
||||
IrisDimension id = dimensions.get(i);
|
||||
CompiledDimension d = new CompiledDimension(id);
|
||||
|
||||
for(IrisBiome j : id.getBiomes())
|
||||
{
|
||||
d.registerBiome(j);
|
||||
GList<String> g = j.getSchematicGroups().k();
|
||||
g.sort();
|
||||
|
||||
for(String k : g)
|
||||
{
|
||||
d.registerObject(genObjectGroups.get(k));
|
||||
|
||||
if(j.isSnowy())
|
||||
{
|
||||
GenObjectGroup ggx = genObjectGroups.get(k).copy("-snowy-" + j.getSnow());
|
||||
ggx.applySnowFilter((int) (j.getSnow() * 4));
|
||||
d.registerObject(ggx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
L.i(ChatColor.LIGHT_PURPLE + "Dimensions: " + ChatColor.WHITE + getDimensions().size());
|
||||
L.i(ChatColor.LIGHT_PURPLE + "Biomes: " + ChatColor.WHITE + getBiomes().size());
|
||||
L.i(ChatColor.LIGHT_PURPLE + "Object Groups: " + ChatColor.WHITE + F.f(getGenObjectGroups().size()));
|
||||
L.i(ChatColor.LIGHT_PURPLE + "Objects: " + ChatColor.WHITE + F.f(m));
|
||||
L.i(ChatColor.LIGHT_PURPLE + "Compilation Time: " + ChatColor.WHITE + F.duration(p.getMilliseconds(), 2));
|
||||
d.sort();
|
||||
compiledDimensions.put(i, d);
|
||||
}
|
||||
|
||||
for(String i : compiledDimensions.k())
|
||||
{
|
||||
CompiledDimension d = compiledDimensions.get(i);
|
||||
L.i(ChatColor.GREEN + i + ChatColor.WHITE + " (" + d.getEnvironment().toString().toLowerCase() + ")");
|
||||
L.i(ChatColor.DARK_GREEN + " Biomes: " + ChatColor.GRAY + F.f(d.getBiomes().size()));
|
||||
L.i(ChatColor.DARK_GREEN + " Objects: " + ChatColor.GRAY + F.f(d.countObjects()));
|
||||
L.flush();
|
||||
}
|
||||
|
||||
L.i("");
|
||||
L.i(ChatColor.LIGHT_PURPLE + "Compilation Time: " + ChatColor.WHITE + F.duration(p.getMilliseconds(), 2));
|
||||
L.i(ChatColor.GREEN + "Iris Dimensions Successfully Compiled!");
|
||||
L.i("");
|
||||
L.flush();
|
||||
|
||||
ready = true;
|
||||
}
|
||||
|
||||
public CompiledDimension getDimension(String name)
|
||||
{
|
||||
return compiledDimensions.get(name);
|
||||
}
|
||||
|
||||
public IrisDimension loadDimension(String s) throws JSONException, IOException
|
||||
{
|
||||
L.v(ChatColor.GOLD + "Loading Dimension: " + ChatColor.GRAY + "pack/dimensions/" + s + ".json");
|
||||
@ -118,7 +194,7 @@ public class PackController implements IrisController
|
||||
|
||||
if(g != null)
|
||||
{
|
||||
Iris.getController(PackController.class).getGenObjectGroups().put(s, g);
|
||||
Iris.getController(PackController.class).genObjectGroups.put(s, g);
|
||||
return g;
|
||||
}
|
||||
|
||||
@ -184,18 +260,19 @@ public class PackController implements IrisController
|
||||
return new File(System.getProperty("java.io.tmpdir") + "/Iris/" + resource);
|
||||
}
|
||||
|
||||
public GMap<String, IrisDimension> getDimensions()
|
||||
public void registerBiome(String name, IrisBiome biome)
|
||||
{
|
||||
return dimensions;
|
||||
biomes.put(name, biome);
|
||||
}
|
||||
|
||||
public GMap<String, IrisBiome> getBiomes()
|
||||
public void registerDimension(String i, IrisDimension d)
|
||||
{
|
||||
return biomes;
|
||||
dimensions.put(i, d);
|
||||
}
|
||||
|
||||
public GMap<String, GenObjectGroup> getGenObjectGroups()
|
||||
public void invalidate()
|
||||
{
|
||||
return genObjectGroups;
|
||||
J.attempt(() -> new File(Iris.instance.getDataFolder(), "dimensions").delete());
|
||||
compiledDimensions.clear();
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.WorldCreator;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.pack.IrisDimension;
|
||||
import ninja.bytecode.iris.pack.CompiledDimension;
|
||||
import ninja.bytecode.iris.util.IrisController;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
import ninja.bytecode.shuriken.io.IO;
|
||||
@ -42,11 +42,11 @@ public class WorldController implements IrisController
|
||||
|
||||
}
|
||||
|
||||
public World createIrisWorld(IrisDimension dimension, long seed, boolean temp)
|
||||
public World createIrisWorld(CompiledDimension dimension, long seed, boolean temp)
|
||||
{
|
||||
if(dimension == null)
|
||||
{
|
||||
dimension = Iris.getController(PackController.class).getDimensions().get("overworld");
|
||||
dimension = Iris.getController(PackController.class).getDimension("overworld");
|
||||
}
|
||||
|
||||
//@builder
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
.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);
|
||||
clipper = new CNG(rng.nextParallelRNG(117), 1D, 1)
|
||||
.scale(0.005)
|
||||
.amp(0.5)
|
||||
.freq(1.1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 3)
|
||||
.scale(0.018)
|
||||
.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.0009)
|
||||
.amp(0.0)
|
||||
.freq(1.1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 3)
|
||||
.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.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);
|
||||
@ -105,16 +107,46 @@ public class GenLayerCarving extends GenLayer
|
||||
hit++;
|
||||
|
||||
if(hit == 1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if(!fail)
|
||||
{
|
||||
MB mb = biome.getDirtRNG();
|
||||
g.setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
g.setBlock(x, i, z, Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -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))
|
||||
|
152
src/main/java/ninja/bytecode/iris/pack/CompiledDimension.java
Normal file
152
src/main/java/ninja/bytecode/iris/pack/CompiledDimension.java
Normal file
@ -0,0 +1,152 @@
|
||||
package ninja.bytecode.iris.pack;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import ninja.bytecode.iris.generator.genobject.GenObjectGroup;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.io.CustomOutputStream;
|
||||
import ninja.bytecode.shuriken.json.JSONObject;
|
||||
import ninja.bytecode.shuriken.reaction.O;
|
||||
|
||||
public class CompiledDimension
|
||||
{
|
||||
private IrisDimension dimension;
|
||||
private GList<IrisBiome> biomes;
|
||||
private GMap<String, GenObjectGroup> objects;
|
||||
|
||||
public CompiledDimension(IrisDimension dimension)
|
||||
{
|
||||
this.dimension = dimension;
|
||||
biomes = new GList<>();
|
||||
objects = new GMap<>();
|
||||
}
|
||||
|
||||
public void read(InputStream in) throws IOException
|
||||
{
|
||||
GZIPInputStream gin = new GZIPInputStream(in);
|
||||
DataInputStream din = new DataInputStream(gin);
|
||||
dimension = new IrisDimension();
|
||||
dimension.fromJSON(new JSONObject(din.readUTF()), false);
|
||||
int bi = din.readInt();
|
||||
int ob = din.readInt();
|
||||
|
||||
for(int i = 0; i < bi; i++)
|
||||
{
|
||||
IrisBiome b = new IrisBiome("Loading", Biome.VOID);
|
||||
b.fromJSON(new JSONObject(din.readUTF()), false);
|
||||
}
|
||||
|
||||
for(int i = 0; i < ob; i++)
|
||||
{
|
||||
GenObjectGroup g = new GenObjectGroup("Loading");
|
||||
g.read(din);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(OutputStream out, Consumer<Double> progress) throws IOException
|
||||
{
|
||||
GZIPOutputStream gzo = new CustomOutputStream(out, 1);
|
||||
DataOutputStream dos = new DataOutputStream(gzo);
|
||||
dos.writeUTF(dimension.toJSON().toString(0));
|
||||
dos.writeInt(biomes.size());
|
||||
dos.writeInt(objects.size());
|
||||
|
||||
for(IrisBiome i : biomes)
|
||||
{
|
||||
dos.writeUTF(i.toJSON().toString(0));
|
||||
}
|
||||
|
||||
O<Integer> tc = new O<>();
|
||||
O<Integer> oc = new O<>();
|
||||
O<Integer> cc = new O<>();
|
||||
tc.set(0);
|
||||
oc.set(0);
|
||||
cc.set(0);
|
||||
|
||||
for(GenObjectGroup i : objects.v())
|
||||
{
|
||||
tc.set(tc.get() + i.size());
|
||||
}
|
||||
|
||||
for(GenObjectGroup i : objects.v().shuffle())
|
||||
{
|
||||
i.write(dos, (o) ->
|
||||
{
|
||||
cc.set((int) (o * i.size()));
|
||||
|
||||
if(progress != null)
|
||||
{
|
||||
progress.accept((double) (oc.get() + cc.get()) / (double) tc.get());
|
||||
}
|
||||
});
|
||||
|
||||
oc.set(oc.get() + cc.get());
|
||||
cc.set(0);
|
||||
}
|
||||
|
||||
dos.close();
|
||||
}
|
||||
|
||||
public void registerBiome(IrisBiome j)
|
||||
{
|
||||
biomes.add(j);
|
||||
}
|
||||
|
||||
public void registerObject(GenObjectGroup g)
|
||||
{
|
||||
if(g.getName().startsWith("pack/objects/"))
|
||||
{
|
||||
g.setName(g.getName().replaceFirst("\\Qpack/objects/\\E", ""));
|
||||
}
|
||||
|
||||
objects.put(g.getName(), g);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return dimension.getName();
|
||||
}
|
||||
|
||||
public GList<IrisBiome> getBiomes()
|
||||
{
|
||||
return biomes;
|
||||
}
|
||||
|
||||
public Environment getEnvironment()
|
||||
{
|
||||
return dimension.getEnvironment();
|
||||
}
|
||||
|
||||
public GenObjectGroup getObjectGroup(String j)
|
||||
{
|
||||
return objects.get(j);
|
||||
}
|
||||
|
||||
public int countObjects()
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
for(GenObjectGroup i : objects.v())
|
||||
{
|
||||
m += i.size();
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
public void sort()
|
||||
{
|
||||
biomes.sort();
|
||||
}
|
||||
}
|
@ -158,6 +158,11 @@ public class IrisBiome
|
||||
}
|
||||
|
||||
public void fromJSON(JSONObject o)
|
||||
{
|
||||
fromJSON(o, true);
|
||||
}
|
||||
|
||||
public void fromJSON(JSONObject o, boolean chain)
|
||||
{
|
||||
name = o.getString("name");
|
||||
realBiome = Biome.valueOf(o.getString("derivative").toUpperCase().replaceAll(" ", "_"));
|
||||
@ -173,10 +178,13 @@ public class IrisBiome
|
||||
{
|
||||
schematicGroups = strFromJSON(o.getJSONArray("objects"));
|
||||
|
||||
if(chain)
|
||||
{
|
||||
for(String i : schematicGroups.k())
|
||||
{
|
||||
Iris.getController(PackController.class).loadSchematicGroup(i);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -34,32 +34,24 @@ public class IrisDimension
|
||||
}
|
||||
|
||||
public void fromJSON(JSONObject o) throws JSONException, IOException
|
||||
{
|
||||
fromJSON(o, true);
|
||||
}
|
||||
|
||||
public void fromJSON(JSONObject o, boolean chain) throws JSONException, IOException
|
||||
{
|
||||
name = o.getString("name");
|
||||
J.attempt(() -> environment = Environment.valueOf(o.getString("environment").toUpperCase().replaceAll(" ", "_")));
|
||||
|
||||
try
|
||||
{
|
||||
biomes = biomesFromArray(o.getJSONArray("biomes"));
|
||||
biomes = chain ? biomesFromArray(o.getJSONArray("biomes")) : new GList<>();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(o.has("focus"))
|
||||
{
|
||||
String focus = o.getString("focus");
|
||||
|
||||
for(IrisBiome i : biomes.copy())
|
||||
{
|
||||
if(!i.getName().toLowerCase().replaceAll(" ", "_").equals(focus))
|
||||
{
|
||||
biomes.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject toJSON()
|
||||
@ -83,10 +75,11 @@ public class IrisDimension
|
||||
for(int i = 0; i < a.length(); i++)
|
||||
{
|
||||
int ii = i;
|
||||
g.queue(() -> {
|
||||
g.queue(() ->
|
||||
{
|
||||
IrisBiome bb = Iris.getController(PackController.class).loadBiome(a.getString(ii));
|
||||
lock.lock();
|
||||
Iris.getController(PackController.class).getBiomes().put(a.getString(ii), bb);
|
||||
Iris.getController(PackController.class).registerBiome(a.getString(ii), bb);
|
||||
b.add(bb);
|
||||
lock.unlock();
|
||||
});
|
||||
|
@ -75,13 +75,13 @@ public class IrisPack
|
||||
for(String i : dimensions)
|
||||
{
|
||||
IrisDimension d = Iris.getController(PackController.class).loadDimension(i);
|
||||
Iris.getController(PackController.class).getDimensions().put(i, d);
|
||||
Iris.getController(PackController.class).registerDimension(i, d);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadBiome(String s) throws JSONException, IOException
|
||||
{
|
||||
IrisBiome b = Iris.getController(PackController.class).loadBiome(s);
|
||||
Iris.getController(PackController.class).getBiomes().put(s, b);
|
||||
Iris.getController(PackController.class).registerBiome(s, b);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user