mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
"Perfection"
This commit is contained in:
parent
0e12c6906f
commit
0483bc0afe
@ -1,5 +1,8 @@
|
||||
package ninja.bytecode.iris;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@ -10,13 +13,20 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mortar.api.nms.NMP;
|
||||
import mortar.api.sched.J;
|
||||
import mortar.util.text.C;
|
||||
import ninja.bytecode.iris.controller.TimingsController;
|
||||
import ninja.bytecode.iris.controller.PackController;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.WorldReactor;
|
||||
import ninja.bytecode.iris.generator.genobject.PlacedObject;
|
||||
import ninja.bytecode.iris.pack.CompiledDimension;
|
||||
import ninja.bytecode.iris.pack.IrisBiome;
|
||||
import ninja.bytecode.iris.util.BiomeLayer;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.execution.ChronoLatch;
|
||||
import ninja.bytecode.shuriken.format.F;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
|
||||
public class CommandIris implements CommandExecutor
|
||||
{
|
||||
@ -34,6 +44,7 @@ public class CommandIris implements CommandExecutor
|
||||
msg(sender, "/iris rtp [biome] - RTP to a biome");
|
||||
msg(sender, "/iris otp [schematic] - RTP to a specific schematic");
|
||||
msg(sender, "/iris info - Chunk info");
|
||||
msg(sender, "/iris hotload - Recompile pack & inject into worlds");
|
||||
msg(sender, "/iris reload - Reload & Recompile");
|
||||
msg(sender, "/iris clean - Clean Pack Install in Iris Folder");
|
||||
msg(sender, "/ish - Iris Schematic Commands");
|
||||
@ -216,6 +227,130 @@ public class CommandIris implements CommandExecutor
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("hotload"))
|
||||
{
|
||||
msg(sender, "=== Hotloading Pack ===");
|
||||
PackController c = Iris.getController(PackController.class);
|
||||
GMap<String, String> f = new GMap<>();
|
||||
|
||||
for(World i : Bukkit.getWorlds())
|
||||
{
|
||||
if(i.getGenerator() instanceof IrisGenerator)
|
||||
{
|
||||
String n = ((IrisGenerator) i.getGenerator()).getDimension().getName();
|
||||
msg(sender, "Preparing " + n);
|
||||
f.put(i.getName(), n);
|
||||
}
|
||||
}
|
||||
|
||||
if(f.isEmpty())
|
||||
{
|
||||
msg(sender, "No Worlds to inject!");
|
||||
return true;
|
||||
}
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
Consumer<String> m = (msg) ->
|
||||
{
|
||||
|
||||
J.s(() ->
|
||||
{
|
||||
String mm = msg;
|
||||
|
||||
if(msg.contains("|"))
|
||||
{
|
||||
GList<String> fx = new GList<>();
|
||||
fx.add(msg.split("\\Q|\\E"));
|
||||
fx.remove(0);
|
||||
fx.remove(0);
|
||||
mm = fx.toString("");
|
||||
}
|
||||
|
||||
msg(sender, mm.replaceAll("\\Q \\E", ""));
|
||||
});
|
||||
};
|
||||
L.addLogConsumer(m);
|
||||
c.compile();
|
||||
L.logConsumers.remove(m);
|
||||
|
||||
for(String fi : f.k())
|
||||
{
|
||||
J.s(() ->
|
||||
{
|
||||
|
||||
World i = Bukkit.getWorld(fi);
|
||||
CompiledDimension dim = c.getDimension(f.get(fi));
|
||||
|
||||
for(String k : c.getDimensions().k())
|
||||
{
|
||||
if(c.getDimension(k).getName().equals(f.get(fi)))
|
||||
{
|
||||
dim = c.getDimension(k);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dim == null)
|
||||
{
|
||||
J.s(() -> msg(sender, "Cannot find dimnension: " + f.get(fi)));
|
||||
return;
|
||||
}
|
||||
msg(sender, "Injecting " + i.getName());
|
||||
IrisGenerator g = ((IrisGenerator) i.getGenerator());
|
||||
g.inject(dim);
|
||||
});
|
||||
}
|
||||
|
||||
J.s(() ->
|
||||
{
|
||||
if(sender instanceof Player)
|
||||
{
|
||||
ChronoLatch cl = new ChronoLatch(3000);
|
||||
Player p = (Player) sender;
|
||||
World ww = ((Player) sender).getWorld();
|
||||
msg(p, "Regenerating View Distance");
|
||||
|
||||
WorldReactor r = new WorldReactor(ww);
|
||||
r.generateRegionNormal(p, true, 45, (pct) ->
|
||||
{
|
||||
if(cl.flip())
|
||||
{
|
||||
msg(p, "Regenerating " + F.pc(pct));
|
||||
}
|
||||
}, () ->
|
||||
{
|
||||
msg(p, "Done!");
|
||||
|
||||
for(Chunk i : p.getWorld().getLoadedChunks())
|
||||
{
|
||||
if(i.getWorld().isChunkInUse(i.getX(), i.getZ()))
|
||||
{
|
||||
NMP.CHUNK.refresh(p, i);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 5);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
Consumer<String> m = (msg) ->
|
||||
{
|
||||
J.s(() -> msg(sender, msg.replaceAll("\\Q \\E", "")));
|
||||
};
|
||||
L.addLogConsumer(m);
|
||||
L.ex(e);
|
||||
L.logConsumers.remove(m);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("reload"))
|
||||
{
|
||||
msg(sender, "Reloading Iris...");
|
||||
|
@ -1,12 +1,9 @@
|
||||
package ninja.bytecode.iris;
|
||||
|
||||
import java.lang.reflect.Executable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.amazonaws.http.ExecutionContext;
|
||||
|
||||
import mortar.compute.math.M;
|
||||
import mortar.util.text.C;
|
||||
import ninja.bytecode.iris.controller.ExecutionController;
|
||||
|
@ -12,14 +12,14 @@ public class Settings
|
||||
public static class PerformanceSettings
|
||||
{
|
||||
public PerformanceMode performanceMode = PerformanceMode.HALF_CPU;
|
||||
public ObjectMode objectMode = ObjectMode.FAST_LIGHTING;
|
||||
public ObjectMode objectMode = ObjectMode.NONE;
|
||||
public boolean fastMode = false;
|
||||
public int threadPriority = Thread.MAX_PRIORITY;
|
||||
public int threadCount = 4;
|
||||
public boolean debugMode = true;
|
||||
public int decorationAccuracy = 2;
|
||||
public boolean noObjectFail = false;
|
||||
public boolean verbose = true;
|
||||
public boolean verbose = false;
|
||||
public int placeHistoryLimit = 8192;
|
||||
}
|
||||
|
||||
@ -43,10 +43,10 @@ public class Settings
|
||||
public double caveDensity = 5;
|
||||
public double caveScale = 1.2;
|
||||
public double biomeScale = 0.65;
|
||||
public boolean flatBedrock = true;
|
||||
public boolean genCarving = true;
|
||||
public boolean genCaverns = true;
|
||||
public boolean genCaves = true;
|
||||
public boolean flatBedrock = false;
|
||||
public boolean genCarving = false;
|
||||
public boolean genCaverns = false;
|
||||
public boolean genCaves = false;
|
||||
public double carvingChance = 0.352;
|
||||
public double cavernChance = 0.321;
|
||||
public int minCarvingHeight = 75;
|
||||
|
@ -5,6 +5,8 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.genobject.GenObject;
|
||||
@ -158,6 +160,26 @@ public class PackController implements IrisController
|
||||
ready = true;
|
||||
}
|
||||
|
||||
public GMap<String, CompiledDimension> getCompiledDimensions()
|
||||
{
|
||||
return compiledDimensions;
|
||||
}
|
||||
|
||||
public GMap<String, IrisDimension> getDimensions()
|
||||
{
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
public GMap<String, IrisBiome> getBiomes()
|
||||
{
|
||||
return biomes;
|
||||
}
|
||||
|
||||
public GMap<String, GenObjectGroup> getGenObjectGroups()
|
||||
{
|
||||
return genObjectGroups;
|
||||
}
|
||||
|
||||
public CompiledDimension getDimension(String name)
|
||||
{
|
||||
return compiledDimensions.get(name);
|
||||
|
@ -64,7 +64,6 @@ public class IrisGenerator extends ParallaxWorldGenerator
|
||||
//@done
|
||||
|
||||
private boolean disposed;
|
||||
private double[][][] scatterCache;
|
||||
private CNG scatter;
|
||||
private MB ICE = new MB(Material.ICE);
|
||||
private MB PACKED_ICE = new MB(Material.PACKED_ICE);
|
||||
@ -110,7 +109,7 @@ public class IrisGenerator extends ParallaxWorldGenerator
|
||||
|
||||
public double scatter(int x, int y, int z)
|
||||
{
|
||||
return scatterCache[Math.abs(x) % 16][Math.abs(y) % 16][Math.abs(z) % 16];
|
||||
return scatter.noise(x, y, z);
|
||||
}
|
||||
|
||||
public boolean scatterChance(int x, int y, int z, double chance)
|
||||
@ -125,8 +124,7 @@ public class IrisGenerator extends ParallaxWorldGenerator
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//@builder
|
||||
random = new Random(world.getSeed());
|
||||
rTerrain = new RNG(world.getSeed());
|
||||
glLNoise = new GenLayerLayeredNoise(this, world, random, rTerrain.nextParallelRNG(2));
|
||||
glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes());
|
||||
@ -135,28 +133,12 @@ public class IrisGenerator extends ParallaxWorldGenerator
|
||||
glCaverns = new GenLayerCaverns(this, world, random, rTerrain.nextParallelRNG(-3));
|
||||
glSnow = new GenLayerSnow(this, world, random, rTerrain.nextParallelRNG(5));
|
||||
glCliffs = new GenLayerCliffs(this, world, random, rTerrain.nextParallelRNG(9));
|
||||
scatterCache = new double[16][][];
|
||||
scatter = new CNG(rTerrain.nextParallelRNG(52), 1, 1).scale(10);
|
||||
|
||||
if(Iris.settings.performance.objectMode.equals(ObjectMode.PARALLAX))
|
||||
{
|
||||
god = new GenObjectDecorator(this);
|
||||
}
|
||||
//@done
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
scatterCache[i] = new double[16][];
|
||||
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
scatterCache[i][j] = new double[16];
|
||||
|
||||
for(int k = 0; k < 16; k++)
|
||||
{
|
||||
scatterCache[i][j][k] = scatter.noise(i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -185,6 +167,7 @@ public class IrisGenerator extends ParallaxWorldGenerator
|
||||
|
||||
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
|
||||
{
|
||||
random = new Random(world.getSeed());
|
||||
PrecisionStopwatch s = getMetrics().start();
|
||||
ChunkData d = super.generateChunkData(world, random, x, z, biome);
|
||||
getMetrics().stop("chunk:ms", s);
|
||||
@ -312,7 +295,7 @@ public class IrisGenerator extends ParallaxWorldGenerator
|
||||
{
|
||||
GList<BlockPopulator> p = new GList<>();
|
||||
|
||||
if(Iris.settings.performance.objectMode.equals(ObjectMode.FAST_LIGHTING) || Iris.settings.performance.objectMode.equals(ObjectMode.LIGHTING))
|
||||
if(Iris.settings.performance.objectMode.equals(ObjectMode.QUICK_N_DIRTY) || Iris.settings.performance.objectMode.equals(ObjectMode.LIGHTING))
|
||||
{
|
||||
p.add(god = new GenObjectDecorator(this));
|
||||
}
|
||||
@ -406,7 +389,7 @@ public class IrisGenerator extends ParallaxWorldGenerator
|
||||
|
||||
else
|
||||
{
|
||||
MB mbx = biome.getScatterChanceSingle();
|
||||
MB mbx = biome.getScatterChanceSingle(scatter(wxx, i, wzx));
|
||||
|
||||
if(!mbx.material.equals(Material.AIR))
|
||||
{
|
||||
@ -549,4 +532,10 @@ public class IrisGenerator extends ParallaxWorldGenerator
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void inject(CompiledDimension dimension)
|
||||
{
|
||||
this.dim = dimension;
|
||||
onInit(getWorld(), rTerrain);
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
@ -11,223 +10,20 @@ import mortar.api.nms.NMP;
|
||||
import mortar.api.sched.J;
|
||||
import mortar.compute.math.M;
|
||||
import mortar.lang.collection.FinalDouble;
|
||||
import ninja.bytecode.iris.generator.atomics.AtomicChunkData;
|
||||
import ninja.bytecode.iris.util.ChronoQueue;
|
||||
import ninja.bytecode.iris.util.ChunkPlan;
|
||||
import ninja.bytecode.iris.util.SMCAVector;
|
||||
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.execution.ChronoLatch;
|
||||
import ninja.bytecode.shuriken.execution.NastyRunnable;
|
||||
import ninja.bytecode.shuriken.execution.TaskExecutor;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class WorldReactor
|
||||
{
|
||||
private final World world;
|
||||
private IrisGenerator gen;
|
||||
|
||||
public WorldReactor(World world)
|
||||
{
|
||||
this.world = world;
|
||||
|
||||
if(!(world.getGenerator() instanceof IrisGenerator))
|
||||
{
|
||||
throw new IllegalArgumentException(world.getName() + " is not an iris world.");
|
||||
}
|
||||
|
||||
this.gen = ((IrisGenerator) world.getGenerator());
|
||||
}
|
||||
|
||||
public void generateMultipleRegions(GMap<SMCAVector, TaskExecutor> g, boolean force, double mst, Consumer<Double> progress, Runnable done)
|
||||
{
|
||||
ChronoLatch cl = new ChronoLatch(50);
|
||||
GMap<SMCAVector, Double> p = new GMap<>();
|
||||
ReentrantLock r = new ReentrantLock();
|
||||
for(SMCAVector i : g.k())
|
||||
{
|
||||
generateRegion(i.getX(), i.getZ(), g.get(i), force, mst / (double) g.size(), (xp) ->
|
||||
{
|
||||
r.lock();
|
||||
p.put(i, xp);
|
||||
double m = 0;
|
||||
|
||||
for(double j : p.v())
|
||||
{
|
||||
m += j;
|
||||
}
|
||||
r.unlock();
|
||||
|
||||
double h = m / (double) p.size();
|
||||
|
||||
if(h == 1D || cl.flip())
|
||||
{
|
||||
progress.accept(h);
|
||||
}
|
||||
}, () ->
|
||||
{
|
||||
p.remove(i);
|
||||
|
||||
if(p.isEmpty())
|
||||
{
|
||||
done.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void generateRegion(int mx, int mz, TaskExecutor executor, boolean force, double mst, Consumer<Double> progress, Runnable done)
|
||||
{
|
||||
J.a(() ->
|
||||
{
|
||||
FinalDouble of = new FinalDouble(0D);
|
||||
FinalDouble max = new FinalDouble(0D);
|
||||
PrecisionStopwatch t = PrecisionStopwatch.start();
|
||||
GMap<SMCAVector, AtomicChunkData> data = new GMap<>();
|
||||
GMap<SMCAVector, ChunkPlan> plan = new GMap<>();
|
||||
GList<NastyRunnable> parallax = new GList<>();
|
||||
GList<NastyRunnable> noise = new GList<>();
|
||||
GList<Runnable> chunk = new GList<>();
|
||||
ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
for(int xx = mx << 5; xx < (mx << 5) + 32; xx++)
|
||||
{
|
||||
int x = xx;
|
||||
|
||||
for(int zz = mz << 5; zz < (mz << 5) + 32; zz++)
|
||||
{
|
||||
int z = zz;
|
||||
SMCAVector w = new SMCAVector(x, z);
|
||||
|
||||
if(!force && world.loadChunk(x, z, false))
|
||||
{
|
||||
// continue;
|
||||
}
|
||||
|
||||
max.add(1);
|
||||
parallax.add(() ->
|
||||
{
|
||||
gen.doGenParallax(x, z);
|
||||
of.add(1);
|
||||
progress.accept(of.get() / max.get());
|
||||
});
|
||||
|
||||
max.add(0.1);
|
||||
noise.add(() ->
|
||||
{
|
||||
AtomicChunkData tydata = new AtomicChunkData(world);
|
||||
ChunkPlan typlan = new ChunkPlan();
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
gen.onGenColumn((x << 4) + i, (z << 4) + j, i, j, typlan, tydata, true);
|
||||
}
|
||||
}
|
||||
|
||||
gen.getWorldData().getChunk(x, z).inject(tydata);
|
||||
gen.onPostChunk(world, x, z, new RNG(world.getSeed()), tydata, typlan);
|
||||
|
||||
lock.lock();
|
||||
data.put(w, tydata);
|
||||
plan.put(w, typlan);
|
||||
lock.unlock();
|
||||
of.add(1);
|
||||
progress.accept(of.get() / max.get());
|
||||
});
|
||||
|
||||
max.add(4);
|
||||
chunk.add(() ->
|
||||
{
|
||||
if(world.loadChunk(x, z, false))
|
||||
{
|
||||
world.regenerateChunk(x, z);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
world.loadChunk(x, z, true);
|
||||
}
|
||||
|
||||
Chunk cc = world.getChunkAt(x, z);
|
||||
NMP.host.relight(cc);
|
||||
cc.unload(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
executor.startWork().queue(parallax).execute();
|
||||
executor.startWork().queue(noise).execute();
|
||||
|
||||
gen.setSplicer((world, random, x, z, biome) ->
|
||||
{
|
||||
SMCAVector w = new SMCAVector(x, z);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
try
|
||||
{
|
||||
biome.setBiome((x << 4) + i, (z << 4) + j, plan.get(w).getBiome(i, j).getRealBiome());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AtomicChunkData f = data.get(w);
|
||||
|
||||
if(f != null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return f;
|
||||
});
|
||||
|
||||
t.end();
|
||||
J.s(() ->
|
||||
{
|
||||
PrecisionStopwatch s = PrecisionStopwatch.start();
|
||||
ChronoQueue q = new ChronoQueue(mst, 1096);
|
||||
int m = 0;
|
||||
for(Runnable i : chunk)
|
||||
{
|
||||
int gg = m;
|
||||
|
||||
q.queue(() ->
|
||||
{
|
||||
i.run();
|
||||
of.add(4);
|
||||
if(gg == chunk.size() - 1)
|
||||
{
|
||||
progress.accept(1D);
|
||||
s.end();
|
||||
q.dieSlowly();
|
||||
done.run();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
progress.accept(M.clip(of.get() / max.get(), 0D, 1D));
|
||||
}
|
||||
});
|
||||
|
||||
m++;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void generateRegionNormal(Player p, boolean force, double mst, Consumer<Double> progress, Runnable done)
|
||||
{
|
||||
ChronoQueue q = new ChronoQueue(mst, 1024);
|
||||
ChronoQueue q = new ChronoQueue(mst, 10240);
|
||||
FinalDouble of = new FinalDouble(0D);
|
||||
FinalDouble max = new FinalDouble(0D);
|
||||
|
||||
@ -235,23 +31,16 @@ public class WorldReactor
|
||||
{
|
||||
int x = xx;
|
||||
|
||||
for(int zz = p.getLocation().getChunk().getX() - 32; zz < p.getLocation().getChunk().getX() + 32; zz++)
|
||||
for(int zz = p.getLocation().getChunk().getZ() - 32; zz < p.getLocation().getChunk().getZ() + 32; zz++)
|
||||
{
|
||||
int z = zz;
|
||||
|
||||
if(world.isChunkLoaded(x, z) || world.loadChunk(x, z, false))
|
||||
{
|
||||
max.add(1);
|
||||
|
||||
q.queue(() ->
|
||||
{
|
||||
if(world.loadChunk(x, z, false))
|
||||
{
|
||||
world.regenerateChunk(x, z);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
world.loadChunk(x, z, true);
|
||||
}
|
||||
|
||||
Chunk cc = world.getChunkAt(x, z);
|
||||
NMP.host.relight(cc);
|
||||
@ -268,10 +57,16 @@ public class WorldReactor
|
||||
{
|
||||
progress.accept(M.clip(of.get() / max.get(), 0D, 1D));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
J.s(() ->
|
||||
{
|
||||
q.dieSlowly();
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import mortar.api.sched.S;
|
||||
import mortar.logic.format.F;
|
||||
import mortar.util.text.C;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@ -27,6 +28,7 @@ import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.collections.GSet;
|
||||
import ninja.bytecode.shuriken.execution.ChronoLatch;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
@ -101,6 +103,8 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
|
||||
@Override
|
||||
public void populate(World world, Random random, Chunk source)
|
||||
{
|
||||
Runnable m = () ->
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -141,6 +145,17 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
};
|
||||
|
||||
if(Iris.settings.performance.objectMode.equals(ObjectMode.QUICK_N_DIRTY))
|
||||
{
|
||||
J.a(m);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
m.run();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -195,7 +210,7 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
}
|
||||
}
|
||||
|
||||
if(Iris.settings.performance.objectMode.equals(ObjectMode.FAST_LIGHTING))
|
||||
if(Iris.settings.performance.objectMode.equals(ObjectMode.QUICK_N_DIRTY))
|
||||
{
|
||||
placer = new NMSPlacer(world);
|
||||
}
|
||||
@ -210,6 +225,8 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
placer = new BukkitPlacer(world, false);
|
||||
}
|
||||
|
||||
Runnable rx = () ->
|
||||
{
|
||||
Location start = go.place(x, by, z, placer);
|
||||
|
||||
if(start != null)
|
||||
@ -233,6 +250,24 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if(Iris.settings.performance.objectMode.equals(ObjectMode.QUICK_N_DIRTY))
|
||||
{
|
||||
new S(20)
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
rx.run();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
rx.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
|
||||
|
||||
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
|
||||
{
|
||||
random = new Random(world.getSeed());
|
||||
if(splicer != null)
|
||||
{
|
||||
AtomicChunkData d = splicer.onSpliceAvailable(world, random, x, z, biome);
|
||||
|
@ -589,11 +589,11 @@ public class IrisBiome
|
||||
return scatterChance;
|
||||
}
|
||||
|
||||
public MB getScatterChanceSingle()
|
||||
public MB getScatterChanceSingle(double d)
|
||||
{
|
||||
for(MB i : getScatterChance().keySet())
|
||||
{
|
||||
if(M.r(getScatterChance().get(i)))
|
||||
if(d < getScatterChance().get(i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class BiomeLayer
|
||||
{
|
||||
private static final IrisBiome VOID = new IrisBiome("Master", Biome.VOID).height(-1).dirt(MB.of(Material.END_BRICKS)).seal(RNG.r);
|
||||
public static final IrisBiome VOID = new IrisBiome("Master", Biome.VOID).height(-1).dirt(MB.of(Material.END_BRICKS)).seal(RNG.r);
|
||||
private GList<BiomeLayer> children;
|
||||
private EnumPolygonGenerator<BiomeLayer> gen;
|
||||
private IrisBiome biome;
|
||||
@ -46,18 +46,21 @@ public class BiomeLayer
|
||||
return;
|
||||
}
|
||||
|
||||
GList<BiomeLayer> b = new GList<>();
|
||||
GMap<BiomeLayer, Double> rarities = new GMap<>();
|
||||
for(BiomeLayer i : getChildren())
|
||||
{
|
||||
b.add(i);
|
||||
rarities.put(i, i.getBiome().getRarity());
|
||||
}
|
||||
|
||||
if(!getBiome().equals(VOID))
|
||||
{
|
||||
b.add(this);
|
||||
rarities.put(this, getBiome().getRarity());
|
||||
}
|
||||
|
||||
gen = new EnumPolygonGenerator<>(iris.getRTerrain().nextParallelRNG(1022 + getBiome().getRealBiome().ordinal() + getBiome().hashCode()), scale, octaves, rarities, factory).useRarity();
|
||||
gen = new EnumPolygonGenerator<>(iris.getRTerrain().nextParallelRNG(1022 + getBiome().getRealBiome().ordinal()), scale, octaves, b, rarities, factory).useRarity();
|
||||
|
||||
for(BiomeLayer i : getChildren())
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ public enum ObjectMode
|
||||
*
|
||||
* Lighting is applied later with packets
|
||||
*/
|
||||
FAST_LIGHTING,
|
||||
QUICK_N_DIRTY,
|
||||
|
||||
/**
|
||||
* Somewhat slow but produces near-perfect results. Updates lighting.
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.function.Function;
|
||||
|
||||
import mortar.lang.collection.GList;
|
||||
@ -155,10 +156,9 @@ public class PolygonGenerator
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public EnumPolygonGenerator(RNG rng, double scale, int octaves, GMap<T, Double> choiceRarities, Function<CNG, CNG> factory)
|
||||
public EnumPolygonGenerator(RNG rng, double scale, int octaves, GList<T> c, GMap<T, Double> choiceRarities, Function<CNG, CNG> factory)
|
||||
{
|
||||
super(rng, choiceRarities.size(), scale / (double) choiceRarities.size(), octaves, factory);
|
||||
GList<T> c = choiceRarities.k();
|
||||
this.choices = (T[]) c.toArray();
|
||||
int m = 0;
|
||||
|
||||
@ -182,7 +182,7 @@ public class PolygonGenerator
|
||||
|
||||
public T getChoice(double... dim)
|
||||
{
|
||||
return choices[super.getIndex(dim)];
|
||||
return choices[getIndex(dim)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user