mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 19:19:07 +00:00
Auto stash before revert of "Drop it "
This commit is contained in:
@@ -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;
|
||||
@@ -460,6 +464,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
public void onChunkLoad(Chunk e, boolean generated) {
|
||||
energy += 0.3;
|
||||
fixEnergy();
|
||||
getEngine().cleanupMantleChunk(e.getX(), e.getZ());
|
||||
}
|
||||
|
||||
private void spawn(IrisPosition block, IrisSpawner spawner, boolean initial) {
|
||||
|
||||
@@ -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,11 +212,13 @@ 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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -262,4 +269,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.PLANNED))
|
||||
{
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
@@ -124,9 +129,35 @@ public class HeadlessGenerator implements PlatformChunkGenerator {
|
||||
if (listener != null) {
|
||||
listener.onChunkGenerated(ii, jj);
|
||||
}
|
||||
}));
|
||||
}), avgLast(x, z));
|
||||
last.add(new Position2(x, z));
|
||||
|
||||
e.complete();
|
||||
|
||||
J.a(() -> PregenTask.iterateRegion(x, z, (ii, jj) -> {
|
||||
getEngine().cleanupMantleChunk(ii, jj);
|
||||
if (listener != null) {
|
||||
listener.onChunkCleaned(ii, jj);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
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 += 7 * (i.getX() - x);
|
||||
zz += 7 * (i.getZ() - z);
|
||||
}
|
||||
|
||||
return new Position2((int)xx, (int)zz);
|
||||
}
|
||||
|
||||
@RegionCoordinates
|
||||
|
||||
Reference in New Issue
Block a user