Massive enhancements

This commit is contained in:
Daniel Mills
2020-01-08 18:53:08 -05:00
parent 2a7b2343b2
commit 6179dbda8a
26 changed files with 1393 additions and 698 deletions

View File

@@ -9,15 +9,16 @@ import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.iris.generator.genobject.GenObjectDecorator;
import ninja.bytecode.iris.generator.genobject.GenObjectGroup;
import ninja.bytecode.iris.generator.layer.GenLayerBase;
import ninja.bytecode.iris.generator.layer.GenLayerBiome;
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.populator.ObjectPopulator;
import ninja.bytecode.iris.schematic.SchematicGroup;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.spec.IrisDimension;
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;
@@ -61,11 +62,11 @@ public class IrisGenerator extends ParallelChunkGenerator
private RNG rTerrain;
private IrisDimension dim;
private World world;
private GMap<String, SchematicGroup> schematicCache = new GMap<>();
private GMap<String, GenObjectGroup> schematicCache = new GMap<>();
public IrisGenerator()
{
this(Iris.dimensions.get("overworld"));
this(Iris.getController(PackController.class).getDimensions().get("overworld"));
}
public GList<IrisBiome> getLoadedBiomes()
@@ -230,15 +231,15 @@ public class IrisGenerator extends ParallelChunkGenerator
if(Iris.settings.gen.doSchematics)
{
p.add(new ObjectPopulator(this));
p.add(new GenObjectDecorator(this));
}
return p;
}
public SchematicGroup loadSchematics(String folder)
public GenObjectGroup loadSchematics(String folder)
{
return Iris.schematics.get(folder);
return Iris.getController(PackController.class).getGenObjectGroups().get(folder);
}
private double getBiomedHeight(int x, int z, ChunkPlan plan)
@@ -260,12 +261,12 @@ public class IrisGenerator extends ParallelChunkGenerator
return world;
}
public GMap<String, SchematicGroup> getSchematicCache()
public GMap<String, GenObjectGroup> getSchematicCache()
{
return schematicCache;
}
public void setSchematicCache(GMap<String, SchematicGroup> schematicCache)
public void setSchematicCache(GMap<String, GenObjectGroup> schematicCache)
{
this.schematicCache = schematicCache;
}

View File

