mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
125 lines
6.3 KiB
Diff
125 lines
6.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Fri, 17 Mar 2023 15:57:08 +0800
|
|
Subject: [PATCH] Fix update suppression crash
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
index 1f7f68aad97ee73763c042837f239bdc7167db55..1e8025ecb14acc7c24917793c97f54355b5a9346 100644
|
|
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
@@ -53,6 +53,10 @@ public class PacketUtils {
|
|
if (listener.shouldHandleMessage(packet)) {
|
|
try {
|
|
packet.handle(listener);
|
|
+ // Leaves start - update suppression crash fix
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ org.leavesmc.leaves.LeavesLogger.LOGGER.info(exception.getMessage());
|
|
+ // Leaves start - update suppression crash fix
|
|
} catch (Exception exception) {
|
|
if (exception instanceof ReportedException) {
|
|
ReportedException reportedexception = (ReportedException) exception;
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 57960e7ff2d85e2aa4cff5550ef719981babb0b9..557ef158dacf00b4565055019aa9532809c6bffb 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1789,7 +1789,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
this.profiler.push("tick");
|
|
|
|
try {
|
|
- worldserver.tick(shouldKeepTicking);
|
|
+ // Leaves start
|
|
+ try {
|
|
+ worldserver.tick(shouldKeepTicking);
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException e) {
|
|
+ org.leavesmc.leaves.LeavesLogger.LOGGER.info(e.getMessage());
|
|
+ }
|
|
+ // Leaves end
|
|
} catch (Throwable throwable) {
|
|
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
index d85da0661096a3587917c6636728bfd2e3eb90a2..c6737d4beb558da68b6fa39fd7595b9e453989b1 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
@@ -230,7 +230,17 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
|
|
|
|
@Override
|
|
protected int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) {
|
|
- return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(world.getBlockEntity(pos));
|
|
+ // Leaves start - fix update suppression crash
|
|
+ if (org.leavesmc.leaves.LeavesConfig.updateSuppressionCrashFix) {
|
|
+ try {
|
|
+ return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(world.getBlockEntity(pos));
|
|
+ } catch (ClassCastException ex) {
|
|
+ throw new org.leavesmc.leaves.util.UpdateSuppressionException(null, pos);
|
|
+ }
|
|
+ } else {
|
|
+ return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(world.getBlockEntity(pos));
|
|
+ }
|
|
+ // Leaves end - fix update suppression crash
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
index e679b40b9628b0eb7152978ef641f9c918c4c8b2..02fa557a129cd85abae0e57be5edc6241943a488 100644
|
|
--- a/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
+++ b/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
@@ -66,9 +66,17 @@ public interface NeighborUpdater {
|
|
state.handleNeighborChanged(world, pos, sourceBlock, sourcePos, notify);
|
|
// Spigot Start
|
|
} catch (StackOverflowError ex) {
|
|
+ // Leaves start - fix update suppression crash
|
|
+ if (org.leavesmc.leaves.LeavesConfig.updateSuppressionCrashFix) {
|
|
+ throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, sourcePos);
|
|
+ }
|
|
world.lastPhysicsProblem = new BlockPos(pos);
|
|
// Spigot End
|
|
} catch (Throwable throwable) {
|
|
+ if (org.leavesmc.leaves.LeavesConfig.updateSuppressionCrashFix) {
|
|
+ throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, sourcePos);
|
|
+ }
|
|
+ // Leaves end - fix update suppression crash
|
|
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception while updating neighbours");
|
|
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Block being updated");
|
|
|
|
diff --git a/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java b/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..77fd58a309b5d3c45f963c4bd1f47d7fc212898e
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java
|
|
@@ -0,0 +1,33 @@
|
|
+package org.leavesmc.leaves.util;
|
|
+
|
|
+import net.minecraft.core.BlockPos;
|
|
+
|
|
+public class UpdateSuppressionException extends RuntimeException {
|
|
+
|
|
+ private final BlockPos pos;
|
|
+ private final BlockPos source;
|
|
+
|
|
+ public UpdateSuppressionException(BlockPos pos, BlockPos source) {
|
|
+ super("Update suppression");
|
|
+ this.pos = pos;
|
|
+ this.source = source;
|
|
+ }
|
|
+
|
|
+ public BlockPos getPos() {
|
|
+ return pos;
|
|
+ }
|
|
+
|
|
+ public BlockPos getSource() {
|
|
+ return source;
|
|
+ }
|
|
+
|
|
+ public String getMessage() {
|
|
+ if (pos != null) {
|
|
+ return "An update suppression processed, form [x:%d,y:%d,z:%d] to [x:%d,y:%d,z:%d]"
|
|
+ .formatted(source.getX(), source.getY(), source.getZ(), pos.getX(), pos.getY(), pos.getZ());
|
|
+ } else {
|
|
+ return "An update suppression processed, form [x:%d,y:%d,z:%d]"
|
|
+ .formatted(source.getX(), source.getY(), source.getZ());
|
|
+ }
|
|
+ }
|
|
+}
|