From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Bacteriawa 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 24f5b890b0126fc817863f99b676da1a548f7608..a25bc31c04778bf12e3b6301ffcfb2275fcc2d90 100644 --- a/net/minecraft/network/PacketProcessor.java +++ b/net/minecraft/network/PacketProcessor.java @@ -106,7 +106,23 @@ public class PacketProcessor implements AutoCloseable { final int packetTimerId = profiler.getOrCreateTimerAndStart(() -> "Packet Handler: ".concat(ListenerAndPacket.this.packet.getClass().getName())); try { // Folia - profiler this.packet.handle(this.listener); } finally { profiler.stopTimer(packetTimerId); } // Folia - profiler + // Lophine start - catch update suppression crash + } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) { + if (this.listener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl gamePacketListener) { + exception.providePlayer(gamePacketListener.player); + } + exception.consume(); + // Lophine end - catch update suppression crash } catch (Exception var3) { + // Lophine start - catch update suppression crash + 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(); + } + + // Lophine end - catch update suppression crash if (var3 instanceof ReportedException re && re.getCause() instanceof OutOfMemoryError) { throw PacketUtils.makeReportedException(var3, this.packet, this.listener); } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java index f99c02b4d88cea924e20ca8dced67873c83c093f..0c042c4af5d52c08e9fbc03a04c4b696d8a0a7ed 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -2019,11 +2019,30 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 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); + // Lophine start - catch update suppression crash + IllegalArgumentException iae = new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.owner); + if (fun.bm.lophine.carpet.config.modules.GeneralCompatConfig.mergedUpdateSuppressionCrashEnabled()) { + 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; + // Lophine end - catch update suppression crash // 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 3708f9ffc46a5b1c038c0e7b2ce84802e2b22397..241c43170b5020c1521f43d349813586ba1f69a5 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java @@ -400,6 +400,8 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot return null; } else { Block newBlock = state.getBlock(); + // Lophine start - catch update suppression crash + try { this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING).update(localX, y, localZ, state); this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES).update(localX, y, localZ, state); this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR).update(localX, y, localZ, state); @@ -468,6 +470,11 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot this.markUnsaved(); return oldState; } + } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) { + exception.provideBlock(this.level, pos, newBlock); + throw exception; + } + // Lophine end - catch update suppression crash } } } diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java index 9b8d63f69ed1101f1b7b2728690e35165b9aeb99..6358787f3c7dcfa599b2949613236fa8de025096 100644 --- a/net/minecraft/world/level/redstone/NeighborUpdater.java +++ b/net/minecraft/world/level/redstone/NeighborUpdater.java @@ -87,9 +87,24 @@ public interface NeighborUpdater { } finally { if (levelChunk != null) levelChunk.getChunkHot().stopTickingAndCount(); } // KioCG // Spigot start } catch (StackOverflowError ex) { + // Lophine start - catch update suppression crash + if (fun.bm.lophine.carpet.config.modules.GeneralCompatConfig.mergedUpdateSuppressionCrashEnabled()) { + throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, level, changedBlock, null, ex); + } + // Lophine end - catch update suppression crash level.lastPhysicsProblem = pos.immutable(); // Spigot end } catch (Throwable var9) { + // Lophine start - catch update suppression crash + if (fun.bm.lophine.carpet.config.modules.GeneralCompatConfig.mergedUpdateSuppressionCrashEnabled()) { + if (var9 instanceof org.leavesmc.leaves.util.UpdateSuppressionException exception) { + exception.provideBlock(level, pos, changedBlock); + throw exception; + } + throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, level, changedBlock, null, var9); + } + + // Lophine end - catch update suppression crash CrashReport report = CrashReport.forThrowable(var9, "Exception while updating neighbours"); CrashReportCategory category = report.addCategory("Block being updated"); category.setDetail(