Loads of fixes

This commit is contained in:
Daniel Mills 2020-01-12 17:49:18 -05:00
parent 9a6e3a80c7
commit 9aac129aad
21 changed files with 345 additions and 154 deletions

View File

@ -174,7 +174,14 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>cb</groupId> <groupId>cb</groupId>
<artifactId>craftbukkit-1.12.2</artifactId> <artifactId>mort</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Mortar.jar</systemPath>
</dependency>
<dependency>
<groupId>cb</groupId>
<artifactId>cb12</artifactId>
<version>1</version> <version>1</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/craftbukkit-1.12.2.jar</systemPath> <systemPath>${project.basedir}/lib/craftbukkit-1.12.2.jar</systemPath>

View File

@ -160,7 +160,14 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<artifactId>craftbukkit-1.12.2</artifactId> <artifactId>mort</artifactId>
<groupId>cb</groupId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Mortar.jar</systemPath>
</dependency>
<dependency>
<artifactId>cb12</artifactId>
<groupId>cb</groupId> <groupId>cb</groupId>
<version>1</version> <version>1</version>
<scope>system</scope> <scope>system</scope>

View File

@ -1,12 +1,14 @@
package ninja.bytecode.iris; package ninja.bytecode.iris;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mortar.api.nms.NMP;
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;
@ -108,6 +110,17 @@ public class CommandIris implements CommandExecutor
msg(sender, "Reloading Iris..."); msg(sender, "Reloading Iris...");
Iris.instance.reload(); Iris.instance.reload();
} }
if(args[0].equalsIgnoreCase("refresh"))
{
msg(sender, "Sec...");
Player p = ((Player) sender);
for(Chunk i : p.getWorld().getLoadedChunks())
{
NMP.CHUNK.refresh(p, i);
}
}
} }
return false; return false;

View File

@ -1,7 +1,6 @@
package ninja.bytecode.iris; package ninja.bytecode.iris;
import ninja.bytecode.iris.util.PerformanceMode; import ninja.bytecode.iris.util.PerformanceMode;
import ninja.bytecode.iris.util.PlacerType;
public class Settings public class Settings
{ {
@ -11,20 +10,21 @@ public class Settings
public static class PerformanceSettings public static class PerformanceSettings
{ {
public PerformanceMode performanceMode = PerformanceMode.DOUBLE_CPU; public PerformanceMode performanceMode = PerformanceMode.DOUBLE_CPU;
public PlacerType placerType = PlacerType.BUKKIT_NO_PHYSICS; public boolean decoratePhysics = false;
public int threadPriority = Thread.MIN_PRIORITY; public int threadPriority = Thread.MIN_PRIORITY;
public int compilerPriority = Thread.MIN_PRIORITY; public int compilerPriority = Thread.MIN_PRIORITY;
public int threadCount = 1; public int threadCount = 1;
public boolean debugMode = true; public boolean debugMode = true;
public int compilerThreads = 12; public int compilerThreads = 12;
public int decorationAccuracy = 1; public int decorationAccuracy = 1;
public int cascadeLimit = 14;
} }
public static class GeneratorSettings public static class GeneratorSettings
{ {
public double horizontalZoom = 1; // 0.525 public double horizontalZoom = 1; // 0.525
public double heightFracture = 155; public double heightFracture = 155;
public double landScale = 0.205; public double landScale = 0.325;
public double landChance = 0.67; public double landChance = 0.67;
public double roughness = 1.333; public double roughness = 1.333;
public double heightMultiplier = 0.806; public double heightMultiplier = 0.806;
@ -38,6 +38,6 @@ public class Settings
public double caveScale = 1.45; public double caveScale = 1.45;
public double biomeScale = 2; public double biomeScale = 2;
public boolean flatBedrock = false; public boolean flatBedrock = false;
public boolean doSchematics = true; public boolean genObjects = true;
} }
} }

View File

