9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/divinemc-server/minecraft-patches/features/0045-Catch-update-suppressors.patch
2025-05-08 17:11:08 +03:00

84 lines
5.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sun, 23 Feb 2025 01:14:54 +0300
Subject: [PATCH] Catch update suppressors
diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java
index e65c62dbe4c1560ae153e4c4344e9194c783a2f4..e3d3b062e273fee4a9d3ba3cadc212787096dc54 100644
--- a/net/minecraft/network/protocol/PacketUtils.java
+++ b/net/minecraft/network/protocol/PacketUtils.java
@@ -25,6 +25,10 @@ public class PacketUtils {
if (processor.shouldHandleMessage(packet)) {
try {
packet.handle(processor);
+ // DivineMC start - Catch update suppressors
+ } catch (org.bxteam.divinemc.util.exception.UpdateSuppressorException e) {
+ LOGGER.info(e.getMessage());
+ // DivineMC end - Catch update suppressors
} catch (Exception var4) {
if (var4 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) {
throw makeReportedException(var4, packet, processor);
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index c4ae883af4337e04d0944c603f298ee1576cb3d2..3a82ce898c38c5d3d971178e2614aed638e03132 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1683,6 +1683,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
serverLevel.tickTimes10s.add(this.tickCount, j);
serverLevel.tickTimes60s.add(this.tickCount, j);
// DivineMC end - MSPT Tracking for each world
+ // DivineMC start - Catch update suppressors
+ } catch (org.bxteam.divinemc.util.exception.UpdateSuppressorException e) {
+ LOGGER.info(e.getMessage());
+ // DivineMC end - Catch update suppressors
} catch (Throwable levelTickingException) {
CrashReport crashReport = CrashReport.forThrowable(levelTickingException, "Exception ticking world");
serverLevel.fillReportDetails(crashReport);
diff --git a/net/minecraft/world/level/block/ShulkerBoxBlock.java b/net/minecraft/world/level/block/ShulkerBoxBlock.java
index 49bac7af90b0a7c490141be6357563447783c6ca..941e2f04a7fd5472ad38ede08d81657604d9f2b3 100644
--- a/net/minecraft/world/level/block/ShulkerBoxBlock.java
+++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java
@@ -183,7 +183,17 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
@Override
protected int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) {
- return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos));
+ // DivineMC start - Catch update suppressors
+ try {
+ return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos));
+ } catch (ClassCastException ex) {
+ if (org.bxteam.divinemc.DivineConfig.updateSuppressionCrashFix) {
+ throw new org.bxteam.divinemc.util.exception.UpdateSuppressorException(pos, this);
+ } else {
+ throw ex;
+ }
+ }
+ // DivineMC end - Catch update suppressors
}
public static Block getBlockByColor(@Nullable DyeColor color) {
diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java
index 332b33a004ab11150cca0cc2cefc26d0286648f5..e6dce5f8bc87a2d0c7985959e3c0408f77b36f5b 100644
--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
@@ -60,9 +60,19 @@ public interface NeighborUpdater {
state.handleNeighborChanged(level, pos, neighborBlock, orientation, movedByPiston);
// Spigot start
} catch (StackOverflowError ex) {
+ // DivineMC start - Catch update suppressors
+ if (org.bxteam.divinemc.DivineConfig.updateSuppressionCrashFix) {
+ throw new org.bxteam.divinemc.util.exception.UpdateSuppressorException(pos, neighborBlock);
+ }
+ // DivineMC end - Catch update suppressors
level.lastPhysicsProblem = pos.immutable();
// Spigot end
} catch (Throwable var9) {
+ // DivineMC start - Catch update suppressors
+ if (org.bxteam.divinemc.DivineConfig.updateSuppressionCrashFix) {
+ throw new org.bxteam.divinemc.util.exception.UpdateSuppressorException(pos, neighborBlock);
+ }
+ // DivineMC end - Catch update suppressors
CrashReport crashReport = CrashReport.forThrowable(var9, "Exception while updating neighbours");
CrashReportCategory crashReportCategory = crashReport.addCategory("Block being updated");
crashReportCategory.setDetail(