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 org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mortar.api.nms.NMP;
|
import mortar.api.nms.NMP;
|
||||||
|
import ninja.bytecode.iris.controller.PackController;
|
||||||
import ninja.bytecode.iris.controller.TimingsController;
|
import ninja.bytecode.iris.controller.TimingsController;
|
||||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||||
import ninja.bytecode.iris.pack.IrisBiome;
|
import ninja.bytecode.iris.pack.IrisBiome;
|
||||||
|
@ -72,7 +72,7 @@ public class CommandIsh implements CommandExecutor
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileOutputStream fos = new FileOutputStream(f);
|
FileOutputStream fos = new FileOutputStream(f);
|
||||||
s.write(fos);
|
s.write(fos, true);
|
||||||
msg(p, "Saved " + args[1] + " (" + F.f(s.getSchematic().size()) + " Entries)");
|
msg(p, "Saved " + args[1] + " (" + F.f(s.getSchematic().size()) + " Entries)");
|
||||||
p.playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 0.45f);
|
p.playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 0.45f);
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ public class CommandIsh implements CommandExecutor
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileInputStream fin = new FileInputStream(f);
|
FileInputStream fin = new FileInputStream(f);
|
||||||
s.read(fin);
|
s.read(fin, true);
|
||||||
|
|
||||||
boolean cursor = false;
|
boolean cursor = false;
|
||||||
for(String i : args)
|
for(String i : args)
|
||||||
|
@ -46,10 +46,10 @@ public class Iris extends JavaPlugin implements Listener
|
|||||||
getServer().getPluginManager().registerEvents((Listener) this, this);
|
getServer().getPluginManager().registerEvents((Listener) this, this);
|
||||||
getCommand("iris").setExecutor(new CommandIris());
|
getCommand("iris").setExecutor(new CommandIris());
|
||||||
getCommand("ish").setExecutor(new CommandIsh());
|
getCommand("ish").setExecutor(new CommandIsh());
|
||||||
|
|
||||||
if(!settings.performance.debugMode)
|
if(!settings.performance.debugMode)
|
||||||
{
|
{
|
||||||
getController(PackController.class).loadContent();
|
getController(PackController.class).compile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,10 +59,11 @@ public class Iris extends JavaPlugin implements Listener
|
|||||||
HandlerList.unregisterAll((Plugin) this);
|
HandlerList.unregisterAll((Plugin) this);
|
||||||
Bukkit.getScheduler().cancelTasks(this);
|
Bukkit.getScheduler().cancelTasks(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload()
|
public void reload()
|
||||||
{
|
{
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () ->
|
||||||
|
{
|
||||||
onDisable();
|
onDisable();
|
||||||
onEnable();
|
onEnable();
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,7 @@ public class Settings
|
|||||||
|
|
||||||
public static class PerformanceSettings
|
public static class PerformanceSettings
|
||||||
{
|
{
|
||||||
public PerformanceMode performanceMode = PerformanceMode.HALF_CPU;
|
public PerformanceMode performanceMode = PerformanceMode.MATCH_CPU;
|
||||||
public boolean fastDecoration = true;
|
public boolean fastDecoration = true;
|
||||||
public int threadPriority = Thread.MIN_PRIORITY;
|
public int threadPriority = Thread.MIN_PRIORITY;
|
||||||
public int compilerPriority = Thread.MIN_PRIORITY;
|
public int compilerPriority = Thread.MIN_PRIORITY;
|
||||||
@ -27,7 +27,7 @@ public class Settings
|
|||||||
public double beachScale = 76;
|
public double beachScale = 76;
|
||||||
public double landScale = 0.325;
|
public double landScale = 0.325;
|
||||||
public double landChance = 0.62;
|
public double landChance = 0.62;
|
||||||
public double roughness = 1;
|
public double roughness = 1.25;
|
||||||
public double heightMultiplier = 0.806;
|
public double heightMultiplier = 0.806;
|
||||||
public double heightExponentBase = 1;
|
public double heightExponentBase = 1;
|
||||||
public double heightExponentMultiplier = 1.41;
|
public double heightExponentMultiplier = 1.41;
|
||||||
@ -41,7 +41,7 @@ public class Settings
|
|||||||
public boolean flatBedrock = false;
|
public boolean flatBedrock = false;
|
||||||
public boolean genObjects = true;
|
public boolean genObjects = true;
|
||||||
public int minCarvingHeight = 75;
|
public int minCarvingHeight = 75;
|
||||||
public int maxCarvingHeight = 175;
|
public int maxCarvingHeight = 155;
|
||||||
public double carvingChance = 0.6;
|
public double carvingChance = 0.6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class CommandIsh implements CommandExecutor
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileOutputStream fos = new FileOutputStream(f);
|
FileOutputStream fos = new FileOutputStream(f);
|
||||||
s.write(fos);
|
s.write(fos, true);
|
||||||
msg(p, "Saved " + args[1] + " (" + F.f(s.getSchematic().size()) + " Entries)");
|
msg(p, "Saved " + args[1] + " (" + F.f(s.getSchematic().size()) + " Entries)");
|
||||||
p.playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 0.45f);
|
p.playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 0.45f);
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ public class CommandIsh implements CommandExecutor
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileInputStream fin = new FileInputStream(f);
|
FileInputStream fin = new FileInputStream(f);
|
||||||
s.read(fin);
|
s.read(fin, true);
|
||||||
|
|
||||||
boolean cursor = false;
|
boolean cursor = false;
|
||||||
for(String i : args)
|
for(String i : args)
|
||||||
|
@ -71,7 +71,7 @@ public class DebugController implements IrisController
|
|||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
});
|
});
|
||||||
Iris.getController(PackController.class).loadContent();
|
Iris.getController(PackController.class).compile();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
package ninja.bytecode.iris.controller;
|
package ninja.bytecode.iris.controller;
|
||||||
|
|
||||||
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
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 net.md_5.bungee.api.ChatColor;
|
||||||
import ninja.bytecode.iris.Iris;
|
import ninja.bytecode.iris.Iris;
|
||||||
import ninja.bytecode.iris.generator.genobject.GenObject;
|
import ninja.bytecode.iris.generator.genobject.GenObject;
|
||||||
import ninja.bytecode.iris.generator.genobject.GenObjectGroup;
|
import ninja.bytecode.iris.generator.genobject.GenObjectGroup;
|
||||||
|
import ninja.bytecode.iris.pack.CompiledDimension;
|
||||||
import ninja.bytecode.iris.pack.IrisBiome;
|
import ninja.bytecode.iris.pack.IrisBiome;
|
||||||
import ninja.bytecode.iris.pack.IrisDimension;
|
import ninja.bytecode.iris.pack.IrisDimension;
|
||||||
import ninja.bytecode.iris.pack.IrisPack;
|
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.bench.PrecisionStopwatch;
|
||||||
import ninja.bytecode.shuriken.collections.GList;
|
import ninja.bytecode.shuriken.collections.GList;
|
||||||
import ninja.bytecode.shuriken.collections.GMap;
|
import ninja.bytecode.shuriken.collections.GMap;
|
||||||
|
import ninja.bytecode.shuriken.execution.J;
|
||||||
import ninja.bytecode.shuriken.execution.TaskExecutor;
|
import ninja.bytecode.shuriken.execution.TaskExecutor;
|
||||||
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
|
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
|
||||||
import ninja.bytecode.shuriken.format.F;
|
import ninja.bytecode.shuriken.format.F;
|
||||||
import ninja.bytecode.shuriken.io.IO;
|
import ninja.bytecode.shuriken.io.IO;
|
||||||
|
import ninja.bytecode.shuriken.io.VoidOutputStream;
|
||||||
import ninja.bytecode.shuriken.json.JSONException;
|
import ninja.bytecode.shuriken.json.JSONException;
|
||||||
import ninja.bytecode.shuriken.json.JSONObject;
|
import ninja.bytecode.shuriken.json.JSONObject;
|
||||||
import ninja.bytecode.shuriken.logging.L;
|
import ninja.bytecode.shuriken.logging.L;
|
||||||
|
|
||||||
public class PackController implements IrisController
|
public class PackController implements IrisController
|
||||||
{
|
{
|
||||||
|
private GMap<String, CompiledDimension> compiledDimensions;
|
||||||
private GMap<String, IrisDimension> dimensions;
|
private GMap<String, IrisDimension> dimensions;
|
||||||
private GMap<String, IrisBiome> biomes;
|
private GMap<String, IrisBiome> biomes;
|
||||||
private GMap<String, GenObjectGroup> genObjectGroups;
|
private GMap<String, GenObjectGroup> genObjectGroups;
|
||||||
|
private ChronoLatch ll = new ChronoLatch(3000);
|
||||||
private boolean ready;
|
private boolean ready;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
|
compiledDimensions = new GMap<>();
|
||||||
dimensions = new GMap<>();
|
dimensions = new GMap<>();
|
||||||
biomes = new GMap<>();
|
biomes = new GMap<>();
|
||||||
genObjectGroups = new GMap<>();
|
genObjectGroups = new GMap<>();
|
||||||
@ -51,14 +63,43 @@ public class PackController implements IrisController
|
|||||||
return ready;
|
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<>();
|
dimensions = new GMap<>();
|
||||||
biomes = new GMap<>();
|
biomes = new GMap<>();
|
||||||
genObjectGroups = new GMap<>();
|
genObjectGroups = new GMap<>();
|
||||||
ready = false;
|
ready = false;
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
L.i("Loading Content");
|
File dims = new File(Iris.instance.getDataFolder(), "dimensions");
|
||||||
|
dims.mkdirs();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -75,29 +116,64 @@ public class PackController implements IrisController
|
|||||||
|
|
||||||
TaskExecutor exf = new TaskExecutor(Iris.settings.performance.compilerThreads, Iris.settings.performance.compilerPriority, "Iris Compiler");
|
TaskExecutor exf = new TaskExecutor(Iris.settings.performance.compilerThreads, Iris.settings.performance.compilerPriority, "Iris Compiler");
|
||||||
TaskGroup gg = exf.startWork();
|
TaskGroup gg = exf.startWork();
|
||||||
for(GenObjectGroup i : getGenObjectGroups().v())
|
for(GenObjectGroup i : genObjectGroups.v())
|
||||||
{
|
{
|
||||||
gg.queue(i::processVariants);
|
gg.queue(i::processVariants);
|
||||||
}
|
}
|
||||||
|
|
||||||
gg.execute();
|
gg.execute();
|
||||||
exf.close();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d.sort();
|
||||||
|
compiledDimensions.put(i, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
L.i(ChatColor.LIGHT_PURPLE + "Dimensions: " + ChatColor.WHITE + getDimensions().size());
|
for(String i : compiledDimensions.k())
|
||||||
L.i(ChatColor.LIGHT_PURPLE + "Biomes: " + ChatColor.WHITE + getBiomes().size());
|
{
|
||||||
L.i(ChatColor.LIGHT_PURPLE + "Object Groups: " + ChatColor.WHITE + F.f(getGenObjectGroups().size()));
|
CompiledDimension d = compiledDimensions.get(i);
|
||||||
L.i(ChatColor.LIGHT_PURPLE + "Objects: " + ChatColor.WHITE + F.f(m));
|
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.LIGHT_PURPLE + "Compilation Time: " + ChatColor.WHITE + F.duration(p.getMilliseconds(), 2));
|
||||||
L.flush();
|
|
||||||
L.i(ChatColor.GREEN + "Iris Dimensions Successfully Compiled!");
|
L.i(ChatColor.GREEN + "Iris Dimensions Successfully Compiled!");
|
||||||
|
L.i("");
|
||||||
|
L.flush();
|
||||||
|
|
||||||
ready = true;
|
ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CompiledDimension getDimension(String name)
|
||||||
|
{
|
||||||
|
return compiledDimensions.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
public IrisDimension loadDimension(String s) throws JSONException, IOException
|
public IrisDimension loadDimension(String s) throws JSONException, IOException
|
||||||
{
|
{
|
||||||
@ -118,7 +194,7 @@ public class PackController implements IrisController
|
|||||||
|
|
||||||
if(g != null)
|
if(g != null)
|
||||||
{
|
{
|
||||||
Iris.getController(PackController.class).getGenObjectGroups().put(s, g);
|
Iris.getController(PackController.class).genObjectGroups.put(s, g);
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,13 +239,13 @@ public class PackController implements IrisController
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
L.f(ChatColor.RED + "Cannot find Resource: " + ChatColor.YELLOW + internal.getAbsolutePath());
|
L.f(ChatColor.RED + "Cannot find Resource: " + ChatColor.YELLOW + internal.getAbsolutePath());
|
||||||
|
|
||||||
if(internal.getName().equals("manifest.json"))
|
if(internal.getName().equals("manifest.json"))
|
||||||
{
|
{
|
||||||
L.f(ChatColor.RED + "Reloading Iris to fix manifest jar issues");
|
L.f(ChatColor.RED + "Reloading Iris to fix manifest jar issues");
|
||||||
Iris.instance.reload();
|
Iris.instance.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,18 +260,19 @@ public class PackController implements IrisController
|
|||||||
return new File(System.getProperty("java.io.tmpdir") + "/Iris/" + resource);
|
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.Iris;
|
||||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
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.iris.util.IrisController;
|
||||||
import ninja.bytecode.shuriken.execution.J;
|
import ninja.bytecode.shuriken.execution.J;
|
||||||
import ninja.bytecode.shuriken.io.IO;
|
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)
|
if(dimension == null)
|
||||||
{
|
{
|
||||||
dimension = Iris.getController(PackController.class).getDimensions().get("overworld");
|
dimension = Iris.getController(PackController.class).getDimension("overworld");
|
||||||
}
|
}
|
||||||
|
|
||||||
//@builder
|
//@builder
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import ninja.bytecode.iris.Iris;
|
import ninja.bytecode.iris.Iris;
|
||||||
import ninja.bytecode.iris.controller.PackController;
|
import ninja.bytecode.iris.controller.PackController;
|
||||||
import ninja.bytecode.iris.generator.genobject.GenObjectDecorator;
|
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.GenLayerLayeredNoise;
|
||||||
import ninja.bytecode.iris.generator.layer.GenLayerRidge;
|
import ninja.bytecode.iris.generator.layer.GenLayerRidge;
|
||||||
import ninja.bytecode.iris.generator.layer.GenLayerSnow;
|
import ninja.bytecode.iris.generator.layer.GenLayerSnow;
|
||||||
|
import ninja.bytecode.iris.pack.CompiledDimension;
|
||||||
import ninja.bytecode.iris.pack.IrisBiome;
|
import ninja.bytecode.iris.pack.IrisBiome;
|
||||||
import ninja.bytecode.iris.pack.IrisDimension;
|
|
||||||
import ninja.bytecode.iris.util.AtomicChunkData;
|
import ninja.bytecode.iris.util.AtomicChunkData;
|
||||||
import ninja.bytecode.iris.util.ChunkPlan;
|
import ninja.bytecode.iris.util.ChunkPlan;
|
||||||
import ninja.bytecode.iris.util.IrisInterpolation;
|
import ninja.bytecode.iris.util.IrisInterpolation;
|
||||||
@ -64,21 +65,16 @@ public class IrisGenerator extends ParallelChunkGenerator
|
|||||||
private GenLayerCarving glCarving;
|
private GenLayerCarving glCarving;
|
||||||
private GenLayerSnow glSnow;
|
private GenLayerSnow glSnow;
|
||||||
private RNG rTerrain;
|
private RNG rTerrain;
|
||||||
private IrisDimension dim;
|
private CompiledDimension dim;
|
||||||
private World world;
|
private World world;
|
||||||
private GMap<String, GenObjectGroup> schematicCache = new GMap<>();
|
private GMap<String, GenObjectGroup> schematicCache = new GMap<>();
|
||||||
|
|
||||||
public IrisGenerator()
|
public IrisGenerator()
|
||||||
{
|
{
|
||||||
this(Iris.getController(PackController.class).getDimensions().get("overworld"));
|
this(Iris.getController(PackController.class).getDimension("overworld"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public GList<IrisBiome> getLoadedBiomes()
|
public IrisGenerator(CompiledDimension dim)
|
||||||
{
|
|
||||||
return internal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IrisGenerator(IrisDimension dim)
|
|
||||||
{
|
{
|
||||||
this.dim = dim;
|
this.dim = dim;
|
||||||
L.i("Preparing Dimension: " + dim.getName() + " With " + dim.getBiomes().size() + " Biomes...");
|
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()))
|
if(j.getName().equals(i.getName()))
|
||||||
{
|
{
|
||||||
internal.remove(j);
|
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
|
@Override
|
||||||
public void onInit(World world, Random random)
|
public void onInit(World world, Random random)
|
||||||
{
|
{
|
||||||
@ -273,11 +274,6 @@ public class IrisGenerator extends ParallelChunkGenerator
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenObjectGroup loadSchematics(String folder)
|
|
||||||
{
|
|
||||||
return Iris.getController(PackController.class).getGenObjectGroups().get(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private double getBiomedHeight(int x, int z, ChunkPlan plan)
|
private double getBiomedHeight(int x, int z, ChunkPlan plan)
|
||||||
{
|
{
|
||||||
double xh = plan.getHeight(x, z);
|
double xh = plan.getHeight(x, z);
|
||||||
@ -321,4 +317,9 @@ public class IrisGenerator extends ParallelChunkGenerator
|
|||||||
{
|
{
|
||||||
return glBase;
|
return glBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CompiledDimension getDimension()
|
||||||
|
{
|
||||||
|
return dim;
|
||||||
|
}
|
||||||
}
|
}
|
@ -15,7 +15,6 @@ import org.bukkit.util.BlockVector;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mortar.compute.math.M;
|
import mortar.compute.math.M;
|
||||||
import ninja.bytecode.iris.Iris;
|
|
||||||
import ninja.bytecode.iris.generator.placer.NMSPlacer;
|
import ninja.bytecode.iris.generator.placer.NMSPlacer;
|
||||||
import ninja.bytecode.iris.util.Direction;
|
import ninja.bytecode.iris.util.Direction;
|
||||||
import ninja.bytecode.iris.util.IPlacer;
|
import ninja.bytecode.iris.util.IPlacer;
|
||||||
@ -38,14 +37,12 @@ public class GenObject
|
|||||||
private BlockVector mount;
|
private BlockVector mount;
|
||||||
private int mountHeight;
|
private int mountHeight;
|
||||||
private BlockVector shift;
|
private BlockVector shift;
|
||||||
private boolean cascading;
|
|
||||||
|
|
||||||
public GenObject(int w, int h, int d)
|
public GenObject(int w, int h, int d)
|
||||||
{
|
{
|
||||||
this.w = w;
|
this.w = w;
|
||||||
this.h = h;
|
this.h = h;
|
||||||
this.d = d;
|
this.d = d;
|
||||||
cascading = false;
|
|
||||||
shift = new BlockVector();
|
shift = new BlockVector();
|
||||||
s = new GMap<>();
|
s = new GMap<>();
|
||||||
centeredHeight = false;
|
centeredHeight = false;
|
||||||
@ -137,40 +134,21 @@ public class GenObject
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAntiCascadeWidth()
|
public void read(InputStream in, boolean gzip) throws IOException
|
||||||
{
|
{
|
||||||
if(isCascading())
|
@SuppressWarnings("resource")
|
||||||
{
|
GZIPInputStream gzi = gzip ? new GZIPInputStream(in) : null;
|
||||||
return -1;
|
DataInputStream din = new DataInputStream(gzip ? gzi : in);
|
||||||
}
|
readDirect(din);
|
||||||
|
din.close();
|
||||||
return 16 - w;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAntiCascadeDepth()
|
|
||||||
{
|
|
||||||
if(isCascading())
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 16 - d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCascading()
|
|
||||||
{
|
|
||||||
return cascading;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@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();
|
w = din.readInt();
|
||||||
h = din.readInt();
|
h = din.readInt();
|
||||||
d = din.readInt();
|
d = din.readInt();
|
||||||
cascading = w > Iris.settings.performance.cascadeLimit || d > Iris.settings.performance.cascadeLimit;
|
|
||||||
int l = din.readInt();
|
int l = din.readInt();
|
||||||
clear();
|
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()));
|
s.put(new BlockVector(din.readInt(), din.readInt(), din.readInt()), new MB(Material.getMaterial((int) din.readInt()), din.readInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
din.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@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(w);
|
||||||
dos.writeInt(h);
|
dos.writeInt(h);
|
||||||
dos.writeInt(d);
|
dos.writeInt(d);
|
||||||
@ -200,7 +174,13 @@ public class GenObject
|
|||||||
dos.writeInt(s.get(i).material.getId());
|
dos.writeInt(s.get(i).material.getId());
|
||||||
dos.writeInt(s.get(i).data);
|
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();
|
dos.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +299,7 @@ public class GenObject
|
|||||||
public static GenObject load(InputStream in) throws IOException
|
public static GenObject load(InputStream in) throws IOException
|
||||||
{
|
{
|
||||||
GenObject s = new GenObject(1, 1, 1);
|
GenObject s = new GenObject(1, 1, 1);
|
||||||
s.read(in);
|
s.read(in, true);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -329,7 +309,7 @@ public class GenObject
|
|||||||
GenObject s = new GenObject(1, 1, 1);
|
GenObject s = new GenObject(1, 1, 1);
|
||||||
s.name = f.getName().replaceAll("\\Q.ish\\E", "");
|
s.name = f.getName().replaceAll("\\Q.ish\\E", "");
|
||||||
FileInputStream fin = new FileInputStream(f);
|
FileInputStream fin = new FileInputStream(f);
|
||||||
s.read(fin);
|
s.read(fin, true);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -47,25 +47,13 @@ public class GenObjectDecorator extends BlockPopulator
|
|||||||
|
|
||||||
for(String j : i.getSchematicGroups().k())
|
for(String j : i.getSchematicGroups().k())
|
||||||
{
|
{
|
||||||
|
double c = i.getSchematicGroups().get(j);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GenObjectGroup g = Iris.getController(PackController.class).getGenObjectGroups().get(j);
|
GenObjectGroup g = generator.getDimension().getObjectGroup(j);
|
||||||
|
|
||||||
if(i.isSnowy())
|
gc.put(g, c);
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package ninja.bytecode.iris.generator.genobject;
|
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.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import ninja.bytecode.iris.Iris;
|
import ninja.bytecode.iris.Iris;
|
||||||
@ -20,21 +25,75 @@ public class GenObjectGroup
|
|||||||
private GList<GenObject> schematics;
|
private GList<GenObject> schematics;
|
||||||
private GList<String> flags;
|
private GList<String> flags;
|
||||||
private String name;
|
private String name;
|
||||||
private int priority;
|
|
||||||
private boolean noCascade;
|
|
||||||
|
|
||||||
public GenObjectGroup(String name)
|
public GenObjectGroup(String name)
|
||||||
{
|
{
|
||||||
this.schematics = new GList<>();
|
this.schematics = new GList<>();
|
||||||
this.flags = new GList<>();
|
this.flags = new GList<>();
|
||||||
priority = 0;
|
|
||||||
this.name = name;
|
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)
|
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());
|
L.i(ChatColor.AQUA + "Applying Snow Filter to " + ChatColor.WHITE + getName());
|
||||||
|
|
||||||
for(GenObject i : schematics)
|
for(GenObject i : schematics)
|
||||||
{
|
{
|
||||||
i.applySnowFilter(factor);
|
i.applySnowFilter(factor);
|
||||||
@ -46,8 +105,6 @@ public class GenObjectGroup
|
|||||||
GenObjectGroup gog = new GenObjectGroup(name + suffix);
|
GenObjectGroup gog = new GenObjectGroup(name + suffix);
|
||||||
gog.schematics = new GList<>();
|
gog.schematics = new GList<>();
|
||||||
gog.flags = flags.copy();
|
gog.flags = flags.copy();
|
||||||
gog.priority = priority;
|
|
||||||
gog.noCascade = noCascade;
|
|
||||||
|
|
||||||
for(GenObject i : schematics)
|
for(GenObject i : schematics)
|
||||||
{
|
{
|
||||||
@ -89,16 +146,6 @@ public class GenObjectGroup
|
|||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPriority()
|
|
||||||
{
|
|
||||||
return priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPriority(int priority)
|
|
||||||
{
|
|
||||||
this.priority = priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int size()
|
public int size()
|
||||||
{
|
{
|
||||||
return getSchematics().size();
|
return getSchematics().size();
|
||||||
@ -192,62 +239,7 @@ public class GenObjectGroup
|
|||||||
|
|
||||||
gg.execute();
|
gg.execute();
|
||||||
ex.close();
|
ex.close();
|
||||||
noCascade = true;
|
|
||||||
|
|
||||||
for(GenObject i : getSchematics())
|
L.i(ChatColor.LIGHT_PURPLE + "Processed " + ChatColor.WHITE + F.f(schematics.size()) + ChatColor.LIGHT_PURPLE + " Schematics in " + ChatColor.WHITE + name);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,25 +25,25 @@ public class GenLayerCarving extends GenLayer
|
|||||||
super(iris, world, random, rng);
|
super(iris, world, random, rng);
|
||||||
//@builder
|
//@builder
|
||||||
carver = new CNG(rng.nextParallelRNG(116), 1D, 3)
|
carver = new CNG(rng.nextParallelRNG(116), 1D, 3)
|
||||||
.scale(0.0135)
|
.scale(0.0285)
|
||||||
.amp(0.5)
|
.amp(0.5)
|
||||||
.freq(1.1)
|
.freq(1.1)
|
||||||
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 3)
|
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 3)
|
||||||
.scale(0.018)
|
.scale(0.005)
|
||||||
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
|
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
|
||||||
.scale(0.1))
|
.scale(0.1))
|
||||||
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 3)
|
.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)
|
clipper = new CNG(rng.nextParallelRNG(117), 1D, 1)
|
||||||
.scale(0.005)
|
.scale(0.0009)
|
||||||
.amp(0.5)
|
.amp(0.0)
|
||||||
.freq(1.1)
|
.freq(1.1)
|
||||||
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 3)
|
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 3)
|
||||||
.scale(0.018)
|
.scale(0.005)
|
||||||
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
|
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
|
||||||
.scale(0.1))
|
.scale(0.1))
|
||||||
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 3)
|
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 3)
|
||||||
.scale(0.15), 24), 44);
|
.scale(0.08), 12), 33);
|
||||||
//@done
|
//@done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ public class GenLayerCarving extends GenLayer
|
|||||||
continue;
|
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++;
|
carved++;
|
||||||
g.setBlock(x, i, z, Material.AIR);
|
g.setBlock(x, i, z, Material.AIR);
|
||||||
@ -97,6 +97,8 @@ public class GenLayerCarving extends GenLayer
|
|||||||
|
|
||||||
if(carved > 4)
|
if(carved > 4)
|
||||||
{
|
{
|
||||||
|
boolean fail = false;
|
||||||
|
|
||||||
for(int i = Iris.settings.gen.maxCarvingHeight; i > Iris.settings.gen.minCarvingHeight; i--)
|
for(int i = Iris.settings.gen.maxCarvingHeight; i > Iris.settings.gen.minCarvingHeight; i--)
|
||||||
{
|
{
|
||||||
Material m = g.getType(x, i, z);
|
Material m = g.getType(x, i, z);
|
||||||
@ -106,14 +108,44 @@ public class GenLayerCarving extends GenLayer
|
|||||||
|
|
||||||
if(hit == 1)
|
if(hit == 1)
|
||||||
{
|
{
|
||||||
MB mb = biome.getSurface(wxx, wzx, g.getRTerrain());
|
fail = false;
|
||||||
g.setBlock(x, i, z, mb.material, mb.data);
|
|
||||||
|
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)
|
else if(hit > 1 && hit < g.getGlBase().scatterInt(x, i, z, 4) + 3)
|
||||||
{
|
{
|
||||||
MB mb = biome.getDirtRNG();
|
if(!fail)
|
||||||
g.setBlock(x, i, z, mb.material, mb.data);
|
{
|
||||||
|
MB mb = biome.getDirtRNG();
|
||||||
|
g.setBlock(x, i, z, mb.material, mb.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.setBlock(x, i, z, Material.AIR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,12 @@ public class GenLayerLayeredNoise extends GenLayer
|
|||||||
{
|
{
|
||||||
//@builder
|
//@builder
|
||||||
super(iris, world, random, rng);
|
super(iris, world, random, rng);
|
||||||
fract = new CNG(rng.nextParallelRNG(16), 1D, 3).scale(0.0181);
|
fract = new CNG(rng.nextParallelRNG(16), 1D, 9).scale(0.0181);
|
||||||
gen = new CNG(rng.nextParallelRNG(17), 0.19D, 6)
|
gen = new CNG(rng.nextParallelRNG(17), 0.19D, 12)
|
||||||
.scale(0.012)
|
.scale(0.012)
|
||||||
.amp(0.5)
|
.amp(0.5)
|
||||||
.freq(1.1)
|
.freq(1.1)
|
||||||
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 3)
|
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 5)
|
||||||
.scale(0.018)
|
.scale(0.018)
|
||||||
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
|
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
|
||||||
.scale(0.1))
|
.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)
|
public void fromJSON(JSONObject o)
|
||||||
|
{
|
||||||
|
fromJSON(o, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fromJSON(JSONObject o, boolean chain)
|
||||||
{
|
{
|
||||||
name = o.getString("name");
|
name = o.getString("name");
|
||||||
realBiome = Biome.valueOf(o.getString("derivative").toUpperCase().replaceAll(" ", "_"));
|
realBiome = Biome.valueOf(o.getString("derivative").toUpperCase().replaceAll(" ", "_"));
|
||||||
@ -173,9 +178,12 @@ public class IrisBiome
|
|||||||
{
|
{
|
||||||
schematicGroups = strFromJSON(o.getJSONArray("objects"));
|
schematicGroups = strFromJSON(o.getJSONArray("objects"));
|
||||||
|
|
||||||
for(String i : schematicGroups.k())
|
if(chain)
|
||||||
{
|
{
|
||||||
Iris.getController(PackController.class).loadSchematicGroup(i);
|
for(String i : schematicGroups.k())
|
||||||
|
{
|
||||||
|
Iris.getController(PackController.class).loadSchematicGroup(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -20,93 +20,86 @@ public class IrisDimension
|
|||||||
private String name;
|
private String name;
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
GList<IrisBiome> biomes;
|
GList<IrisBiome> biomes;
|
||||||
|
|
||||||
public IrisDimension(JSONObject o) throws JSONException, IOException
|
public IrisDimension(JSONObject o) throws JSONException, IOException
|
||||||
{
|
{
|
||||||
this();
|
this();
|
||||||
fromJSON(o);
|
fromJSON(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisDimension()
|
public IrisDimension()
|
||||||
{
|
{
|
||||||
biomes = new GList<IrisBiome>();
|
biomes = new GList<IrisBiome>();
|
||||||
environment = Environment.NORMAL;
|
environment = Environment.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fromJSON(JSONObject o) throws JSONException, IOException
|
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");
|
name = o.getString("name");
|
||||||
J.attempt(() -> environment = Environment.valueOf(o.getString("environment").toUpperCase().replaceAll(" ", "_")));
|
J.attempt(() -> environment = Environment.valueOf(o.getString("environment").toUpperCase().replaceAll(" ", "_")));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
biomes = biomesFromArray(o.getJSONArray("biomes"));
|
biomes = chain ? biomesFromArray(o.getJSONArray("biomes")) : new GList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
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()
|
public JSONObject toJSON()
|
||||||
{
|
{
|
||||||
JSONObject o = new JSONObject();
|
JSONObject o = new JSONObject();
|
||||||
|
|
||||||
o.put("name", name);
|
o.put("name", name);
|
||||||
o.put("environment", environment.name().toLowerCase().replaceAll("_", " "));
|
o.put("environment", environment.name().toLowerCase().replaceAll("_", " "));
|
||||||
o.put("biomes", biomesToArray(biomes));
|
o.put("biomes", biomesToArray(biomes));
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GList<IrisBiome> biomesFromArray(JSONArray a) throws JSONException, IOException
|
private GList<IrisBiome> biomesFromArray(JSONArray a) throws JSONException, IOException
|
||||||
{
|
{
|
||||||
GList<IrisBiome> b = new GList<>();
|
GList<IrisBiome> b = new GList<>();
|
||||||
TaskExecutor ex= new TaskExecutor(Iris.settings.performance.compilerThreads, Iris.settings.performance.compilerPriority, "Iris Loader");
|
TaskExecutor ex = new TaskExecutor(Iris.settings.performance.compilerThreads, Iris.settings.performance.compilerPriority, "Iris Loader");
|
||||||
TaskGroup g = ex.startWork();
|
TaskGroup g = ex.startWork();
|
||||||
ReentrantLock lock = new ReentrantLock();
|
ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
for(int i = 0; i < a.length(); i++)
|
for(int i = 0; i < a.length(); i++)
|
||||||
{
|
{
|
||||||
int ii = i;
|
int ii = i;
|
||||||
g.queue(() -> {
|
g.queue(() ->
|
||||||
|
{
|
||||||
IrisBiome bb = Iris.getController(PackController.class).loadBiome(a.getString(ii));
|
IrisBiome bb = Iris.getController(PackController.class).loadBiome(a.getString(ii));
|
||||||
lock.lock();
|
lock.lock();
|
||||||
Iris.getController(PackController.class).getBiomes().put(a.getString(ii), bb);
|
Iris.getController(PackController.class).registerBiome(a.getString(ii), bb);
|
||||||
b.add(bb);
|
b.add(bb);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
g.execute();
|
g.execute();
|
||||||
ex.close();
|
ex.close();
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONArray biomesToArray(GList<IrisBiome> b)
|
private JSONArray biomesToArray(GList<IrisBiome> b)
|
||||||
{
|
{
|
||||||
JSONArray a = new JSONArray();
|
JSONArray a = new JSONArray();
|
||||||
|
|
||||||
for(IrisBiome i : b)
|
for(IrisBiome i : b)
|
||||||
{
|
{
|
||||||
a.put(i.getName().toLowerCase().replaceAll(" ", "_"));
|
a.put(i.getName().toLowerCase().replaceAll(" ", "_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,13 +75,13 @@ public class IrisPack
|
|||||||
for(String i : dimensions)
|
for(String i : dimensions)
|
||||||
{
|
{
|
||||||
IrisDimension d = Iris.getController(PackController.class).loadDimension(i);
|
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
|
public void loadBiome(String s) throws JSONException, IOException
|
||||||
{
|
{
|
||||||
IrisBiome b = Iris.getController(PackController.class).loadBiome(s);
|
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