@ -133,6 +133,7 @@ public class IrisGenerator extends ParallelChunkGenerator
@Override @Override
public Biome genColumn(int wxx, int wzx, int x, int z, ChunkPlan plan) public Biome genColumn(int wxx, int wzx, int x, int z, ChunkPlan plan)
{ {
int highest = 0;
int seaLevel = Iris.settings.gen.seaLevel; int seaLevel = Iris.settings.gen.seaLevel;
double wx = Math.round((double) wxx * Iris.settings.gen.horizontalZoom); double wx = Math.round((double) wxx * Iris.settings.gen.horizontalZoom);
double wz = Math.round((double) wzx * Iris.settings.gen.horizontalZoom); double wz = Math.round((double) wzx * Iris.settings.gen.horizontalZoom);
@ -144,7 +145,7 @@ public class IrisGenerator extends ParallelChunkGenerator
int max = Math.max(height, seaLevel); int max = Math.max(height, seaLevel);
IrisBiome override = null; IrisBiome override = null;
if(height > 61 && height < 65) if(height > 61 && height < 65 + (glLNoise.getHeight(wz, wx) * 24D))
{ {
override = biome("Beach"); override = biome("Beach");
} }
@ -191,6 +192,7 @@ public class IrisGenerator extends ParallelChunkGenerator
if(!mbx.material.equals(Material.AIR)) if(!mbx.material.equals(Material.AIR))
{ {
setBlock(x, i + 1, z, mbx.material, mbx.data); setBlock(x, i + 1, z, mbx.material, mbx.data);
highest = i > highest ? i : highest;
} }
} }
@ -205,10 +207,11 @@ public class IrisGenerator extends ParallelChunkGenerator
} }
setBlock(x, i, z, mb.material, mb.data); setBlock(x, i, z, mb.material, mb.data);
highest = i > highest ? i : highest;
} }
glCaves.genCaves(wxx, wzx, x, z, height, this); glCaves.genCaves(wxx, wzx, x, z, height, this);
plan.setRealHeight(x, z, highest);
return biome.getRealBiome(); return biome.getRealBiome();
} }
@ -221,7 +224,7 @@ public class IrisGenerator extends ParallelChunkGenerator
@Override @Override
public void onPostChunk(World world, int x, int z, Random random, AtomicChunkData data, ChunkPlan plan) public void onPostChunk(World world, int x, int z, Random random, AtomicChunkData data, ChunkPlan plan)
{ {
} }
@Override @Override
@ -229,7 +232,7 @@ public class IrisGenerator extends ParallelChunkGenerator
{ {
GList<BlockPopulator> p = new GList<>(); GList<BlockPopulator> p = new GList<>();
if(Iris.settings.gen.doSchematics) if(Iris.settings.gen.genObjects)
{ {
p.add(new GenObjectDecorator(this)); p.add(new GenObjectDecorator(this));
} }

View File

@ -15,6 +15,7 @@ import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.Iris;
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;
import ninja.bytecode.iris.util.MB; import ninja.bytecode.iris.util.MB;
@ -35,12 +36,14 @@ 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;
@ -121,6 +124,41 @@ public class GenObject
{ {
return s; return s;
} }
public int getWidth()
{
return w;
}
public int getDepth()
{
return d;
}
public int getAntiCascadeWidth()
{
if(isCascading())
{
return -1;
}
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 read(InputStream in) throws IOException
@ -130,6 +168,7 @@ public class GenObject
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();
@ -203,12 +242,12 @@ public class GenObject
int m = (g / 2); int m = (g / 2);
return g % 2 == 0 ? m : m + 1; return g % 2 == 0 ? m : m + 1;
} }
public void place(Location l) public void place(Location l)
{ {
place(l, Iris.settings.performance.placerType.get(l.getWorld())); place(l, new NMSPlacer(l.getWorld()));
} }
public void place(Location l, IPlacer placer) public void place(Location l, IPlacer placer)
{ {
place(l.getBlockX(), l.getBlockY(), l.getBlockZ(), placer); place(l.getBlockX(), l.getBlockY(), l.getBlockZ(), placer);

View File

@ -15,10 +15,12 @@ import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController; 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.generator.placer.NMSPlacer;
import ninja.bytecode.iris.pack.IrisBiome; import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.iris.util.IPlacer; import ninja.bytecode.iris.util.IPlacer;
import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.collections.GSet; import ninja.bytecode.shuriken.collections.GSet;
import ninja.bytecode.shuriken.execution.ChronoLatch;
import ninja.bytecode.shuriken.logging.L; import ninja.bytecode.shuriken.logging.L;
import ninja.bytecode.shuriken.math.M; import ninja.bytecode.shuriken.math.M;
@ -26,7 +28,9 @@ public class GenObjectDecorator extends BlockPopulator
{ {
private GMap<Biome, IrisBiome> biomeMap; private GMap<Biome, IrisBiome> biomeMap;
private GMap<Biome, GMap<GenObjectGroup, Double>> populationCache; private GMap<Biome, GMap<GenObjectGroup, Double>> populationCache;
private IPlacer cascadingPlacer;
private IPlacer placer; private IPlacer placer;
private ChronoLatch cl = new ChronoLatch(1000);
public GenObjectDecorator(IrisGenerator generator) public GenObjectDecorator(IrisGenerator generator)
{ {
@ -37,13 +41,14 @@ public class GenObjectDecorator extends BlockPopulator
{ {
biomeMap.put(i.getRealBiome(), i); biomeMap.put(i.getRealBiome(), i);
GMap<GenObjectGroup, Double> gk = new GMap<>(); GMap<GenObjectGroup, Double> gc = new GMap<>();
for(String j : i.getSchematicGroups().k()) for(String j : i.getSchematicGroups().k())
{ {
try try
{ {
gk.put(Iris.getController(PackController.class).getGenObjectGroups().get(j), i.getSchematicGroups().get(j)); GenObjectGroup g = Iris.getController(PackController.class).getGenObjectGroups().get(j);
gc.put(g, i.getSchematicGroups().get(j));
} }
catch(Throwable e) catch(Throwable e)
@ -53,13 +58,17 @@ public class GenObjectDecorator extends BlockPopulator
} }
} }
populationCache.put(i.getRealBiome(), gk); if(!gc.isEmpty())
{
populationCache.put(i.getRealBiome(), gc);
}
} }
} }
@Override @Override
public void populate(World world, Random random, Chunk source) public void populate(World world, Random rnotusingyou, Chunk source)
{ {
Random random = new Random(((source.getX() - 32) * (source.getZ() + 54)) + world.getSeed());
Iris.getController(TimingsController.class).started("decor"); Iris.getController(TimingsController.class).started("decor");
GSet<Biome> hits = new GSet<>(); GSet<Biome> hits = new GSet<>();
@ -108,17 +117,22 @@ public class GenObjectDecorator extends BlockPopulator
if(!t.isSolid() || !ibiome.isSurface(t)) if(!t.isSolid() || !ibiome.isSurface(t))
{ {
return; continue;
} }
if(placer == null) if(cascadingPlacer == null)
{ {
placer = Iris.settings.performance.placerType.get(world); cascadingPlacer = new NMSPlacer(world);
} }
i.getSchematics().get(random.nextInt(i.getSchematics().size())).place(x, b.getY(), z, placer); i.getSchematics().get(random.nextInt(i.getSchematics().size())).place(x, b.getY(), z, cascadingPlacer);
} }
} }
if(placer != null && cl.flip())
{
placer.flush();
}
} }
public int getTries(double chance) public int getTries(double chance)

