9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-23 08:59:31 +00:00
Files
LeavesMC/patches/server/0035-Remove-lambda-from-ticking-guard.patch
2023-04-16 20:57:25 +08:00

54 lines
3.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <58360096+s-yh-china@users.noreply.github.com>
Date: Wed, 17 Aug 2022 10:56:49 +0800
Subject: [PATCH] Remove lambda from ticking guard
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index b06a79cbf4ab0fe3ff6f2f9a2d4697e6bf237d60..b0a30f6426868b397ae73d20d57e0c3ddc03b470 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -728,7 +728,24 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
gameprofilerfiller.push("tick");
- this.guardEntityTick(this::tickNonPassenger, entity);
+ // Leaves start - copied from this.guardEntityTick
+ if (top.leavesmc.leaves.LeavesConfig.removeTickGuardLambda) {
+ try {
+ this.tickNonPassenger(entity); // Leaves - changed
+ MinecraftServer.getServer().executeMidTickTasks(); // Tuinity - execute chunk tasks mid tick
+ } catch (Throwable throwable) {
+ if (throwable instanceof ThreadDeath) throw throwable; // Paper
+ // Paper start - Prevent tile entity and entity crashes
+ final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level.getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
+ MinecraftServer.LOGGER.error(msg, throwable);
+ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable)));
+ entity.discard();
+ // Paper end
+ }
+ } else {
+ this.guardEntityTick(this::tickNonPassenger, entity);
+ }
+ // Leaves end - copied from this.guardEntityTick
gameprofilerfiller.pop();
}
}
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index dedf8d67dcf389c98b67614fc75b69465c18d276..83a3d5b3324ad49c0a9e203037a793c03fb3bcfc 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -329,6 +329,11 @@ public final class LeavesConfig {
reduceEntityAllocations = getBoolean("settings.performance.reduce-entity-allocations", reduceEntityAllocations);
}
+ public static boolean removeTickGuardLambda = true;
+ private static void removeTickGuardLambda() {
+ removeTickGuardLambda = getBoolean("settings.performance.remove.tick-guard-lambda", removeTickGuardLambda);
+ }
+
public static final class WorldConfig {
public final String worldName;