9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/leaves-server/minecraft-patches/features/0022-Remove-lambda-from-ticking-guard.patch
Lumine1909 f09fbb247d 1.21.5 (#470)
---------

Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com>
Co-authored-by: Fortern <blueten.ki@gmail.com>
Co-authored-by: MC_XiaoHei <xor7xiaohei@gmail.com>
Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
Co-authored-by: MC_XiaoHei <xiaohei.xor7@outlook.com>
2025-06-05 18:41:51 +08:00

38 lines
2.8 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/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index b1821dc6bfdda93431e2f43d5de6ecc60901c757..26a20dea38628c7acd88f172a09b12af02a82d09 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -806,7 +806,24 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
profilerFiller.push("tick");
- this.guardEntityTick(this::tickNonPassenger, entity);
+ // Leaves start - copied from this.guardEntityTick
+ if (org.leavesmc.leaves.LeavesConfig.performance.remove.tickGuardLambda) {
+ try {
+ this.tickNonPassenger(entity); // Leaves - changed
+ } catch (Throwable throwable) {
+ if (throwable instanceof ThreadDeath) throw throwable; // Paper
+ // Paper start - Prevent block 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))); // Paper - ServerExceptionEvent
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
+ // Paper end - Prevent block entity and entity crashes
+ }
+ this.moonrise$midTickTasks(); // Paper - rewrite chunk system
+ } else {
+ this.guardEntityTick(this::tickNonPassenger, entity);
+ }
+ // Leaves end - copied from this.guardEntityTick
profilerFiller.pop();
}
}