53 lines
3.6 KiB
Diff
53 lines
3.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
|
Date: Tue, 18 Nov 2025 23:26:27 +0800
|
|
Subject: [PATCH] Leaves: Do not reset placed block on exception & Do not
|
|
prevent block entity and entity crash at LevelChunk
|
|
|
|
Co-authored by: MC_XiaoHei <xiaohei.xor7@outlook.com>
|
|
As a part of : Leaves (https://github.com/LeavesMC/Leaves)
|
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
|
|
diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java
|
|
index 4e31e25df5d57086027413bb5e6aa0e4f39452c7..02b8f4aa4aefea0391ab4ce6d634f3a050c80f5a 100644
|
|
--- a/net/minecraft/world/item/BlockItem.java
|
|
+++ b/net/minecraft/world/item/BlockItem.java
|
|
@@ -76,20 +76,8 @@ public class BlockItem extends Item {
|
|
BlockState placedState = level.getBlockState(pos);
|
|
if (placedState.is(placementState.getBlock())) {
|
|
placedState = this.updateBlockStateFromTag(pos, level, itemStack, placedState);
|
|
- // Paper start - Reset placed block on exception
|
|
- try {
|
|
this.updateCustomBlockEntityTag(pos, level, player, itemStack, placedState);
|
|
updateBlockEntityComponents(level, pos, itemStack);
|
|
- } catch (Exception ex) {
|
|
- ((org.bukkit.craftbukkit.block.CraftBlockState) previousState).revertPlace(false);
|
|
- if (player instanceof ServerPlayer serverPlayer) {
|
|
- net.minecraft.server.MinecraftServer.LOGGER.warn("Player {} tried placing invalid block", player.getScoreboardName(), ex);
|
|
- serverPlayer.connection.disconnect(net.minecraft.network.chat.Component.literal("Packet processing error"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION);
|
|
- return InteractionResult.FAIL;
|
|
- }
|
|
- throw ex; // Rethrow exception if not placed by a player
|
|
- }
|
|
- // Paper end - Reset placed block on exception
|
|
placedState.getBlock().setPlacedBy(level, pos, placedState, player, itemStack);
|
|
// CraftBukkit start - special case for handling block placement with water lilies, frog spawn and snow buckets
|
|
if (player != null && (this instanceof PlaceOnWaterBlockItem || this instanceof SolidBucketItem)) {
|
|
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
index a71b37b391ceaf1a77b9e184fd37be86b6c818dd..51e7c9287bc39d1ffaa60946c009711acdfa8572 100644
|
|
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
|
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
@@ -1018,12 +1018,6 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
|
|
|
|
profiler.pop();
|
|
} catch (Throwable t) {
|
|
- // Paper start - Prevent block entity and entity crashes
|
|
- final String msg = String.format("BlockEntity threw exception at %s:%s,%s,%s", io.papermc.paper.util.MCUtil.getLevelName(LevelChunk.this.getLevel()), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
|
|
- LevelChunk.LOGGER.error(msg, t);
|
|
- LevelChunk.this.level.getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, t))); // Paper - ServerExceptionEvent
|
|
- LevelChunk.this.removeBlockEntity(this.getPos());
|
|
- // Paper end - Prevent block entity and entity crashes
|
|
}
|
|
}
|
|
}
|