mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 19:19:07 +00:00
Merge branch 'master' into rawCommands
This commit is contained in:
@@ -23,6 +23,7 @@ import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
|
||||
import com.volmit.iris.core.gui.PregeneratorJob;
|
||||
import com.volmit.iris.core.project.IrisProject;
|
||||
import com.volmit.iris.core.service.PreservationSVC;
|
||||
import com.volmit.iris.engine.actuator.IrisBiomeActuator;
|
||||
@@ -55,11 +56,13 @@ import com.volmit.iris.util.atomics.AtomicRollingSequence;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
@@ -389,6 +392,7 @@ public class IrisEngine implements Engine {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
PregeneratorJob.shutdownInstance();
|
||||
closed = true;
|
||||
J.car(art);
|
||||
getWorldManager().close();
|
||||
@@ -458,6 +462,18 @@ public class IrisEngine implements Engine {
|
||||
mode.generate(x, z, blocks, vbiomes, multicore);
|
||||
}
|
||||
|
||||
if(!multicore)
|
||||
{
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
blocks.set(i, 255, j, B.get("GLASS"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getMantle().getMantle().flag(x>>4, z>>4, MantleFlag.REAL, true);
|
||||
getMetrics().getTotal().put(p.getMilliseconds());
|
||||
generated.incrementAndGet();
|
||||
recycle();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.engine;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineAssignedWorldManager;
|
||||
@@ -41,6 +42,8 @@ import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.MatterFluidBody;
|
||||
import com.volmit.iris.util.matter.MatterMarker;
|
||||
import com.volmit.iris.util.plugin.Chunks;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
@@ -49,6 +52,7 @@ import com.volmit.iris.util.scheduling.Looper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -270,6 +274,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
private void spawnIn(Chunk c, boolean initial) {
|
||||
if(getEngine().isClosed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (initial) {
|
||||
energy += 1.2;
|
||||
}
|
||||
@@ -458,11 +467,22 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
@Override
|
||||
public void onChunkLoad(Chunk e, boolean generated) {
|
||||
if(getEngine().isClosed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
energy += 0.3;
|
||||
fixEnergy();
|
||||
getEngine().cleanupMantleChunk(e.getX(), e.getZ());
|
||||
}
|
||||
|
||||
private void spawn(IrisPosition block, IrisSpawner spawner, boolean initial) {
|
||||
if(getEngine().isClosed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (spawner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.engine.framework;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.gui.components.RenderType;
|
||||
import com.volmit.iris.core.gui.components.Renderer;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
@@ -60,6 +61,7 @@ import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.MatterFluidBody;
|
||||
import com.volmit.iris.util.matter.MatterUpdate;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
@@ -902,4 +904,12 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
Locator.region(r.getLoadKey()).find(player);
|
||||
}
|
||||
|
||||
default void cleanupMantleChunk(int x, int z)
|
||||
{
|
||||
if(IrisSettings.get().getPerformance().isTrimMantleInStudio() || !isStudio())
|
||||
{
|
||||
J.a(() -> getMantle().cleanupChunk(x, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.mantle;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
@@ -40,13 +41,17 @@ import com.volmit.iris.util.mantle.MantleChunk;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.matter.Matter;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.MatterFluidBody;
|
||||
import com.volmit.iris.util.matter.MatterMarker;
|
||||
import com.volmit.iris.util.matter.slices.UpdateMatter;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
// TODO: MOVE PLACER OUT OF MATTER INTO ITS OWN THING
|
||||
@@ -207,17 +212,18 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
int zz = j + z;
|
||||
burst.queue(() -> {
|
||||
IrisContext.touch(getEngine().getContext());
|
||||
MantleChunk mc = getMantle().getChunk(xx, zz);
|
||||
getMantle().raiseFlag(xx, zz, MantleFlag.PLANNED, () -> {
|
||||
MantleChunk mc = getMantle().getChunk(xx, zz);
|
||||
|
||||
for (MantleComponent k : getComponents()) {
|
||||
generateMantleComponent(writer, xx, zz, k, mc);
|
||||
}
|
||||
for (MantleComponent k : getComponents()) {
|
||||
generateMantleComponent(writer, xx, zz, k, mc);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
burst.complete();
|
||||
getMantle().flag(x, z, MantleFlag.REAL, true);
|
||||
}
|
||||
|
||||
default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, MantleChunk mc) {
|
||||
@@ -262,4 +268,35 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
MantleJigsawComponent getJigsawComponent();
|
||||
|
||||
MantleObjectComponent getObjectComponent();
|
||||
|
||||
default boolean isCovered(int x, int z)
|
||||
{
|
||||
int s = getRealRadius();
|
||||
|
||||
for (int i = -s; i <= s; i++) {
|
||||
for (int j = -s; j <= s; j++) {
|
||||
int xx = i + x;
|
||||
int zz = j + z;
|
||||
if(!getMantle().hasFlag(xx, zz, MantleFlag.REAL))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
default void cleanupChunk(int x, int z)
|
||||
{
|
||||
if(!getMantle().hasFlag(x, z, MantleFlag.CLEANED) && isCovered(x, z))
|
||||
{
|
||||
getMantle().raiseFlag(x, z, MantleFlag.CLEANED, () -> {
|
||||
getMantle().deleteChunkSlice(x, z, BlockData.class);
|
||||
getMantle().deleteChunkSlice(x, z, String.class);
|
||||
getMantle().deleteChunkSlice(x, z, MatterCavern.class);
|
||||
getMantle().deleteChunkSlice(x, z, MatterFluidBody.class);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
|
||||
@BlockCoordinates
|
||||
private void placeObject(MantleWriter writer, RNG rng, int x, int z, IrisObjectPlacement objectPlacement) {
|
||||
for (int i = 0; i < objectPlacement.getDensity(); i++) {
|
||||
for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) {
|
||||
IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(getComplex(), rng));
|
||||
if (v == null) {
|
||||
return;
|
||||
@@ -104,7 +104,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
@BlockCoordinates
|
||||
private Set<String> guessPlacedKeys(RNG rng, int x, int z, IrisObjectPlacement objectPlacement) {
|
||||
Set<String> f = new KSet<>();
|
||||
for (int i = 0; i < objectPlacement.getDensity(); i++) {
|
||||
for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) {
|
||||
IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(getComplex(), rng));
|
||||
if (v == null) {
|
||||
continue;
|
||||
|
||||
@@ -62,7 +62,6 @@ public class IrisObjectPlacement {
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
@Desc("Limit the max height or min height of placement.")
|
||||
private IrisObjectLimit clamp = new IrisObjectLimit();
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The maximum layer level of a snow filter overtop of this placement. Set to 0 to disable. Max of 1.")
|
||||
@@ -74,6 +73,8 @@ public class IrisObjectPlacement {
|
||||
@MinNumber(1)
|
||||
@Desc("If the chance check passes, place this many in a single chunk")
|
||||
private int density = 1;
|
||||
@Desc("If the chance check passes, and you specify this, it picks a number in the range based on noise, and 'density' is ignored.")
|
||||
private IrisStyledRange densityStyle = null;
|
||||
@MaxNumber(64)
|
||||
@MinNumber(0)
|
||||
@Desc("If the place mode is set to stilt, you can over-stilt it even further into the ground. Especially useful when using fast stilt due to inaccuracies.")
|
||||
@@ -164,18 +165,6 @@ public class IrisObjectPlacement {
|
||||
return getSurfaceWarp(rng, data).fitDouble(-(getWarp().getMultiplier() / 2D), (getWarp().getMultiplier() / 2D), x, y, z);
|
||||
}
|
||||
|
||||
public int getTriesForChunk(RNG random) {
|
||||
if (chance <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (chance >= 1 || random.nextDouble() < chance) {
|
||||
return density;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public IrisObject getObject(DataProvider g, RNG random) {
|
||||
if (place.isEmpty()) {
|
||||
return null;
|
||||
@@ -194,6 +183,21 @@ public class IrisObjectPlacement {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getDensity() {
|
||||
if (densityStyle == null) {
|
||||
return density;
|
||||
}
|
||||
return densityStyle.getMid();
|
||||
}
|
||||
|
||||
public int getDensity(RNG rng, double x, double z, IrisData data) {
|
||||
if (densityStyle == null) {
|
||||
return density;
|
||||
}
|
||||
|
||||
return (int) Math.round(densityStyle.get(rng, x, z, data));
|
||||
}
|
||||
|
||||
private TableCache getCache(IrisData manager) {
|
||||
return cache.aquire(() -> {
|
||||
TableCache tc = new TableCache();
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineTarget;
|
||||
import com.volmit.iris.engine.object.HeadlessWorld;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.documentation.RegionCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
@@ -40,6 +41,7 @@ import com.volmit.iris.util.nbt.mca.NBTWorld;
|
||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -48,6 +50,8 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Data
|
||||
@@ -59,6 +63,7 @@ public class HeadlessGenerator implements PlatformChunkGenerator {
|
||||
private final MultiBurst burst;
|
||||
private final Engine engine;
|
||||
private final long rkey = RNG.r.lmax();
|
||||
private List<Position2> last = new KList<>();
|
||||
|
||||
public HeadlessGenerator(HeadlessWorld world) {
|
||||
this(world, new IrisEngine(new EngineTarget(world.getWorld(), world.getDimension(), world.getDimension().getLoader()), world.isStudio()));
|
||||
@@ -83,7 +88,7 @@ public class HeadlessGenerator implements PlatformChunkGenerator {
|
||||
.injector((xx, yy, zz, biomeBase) -> chunk.setBiomeAt(ox + xx, yy, oz + zz,
|
||||
INMS.get().getTrueBiomeBaseId(biomeBase)))
|
||||
.build();
|
||||
getEngine().generate(x * 16, z * 16,
|
||||
getEngine().generate(x << 4, z << 4,
|
||||
Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc),
|
||||
false);
|
||||
chunk.cleanupPalettesAndBlockStates();
|
||||
@@ -124,11 +129,29 @@ public class HeadlessGenerator implements PlatformChunkGenerator {
|
||||
if (listener != null) {
|
||||
listener.onChunkGenerated(ii, jj);
|
||||
}
|
||||
}));
|
||||
|
||||
}), avgLast(x, z));
|
||||
last.add(new Position2(x, z));
|
||||
e.complete();
|
||||
}
|
||||
|
||||
private Position2 avgLast(int x, int z) {
|
||||
while(last.size() > 3)
|
||||
{
|
||||
last.remove(0);
|
||||
}
|
||||
|
||||
double xx = 0;
|
||||
double zz = 0;
|
||||
|
||||
for(Position2 i : last)
|
||||
{
|
||||
xx += 27 * (i.getX() - x);
|
||||
zz += 27 * (i.getZ() - z);
|
||||
}
|
||||
|
||||
return new Position2((int)xx, (int)zz);
|
||||
}
|
||||
|
||||
@RegionCoordinates
|
||||
public File generateRegionToFile(int x, int z, PregenListener listener) {
|
||||
generateRegion(x, z, listener);
|
||||
|
||||
Reference in New Issue
Block a user