@@ -1,4 +1,4 @@
package ninja.bytecode.iris.schematic;
package ninja.bytecode.iris.generator.genobject;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -26,7 +26,7 @@ import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.io.CustomOutputStream;
import ninja.bytecode.shuriken.logging.L;
public class Schematic
public class GenObject
{
private boolean centeredHeight;
private int w;
@@ -38,7 +38,7 @@ public class Schematic
private int mountHeight;
private BlockVector shift;
public Schematic(int w, int h, int d)
public GenObject(int w, int h, int d)
{
this.w = w;
this.h = h;
@@ -180,9 +180,9 @@ public class Schematic
s.put(new BlockVector(x, y, z), mb);
}
public Schematic copy()
public GenObject copy()
{
Schematic s = new Schematic(w, h, d);
GenObject s = new GenObject(w, h, d);
s.fill(this.s);
s.centeredHeight = centeredHeight;
s.name = name;
@@ -254,17 +254,17 @@ public class Schematic
}
}
public static Schematic load(InputStream in) throws IOException
public static GenObject load(InputStream in) throws IOException
{
Schematic s = new Schematic(1, 1, 1);
GenObject s = new GenObject(1, 1, 1);
s.read(in);
return s;
}
public static Schematic load(File f) throws IOException
public static GenObject load(File f) throws IOException
{
Schematic s = new Schematic(1, 1, 1);
GenObject s = new GenObject(1, 1, 1);
s.name = f.getName().replaceAll("\\Q.ish\\E", "");
FileInputStream fin = new FileInputStream(f);
s.read(fin);

View File

@@ -1,4 +1,4 @@
package ninja.bytecode.iris.generator.populator;
package ninja.bytecode.iris.generator.genobject;
import java.util.Random;
@@ -11,19 +11,20 @@ import org.bukkit.block.BlockFace;
import org.bukkit.generator.BlockPopulator;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.iris.controller.TimingsController;
import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.schematic.SchematicGroup;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.collections.GSet;
import ninja.bytecode.shuriken.math.M;
public class ObjectPopulator extends BlockPopulator
public class GenObjectDecorator extends BlockPopulator
{
private GMap<Biome, IrisBiome> biomeMap;
private GMap<Biome, GMap<SchematicGroup, Double>> populationCache;
private GMap<Biome, GMap<GenObjectGroup, Double>> populationCache;
public ObjectPopulator(IrisGenerator generator)
public GenObjectDecorator(IrisGenerator generator)
{
biomeMap = new GMap<>();
populationCache = new GMap<>();
@@ -32,11 +33,11 @@ public class ObjectPopulator extends BlockPopulator
{
biomeMap.put(i.getRealBiome(), i);
GMap<SchematicGroup, Double> gk = new GMap<>();
GMap<GenObjectGroup, Double> gk = new GMap<>();
for(String j : i.getSchematicGroups().k())
{
gk.put(Iris.schematics.get(j), i.getSchematicGroups().get(j));
gk.put(Iris.getController(PackController.class).getGenObjectGroups().get(j), i.getSchematicGroups().get(j));
}
populationCache.put(i.getRealBiome(), gk);
@@ -46,7 +47,7 @@ public class ObjectPopulator extends BlockPopulator
@Override
public void populate(World world, Random random, Chunk source)
{
Iris.started("decor");
Iris.getController(TimingsController.class).started("decor");
GSet<Biome> hits = new GSet<>();
for(int i = 0; i < Iris.settings.performance.decorationAccuracy; i++)
@@ -67,7 +68,7 @@ public class ObjectPopulator extends BlockPopulator
continue;
}
GMap<SchematicGroup, Double> objects = populationCache.get(biome);
GMap<GenObjectGroup, Double> objects = populationCache.get(biome);
if(objects == null)
{
@@ -78,12 +79,12 @@ public class ObjectPopulator extends BlockPopulator
populate(world, random, source, biome, ibiome, objects);
}
Iris.stopped("decor");
Iris.getController(TimingsController.class).stopped("decor");
}
private void populate(World world, Random random, Chunk source, Biome biome, IrisBiome ibiome, GMap<SchematicGroup, Double> objects)
private void populate(World world, Random random, Chunk source, Biome biome, IrisBiome ibiome, GMap<GenObjectGroup, Double> objects)
{
for(SchematicGroup i : objects.k())
for(GenObjectGroup i : objects.k())
{
for(int j = 0; j < getTries(objects.get(i)); j++)
{

View File

@@ -1,4 +1,4 @@
package ninja.bytecode.iris.schematic;
package ninja.bytecode.iris.generator.genobject;
import java.io.File;
import java.io.IOException;
@@ -6,6 +6,7 @@ import java.util.concurrent.locks.ReentrantLock;
import net.md_5.bungee.api.ChatColor;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.iris.util.Direction;
import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.execution.TaskExecutor;
@@ -14,14 +15,14 @@ import ninja.bytecode.shuriken.format.F;
import ninja.bytecode.shuriken.io.IO;
import ninja.bytecode.shuriken.logging.L;
public class SchematicGroup
public class GenObjectGroup
{
private GList<Schematic> schematics;
private GList<GenObject> schematics;
private GList<String> flags;
private String name;
private int priority;
public SchematicGroup(String name)
public GenObjectGroup(String name)
{
this.schematics = new GList<>();
this.flags = new GList<>();
@@ -39,12 +40,12 @@ public class SchematicGroup
this.name = name;
}
public GList<Schematic> getSchematics()
public GList<GenObject> getSchematics()
{
return schematics;
}
public void setSchematics(GList<Schematic> schematics)
public void setSchematics(GList<GenObject> schematics)
{
this.schematics = schematics;
}
@@ -74,13 +75,13 @@ public class SchematicGroup
return getSchematics().size();
}
public static SchematicGroup load(String string)
public static GenObjectGroup load(String string)
{
File folder = Iris.loadFolder(string);
File folder = Iris.getController(PackController.class).loadFolder(string);
if(folder != null)
{
SchematicGroup g = new SchematicGroup(string);
GenObjectGroup g = new GenObjectGroup(string);
for(File i : folder.listFiles())
{
@@ -102,7 +103,7 @@ public class SchematicGroup
{
try
{
Schematic s = Schematic.load(i);
GenObject s = GenObject.load(i);
g.getSchematics().add(s);
}
@@ -122,19 +123,19 @@ public class SchematicGroup
public void processVariants()
{
GList<Schematic> inject = new GList<>();
GList<GenObject> inject = new GList<>();
String x = Thread.currentThread().getName();
ReentrantLock rr = new ReentrantLock();
TaskExecutor ex = new TaskExecutor(Iris.settings.performance.compilerThreads, Iris.settings.performance.compilerPriority, x + "/Subroutine ");
TaskGroup gg = ex.startWork();
for(Schematic i : getSchematics())
for(GenObject i : getSchematics())
{
for(Direction j : new Direction[] {Direction.S, Direction.E, Direction.W})
{
Schematic cp = i.copy();
GenObject cp = i.copy();
gg.queue(() -> {
Schematic f = cp;
GenObject f = cp;
f.rotate(Direction.N, j);
rr.lock();
inject.add(f);
@@ -147,7 +148,7 @@ public class SchematicGroup
gg = ex.startWork();
getSchematics().add(inject);
for(Schematic i : getSchematics())
for(GenObject i : getSchematics())
{
gg.queue(() -> {
i.computeMountShift();
@@ -184,7 +185,7 @@ public class SchematicGroup
return false;
if(getClass() != obj.getClass())
return false;
SchematicGroup other = (SchematicGroup) obj;
GenObjectGroup other = (GenObjectGroup) obj;
if(flags == null)
{
if(other.flags != null)

View File

@@ -8,7 +8,7 @@ import org.bukkit.World;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.MaxingGenerator;
import ninja.bytecode.iris.util.MaxingGenerator.EnumMaxingGenerator;