mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-21 07:49:35 +00:00
54 lines
3.3 KiB
Diff
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 03a4e114a3383ce779a6fc48747834b33b480f66..09f6622d9e45e16d1147a43f579d2ec7092ad4d3 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 80f8fdaf3b9b208580422645d3fe3016da4f2b0e..345b9ef0af9f8f08af00693e562e5f39a8ad3362 100644
|
|
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
@@ -324,6 +324,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;
|