mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
204 lines
13 KiB
Diff
204 lines
13 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] Catch update suppression crash
|
|
|
|
|
|
diff --git a/net/minecraft/network/PacketProcessor.java b/net/minecraft/network/PacketProcessor.java
|
|
index 3e4241976fdfe65bc0aae90a9097770745c0ddf1..8e3e9a8aaee8fd4fbe986f9f079945179017c4f3 100644
|
|
--- a/net/minecraft/network/PacketProcessor.java
|
|
+++ b/net/minecraft/network/PacketProcessor.java
|
|
@@ -97,7 +97,20 @@ public class PacketProcessor implements AutoCloseable {
|
|
if (this.listener.shouldHandleMessage(this.packet)) {
|
|
try {
|
|
this.packet.handle(this.listener);
|
|
+ // Leaves start - update suppression crash fix
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ if (this.listener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl gamePacketListener) {
|
|
+ exception.providePlayer(gamePacketListener.player);
|
|
+ }
|
|
+ exception.consume();
|
|
} catch (Exception var3) {
|
|
+ if (var3.getCause() instanceof org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ if (this.listener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl gamePacketListener) {
|
|
+ exception.providePlayer(gamePacketListener.player);
|
|
+ }
|
|
+ exception.consume();
|
|
+ }
|
|
+ // Leaves end - update suppression crash fix
|
|
if (var3 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) {
|
|
throw PacketUtils.makeReportedException(var3, this.packet, this.listener);
|
|
}
|
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
index 2c9451bb024a6d185729e9b1fad508883401e468..cef816d3526cec1b7cb5b03e62454609eec876bb 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -1809,7 +1809,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
|
|
try {
|
|
serverLevel.tick(hasTimeLeft);
|
|
+ // Leaves start - update suppression crash fix
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ exception.provideLevel(serverLevel);
|
|
+ exception.consume();
|
|
} catch (Throwable var7) {
|
|
+ if (var7.getCause() instanceof org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ exception.provideLevel(serverLevel);
|
|
+ exception.consume();
|
|
+ }
|
|
+ // Leaves end - update suppression crash fix
|
|
CrashReport crashReport = CrashReport.forThrowable(var7, "Exception ticking world");
|
|
serverLevel.fillReportDetails(crashReport);
|
|
throw new ReportedException(crashReport);
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 015c49c8170ba8d73b2bc9386192681a8ececb3f..b4000881962db5fe9c6de38f406647d95a395ec3 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -842,6 +842,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
if (org.leavesmc.leaves.LeavesConfig.performance.remove.tickGuardLambda) {
|
|
try {
|
|
this.tickNonPassenger(entity); // Leaves - changed
|
|
+ // Leaves start - update suppression crash fix - for dragon dupe
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ exception.provideLevel(this);
|
|
+ exception.consume();
|
|
+ // Leaves end - update suppression crash fix - for dragon dupe
|
|
} catch (Throwable throwable) {
|
|
if (throwable instanceof ThreadDeath) throw throwable; // Paper
|
|
// Paper start - Prevent block entity and entity crashes
|
|
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
|
index 134f6eba6655b7294ebcdf5cf5d9e2183e2ecf5b..97e133f3555057e36e3e7157f1411ba923ab2823 100644
|
|
--- a/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -902,6 +902,12 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
|
((org.bukkit.craftbukkit.CraftWorldBorder) this.getBukkitEntity().getWorldBorder()).getHandle().tick();
|
|
}
|
|
// CraftBukkit end
|
|
+ // Leaves start - update suppression crash fix
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ exception.providePlayer(this);
|
|
+ exception.provideLevel(this.level());
|
|
+ exception.consume();
|
|
+ // Leaves start - update suppression crash fix
|
|
} catch (Throwable var4) {
|
|
CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player");
|
|
CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked");
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index f6dd8e81f6881400c3278ea53e2ed248625744e1..0129274ab88a151600f4fdde92dae73bec352fb2 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -1363,9 +1363,19 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
|
this.walkingStepSound(pos, state);
|
|
}
|
|
|
|
+ // Leaves start - update suppression crash fix
|
|
if (broadcastGameEvent) {
|
|
- this.level().gameEvent(GameEvent.STEP, this.position(), GameEvent.Context.of(this, state));
|
|
+ try {
|
|
+ this.level().gameEvent(net.minecraft.world.level.gameevent.GameEvent.STEP, this.position(), net.minecraft.world.level.gameevent.GameEvent.Context.of(this, state));
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) {
|
|
+ exception.provideBlock(level, pos, state.getBlock());
|
|
+ if (this instanceof net.minecraft.server.level.ServerPlayer player) {
|
|
+ exception.providePlayer(player);
|
|
+ }
|
|
+ exception.consume();
|
|
+ }
|
|
}
|
|
+ // Leaves end - update suppression crash fix
|
|
|
|
return true;
|
|
} else {
|
|
diff --git a/net/minecraft/world/level/block/ShulkerBoxBlock.java b/net/minecraft/world/level/block/ShulkerBoxBlock.java
|
|
index e08083fbb6c3090c9a6f78dbbe487cbd4fec485a..4ed941783ed038df8e94ea92cdebb72b31921d90 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 state, Level level, BlockPos pos, Direction direction) {
|
|
- return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos));
|
|
+ // Leaves start - update suppression crash fix
|
|
+ try {
|
|
+ return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos));
|
|
+ } catch (ClassCastException ex) {
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.updateSuppressionCrashFix) {
|
|
+ throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, null, this, null, ex);
|
|
+ } else {
|
|
+ throw ex;
|
|
+ }
|
|
+ }
|
|
+ // Leaves end - update suppression crash fix
|
|
}
|
|
|
|
public static Block getBlockByColor(@Nullable DyeColor color) {
|
|
diff --git a/net/minecraft/world/level/block/state/StateHolder.java b/net/minecraft/world/level/block/state/StateHolder.java
|
|
index 040919c61ed29b3eda73b5d0f8ed905011e969a4..22dae9cf15fafda4b398025d85bad3e2a5965066 100644
|
|
--- a/net/minecraft/world/level/block/state/StateHolder.java
|
|
+++ b/net/minecraft/world/level/block/state/StateHolder.java
|
|
@@ -104,7 +104,16 @@ public abstract class StateHolder<O, S> implements ca.spottedleaf.moonrise.patch
|
|
if (ret != null) {
|
|
return ret;
|
|
}
|
|
- throw new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.owner);
|
|
+ // Leaves start - update suppression crash fix
|
|
+ IllegalArgumentException iae = new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.owner);
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.updateSuppressionCrashFix) {
|
|
+ org.leavesmc.leaves.util.UpdateSuppressionException exception = new org.leavesmc.leaves.util.UpdateSuppressionException(null, null, null, null, iae);
|
|
+ if (exception.getStackTrace()[1].getClassName().startsWith("net.minecraft")) {
|
|
+ throw exception;
|
|
+ }
|
|
+ }
|
|
+ throw iae;
|
|
+ // Leaves end - update suppression crash fix
|
|
// Paper end - optimise blockstate property access
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
index bdc564c24982c196f151121fb769c7cfad4a08b0..7c5f827134e0fa81031660a78d4d404c21840cb6 100644
|
|
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
|
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
@@ -380,7 +380,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
|
|
if (blockState == state) {
|
|
return null;
|
|
} else {
|
|
- Block block = state.getBlock();
|
|
+ Block block = state.getBlock(); try { // Leaves start - update suppression crash fix
|
|
this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING).update(i, y, i2, state);
|
|
this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES).update(i, y, i2, state);
|
|
this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR).update(i, y, i2, state);
|
|
@@ -454,6 +454,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
|
|
this.markUnsaved();
|
|
return blockState;
|
|
}
|
|
+ } catch (org.leavesmc.leaves.util.UpdateSuppressionException e) { e.provideBlock(level, pos, block); throw e; } // Leaves - update suppression crash fix
|
|
}
|
|
}
|
|
}
|
|
diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
index f45cf0136e77ed5a903d033a7b0611e5edc23db9..77ed7a6a4bea3dfc77d060c49f77f4e080da200b 100644
|
|
--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
@@ -60,9 +60,22 @@ public interface NeighborUpdater {
|
|
state.handleNeighborChanged(level, pos, neighborBlock, orientation, movedByPiston);
|
|
// Spigot start
|
|
} catch (StackOverflowError ex) {
|
|
+ // Leaves start - update suppression crash fix
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.updateSuppressionCrashFix) {
|
|
+ throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, level, neighborBlock, null, ex);
|
|
+ }
|
|
level.lastPhysicsProblem = pos.immutable();
|
|
// Spigot end
|
|
} catch (Throwable var9) {
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.updateSuppressionCrashFix) {
|
|
+ if (var9 instanceof org.leavesmc.leaves.util.UpdateSuppressionException ue) {
|
|
+ ue.provideBlock(level, pos, neighborBlock);
|
|
+ throw ue;
|
|
+ } else {
|
|
+ throw new org.leavesmc.leaves.util.UpdateSuppressionException(pos, level, neighborBlock, null, var9);
|
|
+ }
|
|
+ }
|
|
+ // Leaves end - update suppression crash fix
|
|
CrashReport crashReport = CrashReport.forThrowable(var9, "Exception while updating neighbours");
|
|
CrashReportCategory crashReportCategory = crashReport.addCategory("Block being updated");
|
|
crashReportCategory.setDetail(
|