View File

@ -21,6 +21,7 @@ public class GenObjectGroup
private GList<String> flags; private GList<String> flags;
private String name; private String name;
private int priority; private int priority;
private boolean noCascade;
public GenObjectGroup(String name) public GenObjectGroup(String name)
{ {
@ -28,6 +29,7 @@ public class GenObjectGroup
this.flags = new GList<>(); this.flags = new GList<>();
priority = 0; priority = 0;
this.name = name; this.name = name;
this.noCascade = false;
} }
public String getName() public String getName()
@ -85,7 +87,6 @@ public class GenObjectGroup
for(File i : folder.listFiles()) for(File i : folder.listFiles())
{ {
if(i.getName().endsWith(".ifl")) if(i.getName().endsWith(".ifl"))
{ {
try try
@ -162,7 +163,18 @@ public class GenObjectGroup
gg.execute(); gg.execute();
ex.close(); ex.close();
L.i(ChatColor.LIGHT_PURPLE + "Processed " + ChatColor.WHITE + F.f(schematics.size()) + ChatColor.LIGHT_PURPLE + " Schematics in " + ChatColor.WHITE + name); noCascade = true;
for(GenObject i : getSchematics())
{
if(i.isCascading())
{
noCascade = false;
break;
}
}
L.i(ChatColor.LIGHT_PURPLE + "Processed " + ChatColor.WHITE + F.f(schematics.size()) + ChatColor.LIGHT_PURPLE + " Schematics in " + ChatColor.WHITE + name + (noCascade ? ChatColor.AQUA + "*" : ChatColor.YELLOW + "^"));
} }
@Override @Override
@ -204,4 +216,9 @@ public class GenObjectGroup
return false; return false;
return true; return true;
} }
public boolean isCascading()
{
return !noCascade;
}
} }

