mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-08-17 16:55:57 +00:00
refactor mantle cleanup
This commit is contained in:
parent
2436ebb857
commit
adb7188eb9
@ -162,6 +162,7 @@ public class IrisSettings {
|
|||||||
public int objectLoaderCacheSize = 4_096;
|
public int objectLoaderCacheSize = 4_096;
|
||||||
public int scriptLoaderCacheSize = 512;
|
public int scriptLoaderCacheSize = 512;
|
||||||
public int tectonicPlateSize = -1;
|
public int tectonicPlateSize = -1;
|
||||||
|
public int mantleCleanupDelay = 200;
|
||||||
|
|
||||||
public int getTectonicPlateSize() {
|
public int getTectonicPlateSize() {
|
||||||
if (tectonicPlateSize > 0)
|
if (tectonicPlateSize > 0)
|
||||||
|
@ -55,6 +55,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -422,9 +423,16 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ref = new WeakReference<>(e.getWorld());
|
||||||
|
int x = e.getX(), z = e.getZ();
|
||||||
|
J.s(() -> {
|
||||||
|
World world = ref.get();
|
||||||
|
if (world == null || !world.isChunkLoaded(x, z))
|
||||||
|
return;
|
||||||
energy += 0.3;
|
energy += 0.3;
|
||||||
fixEnergy();
|
fixEnergy();
|
||||||
getEngine().cleanupMantleChunk(e.getX(), e.getZ());
|
getEngine().cleanupMantleChunk(x, z);
|
||||||
|
}, IrisSettings.get().getPerformance().mantleCleanupDelay);
|
||||||
|
|
||||||
if (generated) {
|
if (generated) {
|
||||||
//INMS.get().injectBiomesFromMantle(e, getMantle());
|
//INMS.get().injectBiomesFromMantle(e, getMantle());
|
||||||
|
@ -289,13 +289,17 @@ public interface EngineMantle extends IObjectPlacer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void cleanupChunk(int x, int z) {
|
default void cleanupChunk(int x, int z) {
|
||||||
if (!getMantle().hasFlag(x, z, MantleFlag.CLEANED) && isCovered(x, z)) {
|
if (!isCovered(x, z)) return;
|
||||||
getMantle().raiseFlag(x, z, MantleFlag.CLEANED, () -> {
|
MantleChunk chunk = getMantle().getChunk(x, z).use();
|
||||||
getMantle().deleteChunkSlice(x, z, BlockData.class);
|
try {
|
||||||
getMantle().deleteChunkSlice(x, z, String.class);
|
chunk.raiseFlag(MantleFlag.CLEANED, () -> {
|
||||||
getMantle().deleteChunkSlice(x, z, MatterCavern.class);
|
chunk.deleteSlices(BlockData.class);
|
||||||
getMantle().deleteChunkSlice(x, z, MatterFluidBody.class);
|
chunk.deleteSlices(String.class);
|
||||||
|
chunk.deleteSlices(MatterCavern.class);
|
||||||
|
chunk.deleteSlices(MatterFluidBody.class);
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
chunk.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,13 +421,10 @@ public class Mantle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
adjustedIdleDuration.set(baseIdleDuration);
|
adjustedIdleDuration.set(baseIdleDuration);
|
||||||
|
|
||||||
if (loadedRegions != null) {
|
|
||||||
if (loadedRegions.size() > tectonicLimit) {
|
if (loadedRegions.size() > tectonicLimit) {
|
||||||
// todo update this correctly and maybe do something when its above a 100%
|
// todo update this correctly and maybe do something when its above a 100%
|
||||||
adjustedIdleDuration.set(Math.max(adjustedIdleDuration.get() - (1000 * (((loadedRegions.size() - tectonicLimit) / (double) tectonicLimit) * 100) * 0.4), 4000));
|
adjustedIdleDuration.set(Math.max(adjustedIdleDuration.get() - (1000 * (((loadedRegions.size() - tectonicLimit) / (double) tectonicLimit) * 100) * 0.4), 4000));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ioTrim.set(true);
|
ioTrim.set(true);
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user