Created
November 20, 2021 15:02
-
-
Save NoahvdAa/2d86e17242c61f33cfd89e92fdf17f82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | |
From: Noah van der Aa <[email protected]> | |
Date: Wed, 20 Oct 2021 16:59:21 +0200 | |
Subject: [PATCH] Allow physics problem exceptions | |
diff --git a/src/main/java/me/noahvdaa/blueprint/util/SuppressedThrowable.java b/src/main/java/me/noahvdaa/blueprint/util/SuppressedThrowable.java | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..56306e2a613c335e94ce1412417b0a2efc31b263 | |
--- /dev/null | |
+++ b/src/main/java/me/noahvdaa/blueprint/util/SuppressedThrowable.java | |
@@ -0,0 +1,7 @@ | |
+package me.noahvdaa.blueprint.util; | |
+ | |
+public class SuppressedThrowable extends RuntimeException { | |
+ public SuppressedThrowable(String reason) { | |
+ super(reason); | |
+ } | |
+} | |
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java | |
index c958a00535c0f7a015a7a566b97e2c80fc9a0efd..f731ce08d3e0aecbaaea2636cefed160434dde43 100644 | |
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java | |
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java | |
@@ -57,6 +57,11 @@ public class PacketUtils { | |
} // Paper - timings | |
// Paper start | |
catch (Exception e) { | |
+ // Blueprint start - ignore suppressed throwables | |
+ if (e instanceof me.noahvdaa.blueprint.util.SuppressedThrowable || (e instanceof net.minecraft.ReportedException re && e.getCause() instanceof me.noahvdaa.blueprint.util.SuppressedThrowable)) { | |
+ return; | |
+ } | |
+ // Blueprint end | |
Connection networkmanager = listener.getConnection(); | |
String playerIP = com.destroystokyo.paper.PaperConfig.logPlayerIpAddresses ? String.valueOf(networkmanager.getRemoteAddress()) : "<ip address withheld>"; // Paper | |
if (networkmanager.getPlayer() != null) { | |
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java | |
index 5a4172faaf960d48939d6a485719041987df9242..be10d5df999377b49d0957dd9e6921cd61a08a63 100644 | |
--- a/src/main/java/net/minecraft/server/MinecraftServer.java | |
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java | |
@@ -1624,7 +1624,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa | |
try { | |
worldserver.timings.doTick.startTiming(); // Spigot | |
- worldserver.tick(shouldKeepTicking); | |
+ // Blueprint start | |
+ try { | |
+ worldserver.tick(shouldKeepTicking); | |
+ } catch (ReportedException e) { | |
+ if (!(e.getCause() instanceof me.noahvdaa.blueprint.util.SuppressedThrowable)) throw e.getCause(); | |
+ MinecraftServer.LOGGER.warn("Prevented crash while ticking world: " + e.getCause()); | |
+ } catch (me.noahvdaa.blueprint.util.SuppressedThrowable e) { | |
+ MinecraftServer.LOGGER.warn("Prevented crash while ticking world: " + e.getCause()); | |
+ } | |
+ // Blueprint end | |
// Paper start | |
for (final io.papermc.paper.chunk.SingleThreadChunkRegionManager regionManager : worldserver.getChunkSource().chunkMap.regionManagers) { | |
regionManager.recalculateRegions(); | |
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java | |
index 9cafd000b3533ed9fd35df2ec880f55e262084fb..5e20167bbb300f8703f9290889242fb1b6982c89 100644 | |
--- a/src/main/java/net/minecraft/world/level/Level.java | |
+++ b/src/main/java/net/minecraft/world/level/Level.java | |
@@ -814,11 +814,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable { | |
} | |
// CraftBukkit end | |
iblockdata.neighborChanged(this, pos, sourceBlock, neighborPos, false); | |
- // Spigot Start | |
- } catch (StackOverflowError ex) { | |
- Level.lastPhysicsProblem = new BlockPos(pos); | |
- // Spigot End | |
} catch (Throwable throwable) { | |
+ // Blueprint start | |
+ if (throwable instanceof StackOverflowError || throwable instanceof me.noahvdaa.blueprint.util.SuppressedThrowable) { | |
+ throw new me.noahvdaa.blueprint.util.SuppressedThrowable("Update suppression"); | |
+ } else { | |
+ // Blueprint - Move down spigot catch block | |
+ if (throwable instanceof StackOverflowError) { | |
+ lastPhysicsProblem = new BlockPos(pos); | |
+ return; | |
+ } | |
+ } | |
+ // Blueprint end | |
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception while updating neighbours"); | |
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Block being updated"); | |
can someone explain to me how to use this in my server? where do i put it, and how do i enable it?
Where to put patches?
New patch for 1.18.2! See the first post in the thread
https://www.spigotmc.org/threads/how-to-enable-update-suppression-on-spigot-or-paper.530401/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This reenables update suppression, right?