View File

@ -40,29 +40,29 @@ public class GenLayerBiome extends GenLayer
pathCheck = new CNG(rng.nextParallelRNG(31), 1D, 1).scale(0.00096); pathCheck = new CNG(rng.nextParallelRNG(31), 1D, 1).scale(0.00096);
roads = new MaxingGenerator(rng.nextParallelRNG(32), 5, 0.00055, 8, factory); roads = new MaxingGenerator(rng.nextParallelRNG(32), 5, 0.00055, 8, factory);
//@done //@done
GMap<String, IrisRegion> regions = new GMap<>(); GMap<String, IrisRegion> regions = new GMap<>();
for(IrisBiome i : biomes) for(IrisBiome i : biomes)
{ {
if(!regions.containsKey(i.getRegion())) if(!regions.containsKey(i.getRegion()))
{ {
regions.put(i.getRegion(), new IrisRegion(i.getRegion())); regions.put(i.getRegion(), new IrisRegion(i.getRegion()));
} }
regions.get(i.getRegion()).getBiomes().add(i); regions.get(i.getRegion()).getBiomes().add(i);
} }
int v = 85034; int v = 85034;
regionGenerator = new EnumMaxingGenerator<IrisRegion>(rng.nextParallelRNG(v), 0.00522 * Iris.settings.gen.biomeScale * 0.189, 1, regions.v().toArray(new IrisRegion[regions.v().size()]), factory); regionGenerator = new EnumMaxingGenerator<IrisRegion>(rng.nextParallelRNG(v), 0.00522 * Iris.settings.gen.biomeScale * 0.189, 1, regions.v().toArray(new IrisRegion[regions.v().size()]), factory);
for(IrisRegion i : regions.v()) for(IrisRegion i : regions.v())
{ {
v += 13 - i.getName().length(); v += 13 - i.getName().length();
i.setGen(new EnumMaxingGenerator<IrisBiome>(rng.nextParallelRNG(33 + v), 0.000755 * i.getBiomes().size() * Iris.settings.gen.biomeScale, 1, i.getBiomes().toArray(new IrisBiome[i.getBiomes().size()]), factory)); i.setGen(new EnumMaxingGenerator<IrisBiome>(rng.nextParallelRNG(33 + v), 0.000255 * i.getBiomes().size() * Iris.settings.gen.biomeScale, 1, i.getBiomes().toArray(new IrisBiome[i.getBiomes().size()]), factory));
} }
} }
public EnumMaxingGenerator<IrisBiome> getRegionGenerator(double xx, double zz) public EnumMaxingGenerator<IrisBiome> getRegionGenerator(double xx, double zz)
{ {
return regionGenerator.getChoice(xx, zz).getGen(); return regionGenerator.getChoice(xx, zz).getGen();

View File

@ -0,0 +1,45 @@
package ninja.bytecode.iris.generator.placer;
import org.bukkit.Location;
import org.bukkit.World;
import ninja.bytecode.iris.util.AtomicChunkData;
import ninja.bytecode.iris.util.ChunkPlan;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.iris.util.Placer;
public class AtomicPlacer extends Placer
{
private AtomicChunkData data;
private ChunkPlan plan;
public AtomicPlacer(World world)
{
super(world);
}
public void bind(AtomicChunkData data, ChunkPlan plan)
{
this.data = data;
this.plan = plan;
}
@Override
public MB get(Location l)
{
return MB.of(data.getType(l.getBlockX(), l.getBlockY(), l.getBlockZ()), data.getData(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
}
@SuppressWarnings("deprecation")
@Override
public void set(Location l, MB mb)
{
data.setBlock(l.getBlockX(), l.getBlockY(), l.getBlockZ(), mb.material.getId(), mb.data);
}
@Override
public int getHighestY(Location l)
{
return plan.getRealHeight(l.getBlockX(), l.getBlockZ());
}
}

View File

@ -1,9 +1,12 @@
package ninja.bytecode.iris.util; package ninja.bytecode.iris.generator.placer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.iris.util.Placer;
public class BukkitPlacer extends Placer public class BukkitPlacer extends Placer
{ {
private final boolean applyPhysics; private final boolean applyPhysics;
@ -26,8 +29,7 @@ public class BukkitPlacer extends Placer
@Override @Override
public void set(Location l, MB mb) public void set(Location l, MB mb)
{ {
Block b = world.getBlockAt(l); l.getBlock().setTypeIdAndData(mb.material.getId(), mb.data, applyPhysics);
b.setTypeIdAndData(mb.material.getId(), mb.data, applyPhysics);
} }
@Override @Override

View File

@ -0,0 +1,60 @@
package ninja.bytecode.iris.generator.placer;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import mortar.api.nms.Catalyst;
import mortar.api.nms.NMP;
import mortar.api.world.MaterialBlock;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.iris.util.Placer;
import ninja.bytecode.shuriken.collections.GSet;
public class NMSPlacer extends Placer
{
private GSet<Chunk> c;
public NMSPlacer(World world)
{
super(world);
c = new GSet<>();
}
@SuppressWarnings("deprecation")
@Override
public MB get(Location l)
{
Block b = world.getBlockAt(l);
return MB.of(b.getType(), b.getData());
}
@SuppressWarnings("deprecation")
@Override
public void set(Location l, MB mb)
{
Catalyst.host.setBlock(l, new MaterialBlock(mb.material.getId(), mb.data));
c.add(l.getChunk());
}
@Override
public int getHighestY(Location l)
{
return world.getHighestBlockYAt(l);
}
public void flush()
{
for(Chunk i : c)
{
for(Player j : NMP.CHUNK.nearbyPlayers(i))
{
NMP.CHUNK.refresh(j, i);
}
}
c.clear();
}
}

View File

@ -47,4 +47,6 @@ public class Catalyst12
net.minecraft.server.v1_12_R1.ChunkSection sec = chunk.getSections()[y >> 4]; net.minecraft.server.v1_12_R1.ChunkSection sec = chunk.getSections()[y >> 4];
sec.setType(x & 15, y & 15, z & 15, ibd); sec.setType(x & 15, y & 15, z & 15, ibd);
} }
} }

View File

@ -0,0 +1,62 @@
package ninja.bytecode.iris.util;
import org.bukkit.Bukkit;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
import ninja.bytecode.shuriken.execution.ChronoLatch;
import ninja.bytecode.shuriken.execution.Queue;
import ninja.bytecode.shuriken.execution.ShurikenQueue;
import ninja.bytecode.shuriken.format.F;
import ninja.bytecode.shuriken.logging.L;
public class ChronoQueue
{
private PrecisionStopwatch s;
private Queue<Runnable> q;
private double limit;
private int jobLimit;
private ChronoLatch cl;
public ChronoQueue(double limit, int jobLimit)
{
this.limit = limit;
this.jobLimit = jobLimit;
s = new PrecisionStopwatch();
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::tick, 0, 0);
q = new ShurikenQueue<>();
cl = new ChronoLatch(1);
}
public void queue(Runnable r)
{
q.queue(r);
}
private void tick()
{
s.reset();
s.begin();
int m = 0;
while(q.hasNext() && (s.getMilliseconds() < limit || q.size() > jobLimit))
{
m++;
try
{
q.next().run();
}
catch(Throwable e)
{
L.ex(e);
}
}
if(cl.flip())
{
System.out.println("Q: " + F.f(q.size()) + " T: " + F.duration(s.getMilliseconds(), 2) + " DID: " + F.f(m));
}
s.end();
}
}

View File

@ -2,40 +2,32 @@ package ninja.bytecode.iris.util;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.bukkit.util.BlockVector;
import ninja.bytecode.iris.generator.genobject.GenObject;
import ninja.bytecode.iris.pack.IrisBiome; import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.collections.GMap;
public class ChunkPlan public class ChunkPlan
{ {
private final GMap<ChunkedVector, Integer> realHeightCache;
private final GMap<ChunkedVector, Double> heightCache; private final GMap<ChunkedVector, Double> heightCache;
private final GMap<ChunkedVector, IrisBiome> biomeCache; private final GMap<ChunkedVector, IrisBiome> biomeCache;
private final GMap<BlockVector, GenObject> schematics;
public ChunkPlan() public ChunkPlan()
{ {
this.schematics = new GMap<>(); this.realHeightCache = new GMap<>();
this.heightCache = new GMap<>(); this.heightCache = new GMap<>();
this.biomeCache = new GMap<>(); this.biomeCache = new GMap<>();
} }
public void planSchematic(BlockVector b, GenObject s)
{
schematics.put(b, s);
}
public IrisBiome getBiome(int x, int z) public IrisBiome getBiome(int x, int z)
{ {
return biomeCache.get(new ChunkedVector(x, z)); return biomeCache.get(new ChunkedVector(x, z));
} }
public void setBiome(int x, int z, IrisBiome cng) public void setBiome(int x, int z, IrisBiome cng)
{ {
biomeCache.put(new ChunkedVector(x, z), cng); biomeCache.put(new ChunkedVector(x, z), cng);
} }
public double getHeight(int x, int z, Supplier<Double> realHeight) public double getHeight(int x, int z, Supplier<Double> realHeight)
{ {
ChunkedVector c = new ChunkedVector(x, z); ChunkedVector c = new ChunkedVector(x, z);
@ -43,29 +35,50 @@ public class ChunkPlan
{ {
return heightCache.get(c); return heightCache.get(c);
} }
double m = realHeight.get(); double m = realHeight.get();
setHeight(c, m); setHeight(c, m);
return m; return m;
} }
public int getRealHeight(int x, int z)
{
ChunkedVector c = new ChunkedVector(x, z);
if(realHeightCache.containsKey(c))
{
return realHeightCache.get(c);
}
return 0;
}
public boolean hasHeight(ChunkedVector c) public boolean hasHeight(ChunkedVector c)
{ {
return heightCache.containsKey(c); return heightCache.containsKey(c);
} }
public boolean hasHeight(int x, int z) public boolean hasHeight(int x, int z)
{ {
return hasHeight(new ChunkedVector(x, z)); return hasHeight(new ChunkedVector(x, z));
} }
public void setHeight(ChunkedVector c, double h) public void setHeight(ChunkedVector c, double h)
{ {
heightCache.put(c, h); heightCache.put(c, h);
} }
public void setRealHeight(ChunkedVector c, int h)
{
realHeightCache.put(c, h);
}
public void setHeight(int x, int z, double h) public void setHeight(int x, int z, double h)
{ {
setHeight(new ChunkedVector(x, z), h); setHeight(new ChunkedVector(x, z), h);
} }
public void setRealHeight(int x, int z, int h)
{
setRealHeight(new ChunkedVector(x, z), h);
}
} }

View File

@ -12,4 +12,6 @@ public interface IPlacer
public void set(Location l, MB mb); public void set(Location l, MB mb);
public int getHighestY(Location l); public int getHighestY(Location l);
public void flush();
} }

