-
-
Save NoahvdAa/64d934ce8a996e4bd985d5b382e749cc to your computer and use it in GitHub Desktop.
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | |
From: Noah van der Aa <ndvdaa@gmail.com> | |
Date: Wed, 20 Oct 2021 16:59:21 +0200 | |
Subject: [PATCH] Allow physics problem exceptions | |
diff --git a/src/main/java/me/noahvdaa/blueprint/config/BlueprintConfig.java b/src/main/java/me/noahvdaa/blueprint/config/BlueprintConfig.java | |
index 540e49e50b82951a87060a3d4ea83b87358f5f96..e3b5cf9973d294f7fe35200653074eddadb6f555 100644 | |
--- a/src/main/java/me/noahvdaa/blueprint/config/BlueprintConfig.java | |
+++ b/src/main/java/me/noahvdaa/blueprint/config/BlueprintConfig.java | |
@@ -305,5 +305,11 @@ public final class BlueprintConfig { | |
private void useMojangItemOptimizations() { | |
useMojangItemOptimizations = getBoolean("use-mojang-item-optimizations", useMojangItemOptimizations); | |
} | |
+ | |
+ public boolean allowPhysicsProblemExceptions = true; | |
+ private void allowPhysicsProblemExceptions() { | |
+ allowPhysicsProblemExceptions = getBoolean("allow-physics-problem-exceptions", allowPhysicsProblemExceptions); | |
+ } | |
+ | |
} | |
} | |
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 30bd18630c395df59bb538b41b3a3fb18753514c..fa0cc52d47509e7bf3f198377a0467e1c57761f9 100644 | |
--- a/src/main/java/net/minecraft/server/MinecraftServer.java | |
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java | |
@@ -1621,7 +1621,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 f20e0987c584f77866124c0ffc2d3e93997d74dd..6d7fa935e6c234e2ba90be7b46395e120e7b121e 100644 | |
--- a/src/main/java/net/minecraft/world/level/Level.java | |
+++ b/src/main/java/net/minecraft/world/level/Level.java | |
@@ -828,11 +828,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 (this.blueprintConfig.allowPhysicsProblemExceptions && (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"); | |
Hey, i am unsure what to do with this patch as it is not meant for Paper, but your own person project i have no access to. How would i apply this properly t papermc/spigot?
I think that you only need to apply what you can from this patch, I am working on it, if there are results I will post them here:
https://www.spigotmc.org/threads/how-to-enable-update-suppression-on-spigot-or-paper.530401/
Hey, i am unsure what to do with this patch as it is not meant for Paper, but your own person project i have no access to. How would i apply this properly t papermc/spigot?
Use this patch, it should work with the latest Paper
Thanks
Here is also a patch to restore default Hopper behaviour for item shadowing:
https://gist.github.com/BenCat07/8aef146ae6ac98fc5fb97a2896bd2d89
Paper currently puts the original item in the target container, and creates a new itemstack in the source container, causing Things like a Fast sucking system to not work properly
Hey, i am unsure what to do with this patch as it is not meant for Paper, but your own person project i have no access to. How would i apply this properly t papermc/spigot?