feat: 添加了防更新抑制时崩服的措施
This commit is contained in:
1 parent
e8dc993ed2
commit
ea91716272
3 files changed
+38
-4
No files matched your search
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package com.github.zly2006.carpetslsaddition.mixin.server;
|
||||||
|
|
||||||
|
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
|
@Mixin(MinecraftServer.class)
|
||||||
|
public abstract class MixinMinecraftServer {
|
||||||
|
@Redirect(method = "runServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;tick(Ljava/util/function/BooleanSupplier;)V"))
|
||||||
|
private void redirectTicking(MinecraftServer instance, BooleanSupplier shouldKeepTicking) {
|
||||||
|
if (SLSCarpetSettings.maxUpdateQueueSize != -1) {
|
||||||
|
try {
|
||||||
|
instance.tick(shouldKeepTicking);
|
||||||
|
}
|
||||||
|
catch (Throwable throwable) {
|
||||||
|
if (throwable instanceof OutOfMemoryError oom) {
|
||||||
|
if (!oom.getMessage().startsWith("Create by Carpet-SLS-Addition")) {
|
||||||
|
throw throwable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw throwable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
instance.tick(shouldKeepTicking);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-3
@@ -18,13 +18,12 @@ public class MixinChainRestrictedNeighborUpdater {
|
|||||||
@Final
|
@Final
|
||||||
private ArrayDeque<?> queue;
|
private ArrayDeque<?> queue;
|
||||||
|
|
||||||
@Inject(method = "runQueuedUpdates", at = @At(value = "INVOKE", target = "Ljava/util/List;clear()V", ordinal = 0, shift = At.Shift.BEFORE), cancellable = true)
|
@Inject(method = "runQueuedUpdates", at = @At(value = "INVOKE", target = "Ljava/util/List;clear()V", ordinal = 0, shift = At.Shift.BEFORE))
|
||||||
public void injectRunQueuedUpdates(CallbackInfo ci) {
|
public void injectRunQueuedUpdates(CallbackInfo ci) {
|
||||||
int maxSize = SLSCarpetSettings.maxUpdateQueueSize;
|
int maxSize = SLSCarpetSettings.maxUpdateQueueSize;
|
||||||
if (maxSize > 0) {
|
if (maxSize > 0) {
|
||||||
if (this.queue.size() > maxSize) {
|
if (this.queue.size() > maxSize) {
|
||||||
ci.cancel();
|
throw new OutOfMemoryError("Create by Carpet-SLS-Addition: The update queue exceeded the maximum allowed allocation of heap space set by SLS Addition!");
|
||||||
// throw new OutOfMemoryError("The update queue exceeded the maximum allowed allocation of heap space set by SLS Addition!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "com.github.zly2006.carpetslsaddition.mixin",
|
"package": "com.github.zly2006.carpetslsaddition.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"server": [
|
||||||
"block.MixinBlock",
|
"block.MixinBlock",
|
||||||
"carpet.MixinFakePlayer",
|
"carpet.MixinFakePlayer",
|
||||||
"carpet.MixinSettingsManager",
|
"carpet.MixinSettingsManager",
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
"protocol.pcaSyncProtocol.entity.MixinStorageMinecartEntity",
|
"protocol.pcaSyncProtocol.entity.MixinStorageMinecartEntity",
|
||||||
"screen.MixinScreenHandler",
|
"screen.MixinScreenHandler",
|
||||||
"screen.MixinSlot",
|
"screen.MixinSlot",
|
||||||
|
"server.MixinMinecraftServer",
|
||||||
"server.MixinPlayerManager",
|
"server.MixinPlayerManager",
|
||||||
"world.MixinChainRestrictedNeighborUpdater",
|
"world.MixinChainRestrictedNeighborUpdater",
|
||||||
"world.MixinSpawnHelper"
|
"world.MixinSpawnHelper"
|
||||||
|
|||||||
Reference in new issue
Block a user