View File

@ -1,73 +0,0 @@
package ninja.bytecode.iris.util;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import net.minecraft.server.v1_12_R1.Block;
import net.minecraft.server.v1_12_R1.Chunk;
import net.minecraft.server.v1_12_R1.ChunkSection;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.WorldServer;
public class NMSPlacer12 extends Placer
{
private CraftWorld craftWorld;
private WorldServer worldServer;
public NMSPlacer12(World world)
{
super(world);
craftWorld = (CraftWorld) world;
worldServer = craftWorld.getHandle();
}
@SuppressWarnings("deprecation")
@Override
public MB get(Location l)
{
Chunk c = worldServer.getChunkAt(l.getBlockX() >> 4, l.getBlockZ() >> 4);
ChunkSection s = c.getSections()[l.getBlockY() >> 4];
if(s == null)
{
return MB.of(Material.AIR);
}
IBlockData d = s.getType(l.getBlockX() & 15, l.getBlockY() & 15, l.getBlockZ() & 15);
Block block = d.getBlock();
return MB.of(Material.getMaterial(Block.getId(block)), block.toLegacyData(d) << 12);
}
@SuppressWarnings("deprecation")
@Override
public void set(Location l, MB mb)
{
Chunk c = worldServer.getChunkAt(l.getBlockX() >> 4, l.getBlockZ() >> 4);
int combined = mb.material.getId() + (mb.data << 12);
IBlockData ibd = net.minecraft.server.v1_12_R1.Block.getByCombinedId(combined);
if(c.getSections()[l.getBlockY() >> 4] == null)
{
c.getSections()[l.getBlockY() >> 4] = new net.minecraft.server.v1_12_R1.ChunkSection(l.getBlockY() >> 4 << 4, c.world.worldProvider.m());
}
int h = c.b(l.getBlockX() & 15, l.getBlockZ() & 15);
if(l.getBlockY() > h)
{
c.heightMap[(l.getBlockZ() & 15) << 4 | (l.getBlockX() & 15)] = l.getBlockY();
}
net.minecraft.server.v1_12_R1.ChunkSection sec = c.getSections()[l.getBlockY() >> 4];
sec.setType(l.getBlockX() & 15, l.getBlockY() & 15, l.getBlockZ() & 15, ibd);
c.markDirty();
}
@Override
public int getHighestY(Location l)
{
return worldServer.getChunkAt(l.getBlockX() >> 4, l.getBlockZ() >> 4)
.b(l.getBlockX() & 15, l.getBlockZ() & 15);
}
}

