244 lines
15 KiB
Diff
244 lines
15 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Bacteriawa <A3167717663@hotmail.com>
|
|
Date: Sat, 7 Feb 2026 23:57:50 +0800
|
|
Subject: [PATCH] Leaves: Catch update suppression crash
|
|
|
|
Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
As a part of : Leaves (https://github.com/LeavesMC/Leaves)
|
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
|
|
diff --git a/net/minecraft/network/PacketProcessor.java b/net/minecraft/network/PacketProcessor.java
|
|
index cf162ec136309d05c5aa03042652ab3932935917..469ffd54eb5af980f49061bbec0a72f4e888f8a3 100644
|
|
--- a/net/minecraft/network/PacketProcessor.java
|
|
+++ b/net/minecraft/network/PacketProcessor.java
|
|
@@ -107,7 +107,20 @@ public class PacketProcessor implements AutoCloseable {
|
|
final int packetTimerId = profiler.getOrCreateTimerAndStart(() -> "Packet Handler: ".concat(io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(ListenerAndPacket.this.packet.getClass().getName()))); try { // Folia - profiler
|
|
this.packet.handle(this.listener);
|
|
} finally { profiler.stopTimer(packetTimerId); } // Folia - profiler
|
|
- } catch (Exception var3) {
|
|
+ // Leaves start - update suppression crash fix
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ if (this.listener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl gamePacketListener) {
|
|
+ exception.providePlayer(gamePacketListener.player);
|
|
+ }
|
|
+ exception.consume();
|
|
+ } catch (Exception var3) {
|
|
+ if (var3.getCause() instanceof org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ if (this.listener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl gamePacketListener) {
|
|
+ exception.providePlayer(gamePacketListener.player);
|
|
+ }
|
|
+ exception.consume();
|
|
+ }
|
|
+ // Leaves end - update suppression crash fix
|
|
if (var3 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) {
|
|
throw PacketUtils.makeReportedException(var3, this.packet, this.listener);
|
|
}
|
|
diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java
|
|
index ab80a66646a7ebe2862221ac342b06c14fcfc734..7834f3da4d0ff4a5cdec46b023d7348369a12e96 100644
|
|
--- a/net/minecraft/network/protocol/PacketUtils.java
|
|
+++ b/net/minecraft/network/protocol/PacketUtils.java
|
|
@@ -34,6 +34,7 @@ public class PacketUtils {
|
|
}
|
|
|
|
public static <T extends PacketListener> ReportedException makeReportedException(Exception exception, Packet<T> packet, T packetListener) {
|
|
+
|
|
if (exception instanceof ReportedException reportedException) {
|
|
fillCrashReport(reportedException.getReport(), packetListener, packet);
|
|
return reportedException;
|
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
index 24f83a6875219aaf4b29e2461afcd0478a391014..9457d86461b032ff2dac338620c3d4a54e6c7071 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -1978,11 +1978,27 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
try {
|
|
profiler.startTimer(serverLevel.tickTimerId); try { // Folia - profiler
|
|
serverLevel.tick(hasTimeLeft, region); // Folia - region threading
|
|
+ // Leaves start - update suppression crash fix
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ exception.provideLevel(serverLevel);
|
|
+ exception.consume();
|
|
} finally { profiler.stopTimer(serverLevel.tickTimerId); } // Folia - profiler
|
|
} catch (Throwable var7) {
|
|
- CrashReport crashReport = CrashReport.forThrowable(var7, "Exception ticking world");
|
|
- serverLevel.fillReportDetails(crashReport);
|
|
- throw new ReportedException(crashReport);
|
|
+ org.leavesmc.leaves.util.UpdateSuppressionException updateSuppressionException = null;
|
|
+ if (var7 instanceof org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ updateSuppressionException = exception;
|
|
+ } else if (var7.getCause() instanceof org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ updateSuppressionException = exception;
|
|
+ }
|
|
+ if (updateSuppressionException != null) {
|
|
+ updateSuppressionException.provideLevel(serverLevel);
|
|
+ updateSuppressionException.consume();
|
|
+ } else {
|
|
+ // Leaves end - update suppression crash fix
|
|
+ CrashReport crashReport = CrashReport.forThrowable(var7, "Exception ticking world");
|
|
+ serverLevel.fillReportDetails(crashReport);
|
|
+ throw new ReportedException(crashReport);
|
|
+ }
|
|
}
|
|
|
|
profilerFiller.pop();
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 9345bdb2770e7c27488c547012020337fc651edc..447b3e6149716a3ca4b9721746ea471c94c56e67 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -894,7 +894,20 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
// Kaiiju end
|
|
|
|
profilerFiller.push("tick");
|
|
- this.guardEntityTick(this::tickNonPassenger, entity);
|
|
+ // Lophine start - update suppression crash fix
|
|
+ if (fun.bm.lophine.config.modules.fixes.UpdateSuppressionCrashFixConfig.enabled) {
|
|
+ try {
|
|
+ this.guardEntityTick(this::tickNonPassenger, entity); // Lophine changed
|
|
+ // Leaves start - update suppression crash fix - for dragon dupe
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ exception.provideLevel(this);
|
|
+ exception.consume();
|
|
+ // Leaves end - update suppression crash fix - for dragon dupe
|
|
+ }
|
|
+ } else {
|
|
+ this.guardEntityTick(this::tickNonPassenger, entity);
|
|
+ }
|
|
+ // Lophine end - update suppression crash fix
|
|
profilerFiller.pop();
|
|
}
|
|
}
|
|
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
|
index ca751564d9189e873d4a53be9a2c68b2a04a8624..e6ec0788b88d3431c06134c879b4bae9c769dac1 100644
|
|
--- a/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1108,6 +1108,12 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
|
|
|
// Folia - region threading - move to main tick loop where we can detect duplicates
|
|
// CraftBukkit end
|
|
+ // Leaves start - update suppression crash fix
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ exception.providePlayer(this);
|
|
+ exception.provideLevel(this.level());
|
|
+ exception.consume();
|
|
+ // Leaves start - update suppression crash fix
|
|
} catch (Throwable var4) {
|
|
CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player");
|
|
CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked");
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 5ac53fcdca5fa6aae0452840e78d67653ceececb..26de0d418e0dcbb4ecd88630d75c677fdc7ff93d 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -1427,9 +1427,19 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
|
this.walkingStepSound(pos, state);
|
|
}
|
|
|
|
+ // Leaves start - update suppression crash fix
|
|
if (broadcastGameEvent) {
|
|
- this.level().gameEvent(GameEvent.STEP, this.position(), GameEvent.Context.of(this, state));
|
|
+ try {
|
|
+ this.level().gameEvent(net.minecraft.world.level.gameevent.GameEvent.STEP, this.position(), net.minecraft.world.level.gameevent.GameEvent.Context.of(this, state));
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ exception.provideBlock(level, pos, state.getBlock());
|
|
+ if (this instanceof net.minecraft.server.level.ServerPlayer player) {
|
|
+ exception.providePlayer(player);
|
|
+ }
|
|
+ exception.consume();
|
|
+ }
|
|
}
|
|
+ // Leaves end - update suppression crash fix
|
|
|
|
return true;
|
|
} else {
|
|
diff --git a/net/minecraft/world/level/block/ShulkerBoxBlock.java b/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
index cb0471b06c33d1f79ba5b7a9b6036ba6b089d2be..46d6c6e3befc70a6878e12a4d75575e6d48d10ca 100644
|
|
--- a/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
+++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
@@ -181,7 +181,17 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
|
|
|
|
@Override
|
|
protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos, Direction direction) {
|
|
- return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos));
|
|
+ // Leaves start - update suppression crash fix
|
|
+ try {
|
|
+ return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos));
|
|
+ } catch (ClassCastException ex) {
|
|
+ if (fun.bm.lophine.config.modules.fixes.UpdateSuppressionCrashFixConfig.enabled) {
|
|
+ throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, null, this, null, ex);
|
|
+ } else {
|
|
+ throw ex;
|
|
+ }
|
|
+ }
|
|
+ // Leaves end - update suppression crash fix
|
|
}
|
|
|
|
public static Block getBlockByColor(@Nullable DyeColor color) {
|
|
diff --git a/net/minecraft/world/level/block/state/StateHolder.java b/net/minecraft/world/level/block/state/StateHolder.java
|
|
index c020d1944a25e2cd247e30a97c35bf93731d694a..74967f20099ea58cea1f9fc0f2387d8c45b54748 100644
|
|
--- a/net/minecraft/world/level/block/state/StateHolder.java
|
|
+++ b/net/minecraft/world/level/block/state/StateHolder.java
|
|
@@ -104,7 +104,16 @@ public abstract class StateHolder<O, S> implements ca.spottedleaf.moonrise.patch
|
|
if (ret != null) {
|
|
return ret;
|
|
}
|
|
- throw new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.owner);
|
|
+ // Leaves start - update suppression crash fix
|
|
+ IllegalArgumentException iae = new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.owner);
|
|
+ if (fun.bm.lophine.config.modules.fixes.UpdateSuppressionCrashFixConfig.enabled) {
|
|
+ org.leavesmc.leaves.util.UpdateSuppressionException exception = new org.leavesmc.leaves.util.UpdateSuppressionException(null, null, null, null, iae);
|
|
+ if (exception.getStackTrace()[1].getClassName().startsWith("net.minecraft")) {
|
|
+ throw exception;
|
|
+ }
|
|
+ }
|
|
+ throw iae;
|
|
+ // Leaves end - update suppression crash fix
|
|
// Paper end - optimise blockstate property access
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
index 77577d0df9b14a7ad55b2866c2ac31863226458b..5551d80a81c2878136f96b3e695c4888c7105a49 100644
|
|
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
|
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
@@ -383,7 +383,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
|
|
if (blockState == state) {
|
|
return null;
|
|
} else {
|
|
- Block block = state.getBlock();
|
|
+ Block block = state.getBlock(); try { // Leaves start - update suppression crash fix
|
|
this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING).update(i, y, i2, state);
|
|
this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES).update(i, y, i2, state);
|
|
this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR).update(i, y, i2, state);
|
|
@@ -457,6 +457,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
|
|
this.markUnsaved();
|
|
return blockState;
|
|
}
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException e) { e.provideBlock(level, pos, block); throw e; } // Leaves - update suppression crash fix
|
|
}
|
|
}
|
|
}
|
|
diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
index af21821513f11011e7bf3841d2f79cb99e4cd517..32488203ff074b675f5c8831d157b1d91bae48a9 100644
|
|
--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
@@ -63,9 +63,22 @@ public interface NeighborUpdater {
|
|
} finally { if (levelChunk != null) levelChunk.getChunkHot().stopTickingAndCount(); } // KioCG
|
|
// Spigot start
|
|
} catch (StackOverflowError ex) {
|
|
+ // Leaves start - update suppression crash fix
|
|
+ if (fun.bm.lophine.config.modules.fixes.UpdateSuppressionCrashFixConfig.enabled) {
|
|
+ throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, level, neighborBlock, null, ex);
|
|
+ }
|
|
level.lastPhysicsProblem = pos.immutable();
|
|
// Spigot end
|
|
} catch (Throwable var9) {
|
|
+ if (fun.bm.lophine.config.modules.fixes.UpdateSuppressionCrashFixConfig.enabled) {
|
|
+ if (var9 instanceof org.leavesmc.leaves.util.UpdateSuppressionException ue) {
|
|
+ ue.provideBlock(level, pos, neighborBlock);
|
|
+ throw ue;
|
|
+ } else {
|
|
+ throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, level, neighborBlock, null, var9);
|
|
+ }
|
|
+ }
|
|
+ // Leaves end - update suppression crash fix
|
|
CrashReport crashReport = CrashReport.forThrowable(var9, "Exception while updating neighbours");
|
|
CrashReportCategory crashReportCategory = crashReport.addCategory("Block being updated");
|
|
crashReportCategory.setDetail(
|