Fixes chunk iterate
This commit is contained in:
@@ -7,11 +7,17 @@ import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import net.minecraft.server.Chunk;
|
||||
import net.minecraft.server.ChunkProviderServer;
|
||||
import net.minecraft.server.Enchantment;
|
||||
import net.minecraft.server.EntityTypes;
|
||||
import net.minecraft.server.IChunkLoader;
|
||||
import net.minecraft.server.MobEffectList;
|
||||
import net.minecraft.server.PotionRegistry;
|
||||
import net.minecraft.server.WorldServer;
|
||||
|
||||
@Mixin(value = ChunkProviderServer.class, remap = false)
|
||||
@@ -45,7 +51,7 @@ public abstract class MixinChunkProviderServer {
|
||||
long unloadAfter = world.paperConfig.delayChunkUnloadsBy;
|
||||
int targetSize = Math.min(pendingUnloadChunks - 100, (int) (pendingUnloadChunks * UNLOAD_QUEUE_RESIZE_FACTOR)); // Paper - Make more aggressive
|
||||
|
||||
for (int i = 0; i < chunks.size() && pendingUnloadChunks > targetSize; i++) { // CraftBukkit removes unload logic to its method, we must check index
|
||||
for (int i = 0; i < chunks.size() && pendingUnloadChunks > targetSize; i++) {
|
||||
Chunk chunk = it.next();
|
||||
|
||||
if (chunk != null && chunk.isUnloading()) {
|
||||
@@ -58,10 +64,11 @@ public abstract class MixinChunkProviderServer {
|
||||
}
|
||||
|
||||
// If a plugin cancelled it, we shouldn't trying unload it for a while
|
||||
chunk.setShouldUnload(false); // Paper
|
||||
chunk.setShouldUnload(false); // Paper
|
||||
|
||||
if (!unloadChunk(chunk, true)) continue; // Event cancelled
|
||||
pendingUnloadChunks--;
|
||||
it.remove();
|
||||
|
||||
if (activityAccountant.activityTimeIsExhausted()) break;
|
||||
}
|
||||
@@ -72,6 +79,14 @@ public abstract class MixinChunkProviderServer {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Redirect(method = "unloadChunk", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "it/unimi/dsi/fastutil/longs/Long2ObjectOpenHashMap.remove(J)Lnet/minecraft/server/Chunk;"
|
||||
))
|
||||
private Chunk remove(Long2ObjectOpenHashMap<Chunk> chunks, Object chunkHash) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Overwrite
|
||||
public String getName() {
|
||||
return "ServerChunkCache: " + chunks.size(); // Akarin - remove unload queue
|
||||
|
||||
@@ -18,6 +18,12 @@ import com.google.common.collect.Lists; // CraftBukkit
|
||||
import org.bukkit.Server; // CraftBukkit
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers; // Paper
|
||||
|
||||
/**
|
||||
* <b>Akarin Changes Note</b><br>
|
||||
* <br>
|
||||
* 1) Expose private members<br>
|
||||
* @author cakoyo
|
||||
*/
|
||||
public class Chunk {
|
||||
|
||||
private static final Logger e = LogManager.getLogger();
|
||||
|
||||
Reference in New Issue
Block a user