View File

@ -14,7 +14,6 @@ import ninja.bytecode.shuriken.execution.ChronoLatch;
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.execution.TaskExecutor.TaskResult; import ninja.bytecode.shuriken.execution.TaskExecutor.TaskResult;
import ninja.bytecode.shuriken.logging.L;
import ninja.bytecode.shuriken.math.RollingSequence; import ninja.bytecode.shuriken.math.RollingSequence;
import ninja.bytecode.shuriken.reaction.O; import ninja.bytecode.shuriken.reaction.O;
@ -41,7 +40,6 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
public void generateFullColumn(int a, int b, int c, int d, BiomeGrid g, ChunkPlan p) public void generateFullColumn(int a, int b, int c, int d, BiomeGrid g, ChunkPlan p)
{ {
g.setBiome(c, d, genColumn(a, b, c, d, p)); g.setBiome(c, d, genColumn(a, b, c, d, p));
decorateColumn(a, b, c, d, p);
} }
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
@ -100,8 +98,6 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
data.setBlock(i, 0, j, Material.RED_GLAZED_TERRACOTTA); data.setBlock(i, 0, j, Material.RED_GLAZED_TERRACOTTA);
} }
} }
L.ex(e);
} }
return data.toChunkData(); return data.toChunkData();

View File

@ -16,4 +16,9 @@ public abstract class Placer implements IPlacer
{ {
return world; return world;
} }
public void flush()
{
}
} }

View File

@ -1,24 +0,0 @@
package ninja.bytecode.iris.util;
import java.util.function.Function;
import org.bukkit.World;
public enum PlacerType
{
BUKKIT((w) -> new BukkitPlacer(w, true)),
BUKKIT_NO_PHYSICS((w) -> new BukkitPlacer(w, false)),
NMS((w) -> new NMSPlacer12(w));
private Function<World, IPlacer> placer;
private PlacerType(Function<World, IPlacer> placer)
{
this.placer = placer;
}
public IPlacer get(World world)
{
return placer.apply(world);
}
}

View File

@ -3,4 +3,5 @@ version: ${project.version}
main: ninja.bytecode.iris.Iris main: ninja.bytecode.iris.Iris
commands: commands:
iris: iris:
ish: ish:
depend: [Mortar]