mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
125 lines
6.4 KiB
Diff
125 lines
6.4 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 d6daa27a8d7aca00b181e90d789f4249e8437d29..61b0e26a34bf94b10ce0ac78a662d5e97ad4cc9a 100644
|
|
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
@@ -52,6 +52,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 b55cde303e18898ec791eb6d529ed4434ae70675..aa7f001a3f75f7981e8aa27d24041d9a2e0493db 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1756,7 +1756,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
|
|
// 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/block/ShulkerBoxBlock.java b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
index 68431244432a4342041e63218cf7d1eb4eb7ebc0..aeb0577abcc0790edaece34939a6756424610dbc 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
@@ -231,7 +231,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());
|
|
+ }
|
|
+ }
|
|
+}
|