mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Region rarity
This commit is contained in:
parent
e5384509cf
commit
c158e74fb5
@ -285,7 +285,7 @@ public class Iris extends MortarPlugin implements BoardProvider
|
|||||||
@Override
|
@Override
|
||||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
|
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
|
||||||
{
|
{
|
||||||
return new IrisChunkGenerator("overworld", 16);
|
return new IrisChunkGenerator(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void msg(String string)
|
public static void msg(String string)
|
||||||
|
@ -26,6 +26,7 @@ public class IrisDataManager
|
|||||||
{
|
{
|
||||||
private File dataFolder;
|
private File dataFolder;
|
||||||
private File packs;
|
private File packs;
|
||||||
|
private boolean prod;
|
||||||
private ResourceLoader<IrisBiome> biomeLoader;
|
private ResourceLoader<IrisBiome> biomeLoader;
|
||||||
private ResourceLoader<IrisRegion> regionLoader;
|
private ResourceLoader<IrisRegion> regionLoader;
|
||||||
private ResourceLoader<IrisDimension> dimensionLoader;
|
private ResourceLoader<IrisDimension> dimensionLoader;
|
||||||
@ -35,6 +36,12 @@ public class IrisDataManager
|
|||||||
|
|
||||||
public void hotloaded()
|
public void hotloaded()
|
||||||
{
|
{
|
||||||
|
if(prod)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File packs = this.packs.getName().equals("packs") ? this.packs : dataFolder;
|
||||||
packs.mkdirs();
|
packs.mkdirs();
|
||||||
this.regionLoader = new ResourceLoader<>(packs, "regions", "Region", IrisRegion.class);
|
this.regionLoader = new ResourceLoader<>(packs, "regions", "Region", IrisRegion.class);
|
||||||
this.biomeLoader = new ResourceLoader<>(packs, "biomes", "Biome", IrisBiome.class);
|
this.biomeLoader = new ResourceLoader<>(packs, "biomes", "Biome", IrisBiome.class);
|
||||||
@ -42,14 +49,28 @@ public class IrisDataManager
|
|||||||
this.structureLoader = new ResourceLoader<>(packs, "structures", "Structure", IrisStructure.class);
|
this.structureLoader = new ResourceLoader<>(packs, "structures", "Structure", IrisStructure.class);
|
||||||
this.generatorLoader = new ResourceLoader<>(packs, "generators", "Generator", IrisGenerator.class);
|
this.generatorLoader = new ResourceLoader<>(packs, "generators", "Generator", IrisGenerator.class);
|
||||||
this.objectLoader = new ObjectResourceLoader(packs, "objects", "Object");
|
this.objectLoader = new ObjectResourceLoader(packs, "objects", "Object");
|
||||||
writeExamples();
|
if(packs.getName().equals("packs"))
|
||||||
|
{
|
||||||
|
writeExamples();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisDataManager(File dataFolder)
|
public IrisDataManager(File dataFolder)
|
||||||
{
|
{
|
||||||
this.dataFolder = dataFolder;
|
this.dataFolder = dataFolder;
|
||||||
this.packs = new File(dataFolder, "packs");
|
this.packs = new File(dataFolder, "packs");
|
||||||
|
boolean pr = false;
|
||||||
|
if(!packs.exists())
|
||||||
|
{
|
||||||
|
if(new File(dataFolder, "iris").exists())
|
||||||
|
{
|
||||||
|
pr = true;
|
||||||
|
packs = new File(dataFolder, "iris");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hotloaded();
|
hotloaded();
|
||||||
|
prod = pr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeExamples()
|
private void writeExamples()
|
||||||
|
@ -164,7 +164,7 @@ public class ProjectManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void compilePackage(MortarSender sender, String dim, boolean obfuscate)
|
public File compilePackage(MortarSender sender, String dim, boolean obfuscate)
|
||||||
{
|
{
|
||||||
String dimm = dim;
|
String dimm = dim;
|
||||||
IrisDimension dimension = Iris.globaldata.getDimensionLoader().load(dimm);
|
IrisDimension dimension = Iris.globaldata.getDimensionLoader().load(dimm);
|
||||||
@ -317,15 +317,19 @@ public class ProjectManager
|
|||||||
meta.put("time", M.ms());
|
meta.put("time", M.ms());
|
||||||
meta.put("version", dimension.getVersion());
|
meta.put("version", dimension.getVersion());
|
||||||
IO.writeAll(new File(folder, "package.json"), meta.toString(0));
|
IO.writeAll(new File(folder, "package.json"), meta.toString(0));
|
||||||
ZipUtil.pack(folder, new File(Iris.instance.getDataFolder(), "exports/" + dimension.getLoadKey() + ".iris"), 9);
|
File p = new File(Iris.instance.getDataFolder(), "exports/" + dimension.getLoadKey() + ".iris");
|
||||||
|
ZipUtil.pack(folder, p, 9);
|
||||||
IO.delete(folder);
|
IO.delete(folder);
|
||||||
|
|
||||||
|
sender.sendMessage("Done!");
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
sender.sendMessage("Failed!");
|
||||||
sender.sendMessage("Done!");
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,9 @@ public class CommandIris extends MortarCommand
|
|||||||
@Command
|
@Command
|
||||||
private CommandIrisObject object;
|
private CommandIrisObject object;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisCreate create;
|
||||||
|
|
||||||
public CommandIris()
|
public CommandIris()
|
||||||
{
|
{
|
||||||
super("iris", "ir", "irs");
|
super("iris", "ir", "irs");
|
||||||
|
199
src/main/java/com/volmit/iris/command/CommandIrisCreate.java
Normal file
199
src/main/java/com/volmit/iris/command/CommandIrisCreate.java
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.WorldType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.zeroturnaround.zip.ZipUtil;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.IrisDataManager;
|
||||||
|
import com.volmit.iris.IrisSettings;
|
||||||
|
import com.volmit.iris.gen.IrisChunkGenerator;
|
||||||
|
import com.volmit.iris.object.IrisDimension;
|
||||||
|
import com.volmit.iris.util.Form;
|
||||||
|
import com.volmit.iris.util.J;
|
||||||
|
import com.volmit.iris.util.MortarCommand;
|
||||||
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
import com.volmit.iris.util.O;
|
||||||
|
import com.volmit.iris.util.PregenJob;
|
||||||
|
|
||||||
|
public class CommandIrisCreate extends MortarCommand
|
||||||
|
{
|
||||||
|
public CommandIrisCreate()
|
||||||
|
{
|
||||||
|
super("create", "new", "+");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setCategory("Create");
|
||||||
|
setDescription("Create a new Iris World!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
|
{
|
||||||
|
String worldName = args[0];
|
||||||
|
String type = "overworld";
|
||||||
|
long seed = 1337;
|
||||||
|
int pregen = 0;
|
||||||
|
boolean zip = false;
|
||||||
|
File folder = new File(worldName);
|
||||||
|
|
||||||
|
if(folder.exists())
|
||||||
|
{
|
||||||
|
sender.sendMessage("That world folder already exists!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
File iris = new File(folder, "iris");
|
||||||
|
iris.mkdirs();
|
||||||
|
|
||||||
|
for(String i : args)
|
||||||
|
{
|
||||||
|
if(i.equals("-zip"))
|
||||||
|
{
|
||||||
|
zip = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
type = i.startsWith("type=") ? i.split("\\Q=\\E")[1] : type;
|
||||||
|
seed = i.startsWith("seed=") ? Long.valueOf(i.split("\\Q=\\E")[1]) : seed;
|
||||||
|
pregen = i.startsWith("pregen=") ? Integer.parseInt(i.split("\\Q=\\E")[1]) : pregen;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage("Looking for Package: " + type);
|
||||||
|
|
||||||
|
IrisDimension dim = Iris.globaldata.getDimensionLoader().load(type);
|
||||||
|
|
||||||
|
if(dim == null)
|
||||||
|
{
|
||||||
|
for(File i : Iris.instance.getDataFolder("packs").listFiles())
|
||||||
|
{
|
||||||
|
if(i.isFile() && i.getName().equals(type + ".iris"))
|
||||||
|
{
|
||||||
|
sender.sendMessage("Found " + type + ".iris in packs folder");
|
||||||
|
ZipUtil.unpack(i, iris);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("Foind " + type + " dimension in packs folder. Repackaging");
|
||||||
|
ZipUtil.unpack(Iris.proj.compilePackage(sender, type, true), iris);
|
||||||
|
}
|
||||||
|
|
||||||
|
File dimf = new File(iris, "dimensions/" + type + ".json");
|
||||||
|
|
||||||
|
if(!dimf.exists() || !dimf.isFile())
|
||||||
|
{
|
||||||
|
sender.sendMessage("Can't find the " + dimf.getName() + " in the dimensions folder of this pack! Failed!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IrisDataManager dm = new IrisDataManager(folder);
|
||||||
|
dim = dm.getDimensionLoader().load(type);
|
||||||
|
|
||||||
|
if(dim == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Can't load the dimension! Failed!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(worldName + " type installed. Generating Spawn Area...");
|
||||||
|
IrisChunkGenerator gen = new IrisChunkGenerator("", 16);
|
||||||
|
|
||||||
|
sender.sendMessage("Generating with " + IrisSettings.get().threads + " threads per chunk");
|
||||||
|
O<Boolean> done = new O<Boolean>();
|
||||||
|
done.set(false);
|
||||||
|
|
||||||
|
J.a(() ->
|
||||||
|
{
|
||||||
|
double last = 0;
|
||||||
|
int req = 800;
|
||||||
|
while(!done.get())
|
||||||
|
{
|
||||||
|
boolean derp = false;
|
||||||
|
double v = (double) gen.getGenerated() / (double) req;
|
||||||
|
|
||||||
|
if(last > v || v > 1)
|
||||||
|
{
|
||||||
|
derp = true;
|
||||||
|
v = last;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
last = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage("Generating " + Form.pc(v) + (derp ? " (Waiting on Server...)" : ""));
|
||||||
|
J.sleep(3000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
World world = Bukkit.createWorld(new WorldCreator(worldName).seed(seed).generator(gen).type(WorldType.NORMAL).environment(dim.getEnvironment()));
|
||||||
|
done.set(true);
|
||||||
|
sender.sendMessage(worldName + " Spawn Area generated.");
|
||||||
|
|
||||||
|
O<Boolean> b = new O<Boolean>();
|
||||||
|
b.set(true);
|
||||||
|
|
||||||
|
if(pregen > 0)
|
||||||
|
{
|
||||||
|
b.set(false);
|
||||||
|
sender.sendMessage("Pregenerating " + worldName + " " + pregen + " x " + pregen);
|
||||||
|
sender.sendMessage("Expect Extreme server lag during this time. Use '/iris world pregen stop' to cancel");
|
||||||
|
|
||||||
|
new PregenJob(world, pregen, sender, () ->
|
||||||
|
{
|
||||||
|
b.set(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean zipp = zip;
|
||||||
|
|
||||||
|
J.a(() ->
|
||||||
|
{
|
||||||
|
while(!b.get())
|
||||||
|
{
|
||||||
|
J.sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () ->
|
||||||
|
{
|
||||||
|
world.save();
|
||||||
|
|
||||||
|
for(Player i : world.getPlayers())
|
||||||
|
{
|
||||||
|
i.kickPlayer("Please Rejoin in a different world.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Bukkit.unloadWorld(world, true))
|
||||||
|
{
|
||||||
|
sender.sendMessage("Couldn't unload the world for some reason.... Aborting zip.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(zipp)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Zipping up world");
|
||||||
|
ZipUtil.pack(folder, new File("" + folder.getName() + ".zip"), 9);
|
||||||
|
sender.sendMessage("Zipped to " + folder.getName() + ".zip");
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage("All Done!");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage()
|
||||||
|
{
|
||||||
|
return "<name> [type=overworld] [seed=1337] [pregen=5000] [-zip]";
|
||||||
|
}
|
||||||
|
}
|
@ -39,7 +39,9 @@ public class CommandIrisPregen extends MortarCommand
|
|||||||
{
|
{
|
||||||
Player p = sender.player();
|
Player p = sender.player();
|
||||||
World world = p.getWorld();
|
World world = p.getWorld();
|
||||||
new PregenJob(world, Integer.valueOf(args[0]));
|
new PregenJob(world, Integer.valueOf(args[0]), sender, () ->
|
||||||
|
{
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
|
|||||||
|
|
||||||
public void onInit(World world, RNG rng)
|
public void onInit(World world, RNG rng)
|
||||||
{
|
{
|
||||||
|
super.onInit(world, rng);
|
||||||
loadGenerators();
|
loadGenerators();
|
||||||
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
|
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
|
||||||
masterFracture = CNG.signature(rng.nextParallelRNG(13)).scale(0.12);
|
masterFracture = CNG.signature(rng.nextParallelRNG(13)).scale(0.12);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.volmit.iris.gen;
|
package com.volmit.iris.gen;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@ -137,7 +136,7 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = new IrisDataManager(new File(getWorld().getWorldFolder(), "iris"));
|
data = new IrisDataManager(getWorld().getWorldFolder());
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.masterRandom = new RNG(world.getSeed());
|
this.masterRandom = new RNG(world.getSeed());
|
||||||
metrics = new IrisMetrics(128);
|
metrics = new IrisMetrics(128);
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.volmit.iris.gen;
|
package com.volmit.iris.gen;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
@ -10,6 +13,7 @@ import com.volmit.iris.object.IrisDimension;
|
|||||||
import com.volmit.iris.object.IrisRegion;
|
import com.volmit.iris.object.IrisRegion;
|
||||||
import com.volmit.iris.util.B;
|
import com.volmit.iris.util.B;
|
||||||
import com.volmit.iris.util.BiomeResult;
|
import com.volmit.iris.util.BiomeResult;
|
||||||
|
import com.volmit.iris.util.RNG;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -18,7 +22,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public abstract class DimensionChunkGenerator extends ContextualChunkGenerator
|
public abstract class DimensionChunkGenerator extends ContextualChunkGenerator
|
||||||
{
|
{
|
||||||
protected final String dimensionName;
|
protected String dimensionName;
|
||||||
protected static final BlockData AIR = Material.AIR.createBlockData();
|
protected static final BlockData AIR = Material.AIR.createBlockData();
|
||||||
protected static final BlockData CAVE_AIR = B.get("CAVE_AIR");
|
protected static final BlockData CAVE_AIR = B.get("CAVE_AIR");
|
||||||
protected static final BlockData BEDROCK = Material.BEDROCK.createBlockData();
|
protected static final BlockData BEDROCK = Material.BEDROCK.createBlockData();
|
||||||
@ -29,6 +33,34 @@ public abstract class DimensionChunkGenerator extends ContextualChunkGenerator
|
|||||||
this.dimensionName = dimensionName;
|
this.dimensionName = dimensionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onInit(World world, RNG masterRandom)
|
||||||
|
{
|
||||||
|
if(dimensionName.isEmpty())
|
||||||
|
{
|
||||||
|
File folder = new File(world.getWorldFolder(), "iris/dimensions");
|
||||||
|
|
||||||
|
if(!folder.exists())
|
||||||
|
{
|
||||||
|
Iris.error("Missing World iris/dimensions folder!");
|
||||||
|
dimensionName = "error-missing-dimension";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(File i : folder.listFiles())
|
||||||
|
{
|
||||||
|
if(i.isFile() && i.getName().endsWith(".json"))
|
||||||
|
{
|
||||||
|
dimensionName = i.getName().replaceAll("\\Q.json\\E", "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iris.error("Missing World iris/dimensions/<dimension-name>.json file. Assuming overworld!");
|
||||||
|
dimensionName = "error-missing-dimension";
|
||||||
|
fail(new RuntimeException("Missing dimension folder/file in " + folder.getAbsolutePath()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IrisDimension getDimension()
|
public IrisDimension getDimension()
|
||||||
{
|
{
|
||||||
IrisDimension d = loadDimension(dimensionName);
|
IrisDimension d = loadDimension(dimensionName);
|
||||||
|
@ -41,6 +41,12 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
|
|||||||
lock = new IrisLock("IrisChunkGenerator");
|
lock = new IrisLock("IrisChunkGenerator");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IrisChunkGenerator(int tc)
|
||||||
|
{
|
||||||
|
super("", tc);
|
||||||
|
lock = new IrisLock("IrisChunkGenerator");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
|
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
|
||||||
{
|
{
|
||||||
|
@ -2,10 +2,11 @@ package com.volmit.iris.gen.layer;
|
|||||||
|
|
||||||
import com.volmit.iris.gen.ContextualChunkGenerator;
|
import com.volmit.iris.gen.ContextualChunkGenerator;
|
||||||
import com.volmit.iris.object.InferredType;
|
import com.volmit.iris.object.InferredType;
|
||||||
|
import com.volmit.iris.object.IrisBiome;
|
||||||
import com.volmit.iris.object.IrisRegion;
|
import com.volmit.iris.object.IrisRegion;
|
||||||
import com.volmit.iris.util.RarityCellGenerator;
|
|
||||||
import com.volmit.iris.util.BiomeResult;
|
import com.volmit.iris.util.BiomeResult;
|
||||||
import com.volmit.iris.util.RNG;
|
import com.volmit.iris.util.RNG;
|
||||||
|
import com.volmit.iris.util.RarityCellGenerator;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -13,14 +14,14 @@ import lombok.Data;
|
|||||||
public class BiomeDataProvider
|
public class BiomeDataProvider
|
||||||
{
|
{
|
||||||
private InferredType type;
|
private InferredType type;
|
||||||
private RarityCellGenerator generator;
|
private RarityCellGenerator<IrisBiome> generator;
|
||||||
private GenLayerBiome layer;
|
private GenLayerBiome layer;
|
||||||
|
|
||||||
public BiomeDataProvider(GenLayerBiome layer, InferredType type, RNG rng)
|
public BiomeDataProvider(GenLayerBiome layer, InferredType type, RNG rng)
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.layer = layer;
|
this.layer = layer;
|
||||||
generator = new RarityCellGenerator(rng.nextParallelRNG(4645079 + (type.ordinal() * 23845)));
|
generator = new RarityCellGenerator<IrisBiome>(rng.nextParallelRNG(4645079 + (type.ordinal() * 23845)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeResult generatePureData(ContextualChunkGenerator g, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
public BiomeResult generatePureData(ContextualChunkGenerator g, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||||
|
@ -21,7 +21,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class GenLayerBiome extends GenLayer
|
public class GenLayerBiome extends GenLayer
|
||||||
{
|
{
|
||||||
private CellGenerator regionGenerator;
|
private RarityCellGenerator<IrisRegion> regionGenerator;
|
||||||
private CellGenerator bridgeGenerator;
|
private CellGenerator bridgeGenerator;
|
||||||
private BiomeDataProvider seaProvider;
|
private BiomeDataProvider seaProvider;
|
||||||
private BiomeDataProvider landProvider;
|
private BiomeDataProvider landProvider;
|
||||||
@ -41,7 +41,7 @@ public class GenLayerBiome extends GenLayer
|
|||||||
caveProvider = new BiomeDataProvider(this, InferredType.CAVE, rng);
|
caveProvider = new BiomeDataProvider(this, InferredType.CAVE, rng);
|
||||||
islandProvider = new BiomeDataProvider(this, InferredType.ISLAND, rng);
|
islandProvider = new BiomeDataProvider(this, InferredType.ISLAND, rng);
|
||||||
skylandProvider = new BiomeDataProvider(this, InferredType.SKYLAND, rng);
|
skylandProvider = new BiomeDataProvider(this, InferredType.SKYLAND, rng);
|
||||||
regionGenerator = new CellGenerator(rng.nextParallelRNG(1188519));
|
regionGenerator = new RarityCellGenerator<IrisRegion>(rng.nextParallelRNG(1188519));
|
||||||
bridgeGenerator = new CellGenerator(rng.nextParallelRNG(1541462));
|
bridgeGenerator = new CellGenerator(rng.nextParallelRNG(1541462));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,13 +53,12 @@ public class GenLayerBiome extends GenLayer
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
regionGenerator.setShuffle(11);
|
regionGenerator.setShuffle(iris.getDimension().getRegionShuffle());
|
||||||
regionGenerator.setCellScale(0.33 / iris.getDimension().getRegionZoom());
|
regionGenerator.setCellScale(0.35);
|
||||||
double x = bx / iris.getDimension().getBiomeZoom();
|
double x = bx / iris.getDimension().getRegionZoom();
|
||||||
double z = bz / iris.getDimension().getBiomeZoom();
|
double z = bz / iris.getDimension().getRegionZoom();
|
||||||
String regionId = iris.getDimension().getRegions().get(regionGenerator.getIndex(x, z, iris.getDimension().getRegions().size()));
|
|
||||||
|
|
||||||
return iris.loadRegion(regionId);
|
return regionGenerator.get(x, z, iris.getDimension().getAllRegions(iris));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeResult generateData(double bx, double bz, int rawX, int rawZ)
|
public BiomeResult generateData(double bx, double bz, int rawX, int rawZ)
|
||||||
@ -119,14 +118,14 @@ public class GenLayerBiome extends GenLayer
|
|||||||
|
|
||||||
public InferredType getType(double bx, double bz, IrisRegion regionData)
|
public InferredType getType(double bx, double bz, IrisRegion regionData)
|
||||||
{
|
{
|
||||||
bridgeGenerator.setShuffle(47);
|
bridgeGenerator.setShuffle(iris.getDimension().getContinentalShuffle());
|
||||||
bridgeGenerator.setCellScale(0.33 / iris.getDimension().getContinentZoom());
|
bridgeGenerator.setCellScale(0.33);
|
||||||
double x = bx / iris.getDimension().getBiomeZoom();
|
double x = bx / iris.getDimension().getContinentZoom();
|
||||||
double z = bz / iris.getDimension().getBiomeZoom();
|
double z = bz / iris.getDimension().getContinentZoom();
|
||||||
return bridgeGenerator.getIndex(x, z, 2) == 1 ? InferredType.LAND : InferredType.SEA;
|
return bridgeGenerator.getIndex(x, z, 2) == 1 ? InferredType.LAND : InferredType.SEA;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, RarityCellGenerator cell, KList<IrisBiome> biomes, InferredType inferredType)
|
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, RarityCellGenerator<IrisBiome> cell, KList<IrisBiome> biomes, InferredType inferredType)
|
||||||
{
|
{
|
||||||
if(biomes.isEmpty())
|
if(biomes.isEmpty())
|
||||||
{
|
{
|
||||||
@ -162,12 +161,12 @@ public class GenLayerBiome extends GenLayer
|
|||||||
return pureResult;
|
return pureResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeResult implode(double bx, double bz, IrisRegion regionData, RarityCellGenerator parentCell, BiomeResult parent)
|
public BiomeResult implode(double bx, double bz, IrisRegion regionData, RarityCellGenerator<IrisBiome> parentCell, BiomeResult parent)
|
||||||
{
|
{
|
||||||
return implode(bx, bz, regionData, parentCell, parent, 1);
|
return implode(bx, bz, regionData, parentCell, parent, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeResult implode(double bx, double bz, IrisRegion regionData, RarityCellGenerator parentCell, BiomeResult parent, int hits)
|
public BiomeResult implode(double bx, double bz, IrisRegion regionData, RarityCellGenerator<IrisBiome> parentCell, BiomeResult parent, int hits)
|
||||||
{
|
{
|
||||||
if(hits > 9)
|
if(hits > 9)
|
||||||
{
|
{
|
||||||
@ -181,7 +180,7 @@ public class GenLayerBiome extends GenLayer
|
|||||||
{
|
{
|
||||||
if(!parent.getBiome().getRealChildren(iris).isEmpty())
|
if(!parent.getBiome().getRealChildren(iris).isEmpty())
|
||||||
{
|
{
|
||||||
RarityCellGenerator childCell = parent.getBiome().getChildrenGenerator(rng, 123, parentCell.getCellScale() * parent.getBiome().getChildShrinkFactor());
|
RarityCellGenerator<IrisBiome> childCell = parent.getBiome().getChildrenGenerator(rng, 123, parentCell.getCellScale() * parent.getBiome().getChildShrinkFactor());
|
||||||
KList<IrisBiome> chx = parent.getBiome().getRealChildren(iris).copy();
|
KList<IrisBiome> chx = parent.getBiome().getRealChildren(iris).copy();
|
||||||
chx.add(parent.getBiome());
|
chx.add(parent.getBiome());
|
||||||
IrisBiome biome = childCell.get(x, z, chx);
|
IrisBiome biome = childCell.get(x, z, chx);
|
||||||
|
@ -6,13 +6,14 @@ import org.bukkit.block.data.BlockData;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.ContextualChunkGenerator;
|
import com.volmit.iris.gen.ContextualChunkGenerator;
|
||||||
import com.volmit.iris.gen.atomics.AtomicCache;
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.RarityCellGenerator;
|
|
||||||
import com.volmit.iris.util.CNG;
|
import com.volmit.iris.util.CNG;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
|
import com.volmit.iris.util.IRare;
|
||||||
import com.volmit.iris.util.KList;
|
import com.volmit.iris.util.KList;
|
||||||
import com.volmit.iris.util.KSet;
|
import com.volmit.iris.util.KSet;
|
||||||
import com.volmit.iris.util.RNG;
|
import com.volmit.iris.util.RNG;
|
||||||
|
import com.volmit.iris.util.RarityCellGenerator;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -21,7 +22,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
@Desc("Represents a biome in iris.")
|
@Desc("Represents a biome in iris.")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class IrisBiome extends IrisRegistrant
|
public class IrisBiome extends IrisRegistrant implements IRare
|
||||||
{
|
{
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("This is the human readable name for this biome. This can and should be different than the file name. This is not used for loading biomes in other objects.")
|
@Desc("This is the human readable name for this biome. This can and should be different than the file name. This is not used for loading biomes in other objects.")
|
||||||
@ -100,7 +101,7 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
private KList<IrisDepositGenerator> deposits = new KList<>();
|
private KList<IrisDepositGenerator> deposits = new KList<>();
|
||||||
|
|
||||||
private transient InferredType inferredType;
|
private transient InferredType inferredType;
|
||||||
private transient AtomicCache<RarityCellGenerator> childrenCell = new AtomicCache<>();
|
private transient AtomicCache<RarityCellGenerator<IrisBiome>> childrenCell = new AtomicCache<>();
|
||||||
private transient AtomicCache<CNG> biomeGenerator = new AtomicCache<>();
|
private transient AtomicCache<CNG> biomeGenerator = new AtomicCache<>();
|
||||||
private transient AtomicCache<Integer> maxHeight = new AtomicCache<>();
|
private transient AtomicCache<Integer> maxHeight = new AtomicCache<>();
|
||||||
private transient AtomicCache<KList<IrisBiome>> realChildren = new AtomicCache<>();
|
private transient AtomicCache<KList<IrisBiome>> realChildren = new AtomicCache<>();
|
||||||
@ -132,11 +133,11 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public RarityCellGenerator getChildrenGenerator(RNG random, int sig, double scale)
|
public RarityCellGenerator<IrisBiome> getChildrenGenerator(RNG random, int sig, double scale)
|
||||||
{
|
{
|
||||||
return childrenCell.aquire(() ->
|
return childrenCell.aquire(() ->
|
||||||
{
|
{
|
||||||
RarityCellGenerator childrenCell = new RarityCellGenerator(random.nextParallelRNG(sig * 2137));
|
RarityCellGenerator<IrisBiome> childrenCell = new RarityCellGenerator<IrisBiome>(random.nextParallelRNG(sig * 2137));
|
||||||
childrenCell.setCellScale(scale);
|
childrenCell.setCellScale(scale);
|
||||||
return childrenCell;
|
return childrenCell;
|
||||||
});
|
});
|
||||||
|
@ -182,6 +182,14 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
@Desc("Change the size of regions")
|
@Desc("Change the size of regions")
|
||||||
private double regionZoom = 1;
|
private double regionZoom = 1;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The shuffle of regions")
|
||||||
|
private double regionShuffle = 11;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The shuffle of land vs sea")
|
||||||
|
private double continentalShuffle = 99;
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("Disable this to stop placing schematics in biomes")
|
@Desc("Disable this to stop placing schematics in biomes")
|
||||||
private boolean placeObjects = true;
|
private boolean placeObjects = true;
|
||||||
|
@ -6,6 +6,7 @@ import com.volmit.iris.gen.atomics.AtomicCache;
|
|||||||
import com.volmit.iris.util.CNG;
|
import com.volmit.iris.util.CNG;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
|
import com.volmit.iris.util.IRare;
|
||||||
import com.volmit.iris.util.KList;
|
import com.volmit.iris.util.KList;
|
||||||
import com.volmit.iris.util.KMap;
|
import com.volmit.iris.util.KMap;
|
||||||
import com.volmit.iris.util.KSet;
|
import com.volmit.iris.util.KSet;
|
||||||
@ -17,12 +18,16 @@ import lombok.EqualsAndHashCode;
|
|||||||
@Desc("Represents an iris region")
|
@Desc("Represents an iris region")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class IrisRegion extends IrisRegistrant
|
public class IrisRegion extends IrisRegistrant implements IRare
|
||||||
{
|
{
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The name of the region")
|
@Desc("The name of the region")
|
||||||
private String name = "A Region";
|
private String name = "A Region";
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The rarity of the region")
|
||||||
|
private int rarity = 1;
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The shore ration (How much percent of land should be a shore)")
|
@Desc("The shore ration (How much percent of land should be a shore)")
|
||||||
private double shoreRatio = 0.13;
|
private double shoreRatio = 0.13;
|
||||||
@ -182,6 +187,9 @@ public class IrisRegion extends IrisRegistrant
|
|||||||
KMap<String, IrisBiome> b = new KMap<>();
|
KMap<String, IrisBiome> b = new KMap<>();
|
||||||
KSet<String> names = new KSet<>();
|
KSet<String> names = new KSet<>();
|
||||||
names.addAll(landBiomes);
|
names.addAll(landBiomes);
|
||||||
|
names.addAll(islandBiomes);
|
||||||
|
names.addAll(caveBiomes);
|
||||||
|
names.addAll(skylandBiomes);
|
||||||
names.addAll(seaBiomes);
|
names.addAll(seaBiomes);
|
||||||
names.addAll(shoreBiomes);
|
names.addAll(shoreBiomes);
|
||||||
spotBiomes.forEach((i) -> names.add(i.getBiome()));
|
spotBiomes.forEach((i) -> names.add(i.getBiome()));
|
||||||
|
6
src/main/java/com/volmit/iris/util/IRare.java
Normal file
6
src/main/java/com/volmit/iris/util/IRare.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package com.volmit.iris.util;
|
||||||
|
|
||||||
|
public interface IRare
|
||||||
|
{
|
||||||
|
public int getRarity();
|
||||||
|
}
|
@ -20,18 +20,22 @@ public class PregenJob
|
|||||||
public static int task = -1;
|
public static int task = -1;
|
||||||
private PrecisionStopwatch s;
|
private PrecisionStopwatch s;
|
||||||
private ChronoLatch cl;
|
private ChronoLatch cl;
|
||||||
|
private MortarSender sender;
|
||||||
|
private Runnable onDone;
|
||||||
|
|
||||||
public PregenJob(World world, int size)
|
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
||||||
{
|
{
|
||||||
this.s = PrecisionStopwatch.start();
|
this.s = PrecisionStopwatch.start();
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
this.onDone = onDone;
|
||||||
world.getWorldBorder().setCenter(0, 0);
|
world.getWorldBorder().setCenter(0, 0);
|
||||||
world.getWorldBorder().setWarningDistance(64);
|
world.getWorldBorder().setWarningDistance(64);
|
||||||
world.getWorldBorder().setSize(size);
|
world.getWorldBorder().setSize(size);
|
||||||
mcaX = mca(min());
|
mcaX = mca(min());
|
||||||
mcaZ = mca(min());
|
mcaZ = mca(min());
|
||||||
rcx = 0;
|
rcx = 0;
|
||||||
|
this.sender = sender;
|
||||||
cl = new ChronoLatch(3000);
|
cl = new ChronoLatch(3000);
|
||||||
rcz = 0;
|
rcz = 0;
|
||||||
total = (size / 16) * (size / 16);
|
total = (size / 16) * (size / 16);
|
||||||
@ -83,7 +87,12 @@ public class PregenJob
|
|||||||
private void tickMetrics()
|
private void tickMetrics()
|
||||||
{
|
{
|
||||||
long eta = (long) ((total - genned) * (s.getMilliseconds() / (double) genned));
|
long eta = (long) ((total - genned) * (s.getMilliseconds() / (double) genned));
|
||||||
Iris.info("Pregen: Generating: " + Form.pc(Math.min((double) genned / (double) total, 1.0), 0) + ", Elapsed: " + Form.duration((long) s.getMilliseconds()) + ", ETA: " + (genned >= total - 5 ? "Any second..." : s.getMilliseconds() < 25000 ? "Calculating..." : Form.duration(eta)) + " MS: " + Form.duration((s.getMilliseconds() / (double) genned), 2));
|
String ss = "Pregen: " + Form.pc(Math.min((double) genned / (double) total, 1.0), 0) + ", Elapsed: " + Form.duration((long) s.getMilliseconds()) + ", ETA: " + (genned >= total - 5 ? "Any second..." : s.getMilliseconds() < 25000 ? "Calculating..." : Form.duration(eta)) + " MS: " + Form.duration((s.getMilliseconds() / (double) genned), 2);
|
||||||
|
Iris.info(ss);
|
||||||
|
if(sender.isPlayer() && sender.player().isOnline())
|
||||||
|
{
|
||||||
|
sender.sendMessage(ss);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tick()
|
public void tick()
|
||||||
@ -117,6 +126,10 @@ public class PregenJob
|
|||||||
completed = true;
|
completed = true;
|
||||||
stop();
|
stop();
|
||||||
Iris.info("Pregen Completed!");
|
Iris.info("Pregen Completed!");
|
||||||
|
if(sender.isPlayer() && sender.player().isOnline())
|
||||||
|
{
|
||||||
|
sender.sendMessage("Pregen Completed!");
|
||||||
|
}
|
||||||
|
|
||||||
for(Chunk i : world.getLoadedChunks())
|
for(Chunk i : world.getLoadedChunks())
|
||||||
{
|
{
|
||||||
@ -124,6 +137,8 @@ public class PregenJob
|
|||||||
}
|
}
|
||||||
|
|
||||||
world.save();
|
world.save();
|
||||||
|
|
||||||
|
onDone.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +164,12 @@ public class PregenJob
|
|||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
{
|
{
|
||||||
Iris.warn("Pregen Crash!");
|
Iris.warn("Pregen Crash!");
|
||||||
|
if(sender.isPlayer() && sender.player().isOnline())
|
||||||
|
{
|
||||||
|
sender.sendMessage("Pregen Completed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
onDone.run();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package com.volmit.iris.util;
|
package com.volmit.iris.util;
|
||||||
|
|
||||||
import com.volmit.iris.object.IrisBiome;
|
public class RarityCellGenerator<T extends IRare> extends CellGenerator
|
||||||
|
|
||||||
public class RarityCellGenerator extends CellGenerator
|
|
||||||
{
|
{
|
||||||
public RarityCellGenerator(RNG rng)
|
public RarityCellGenerator(RNG rng)
|
||||||
{
|
{
|
||||||
super(rng);
|
super(rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisBiome get(double x, double z, KList<IrisBiome> b)
|
public T get(double x, double z, KList<T> b)
|
||||||
{
|
{
|
||||||
if(b.size() == 0)
|
if(b.size() == 0)
|
||||||
{
|
{
|
||||||
@ -21,10 +19,10 @@ public class RarityCellGenerator extends CellGenerator
|
|||||||
return b.get(0);
|
return b.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
KList<IrisBiome> rarityMapped = new KList<>();
|
KList<T> rarityMapped = new KList<>();
|
||||||
boolean o = false;
|
boolean o = false;
|
||||||
int max = 1;
|
int max = 1;
|
||||||
for(IrisBiome i : b)
|
for(T i : b)
|
||||||
{
|
{
|
||||||
if(i.getRarity() > max)
|
if(i.getRarity() > max)
|
||||||
{
|
{
|
||||||
@ -34,7 +32,7 @@ public class RarityCellGenerator extends CellGenerator
|
|||||||
|
|
||||||
max++;
|
max++;
|
||||||
|
|
||||||
for(IrisBiome i : b)
|
for(T i : b)
|
||||||
{
|
{
|
||||||
for(int j = 0; j < max - i.getRarity(); j++)
|
for(int j = 0; j < max - i.getRarity(); j++)
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,9 @@ import com.google.gson.Gson;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.object.IrisRegistrant;
|
import com.volmit.iris.object.IrisRegistrant;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class ResourceLoader<T extends IrisRegistrant>
|
public class ResourceLoader<T extends IrisRegistrant>
|
||||||
{
|
{
|
||||||
protected File root;
|
protected File root;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user