Paper/patches/server/0976-Fix-block-place-logic.patch
Lulu13022002 3c8c22323f
Fix some broken block place logic (#9094)
- The dispensed shulker will not play the place sound (due to its logic been removed)
- The hanging sign text editor cannot be cancelled using the BlockPlaceEvent (not consistent with the other regular signs)
- The jukebox logic hasn't been synced with the RecordItem
2023-04-06 17:39:32 -05:00

69 lines
4.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Date: Mon, 3 Apr 2023 18:46:49 +0200
Subject: [PATCH] Fix block place logic
diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
index b0204af850ee182773ad458208cccd946ad148d5..ebee8de2ed831755b6fd154f6cc77ac993839bb9 100644
--- a/src/main/java/net/minecraft/world/item/BlockItem.java
+++ b/src/main/java/net/minecraft/world/item/BlockItem.java
@@ -131,7 +131,7 @@ public class BlockItem extends Item {
SoundType soundeffecttype = iblockdata1.getSoundType();
- // world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
+ if (entityhuman == null) world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), net.minecraft.sounds.SoundSource.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); // Paper - reintroduce this for the dispenser (i.e the shulker)
world.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.Context.of(entityhuman, iblockdata1));
if ((entityhuman == null || !entityhuman.getAbilities().instabuild) && itemstack != ItemStack.EMPTY) { // CraftBukkit
itemstack.shrink(1);
diff --git a/src/main/java/net/minecraft/world/item/HangingSignItem.java b/src/main/java/net/minecraft/world/item/HangingSignItem.java
index f8f8392ba16838449354e78f0ce69af37b0b7fed..91caa607a21bfb61849826949b59bcdac73af7ab 100644
--- a/src/main/java/net/minecraft/world/item/HangingSignItem.java
+++ b/src/main/java/net/minecraft/world/item/HangingSignItem.java
@@ -33,11 +33,14 @@ public class HangingSignItem extends StandingAndWallBlockItem {
protected boolean updateCustomBlockEntityTag(BlockPos pos, Level world, @Nullable Player player, ItemStack stack, BlockState state) {
boolean bl = super.updateCustomBlockEntityTag(pos, world, player, stack, state);
if (!world.isClientSide && !bl && player != null) {
- BlockEntity var8 = world.getBlockEntity(pos);
+ // Paper start - moved in ItemStack use handler for events cancellation
+ /*BlockEntity var8 = world.getBlockEntity(pos);
if (var8 instanceof SignBlockEntity) {
SignBlockEntity signBlockEntity = (SignBlockEntity)var8;
player.openTextEdit(signBlockEntity);
- }
+ }*/
+ SignItem.openSign = pos;
+ // Paper end
}
return bl;
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index d690b8d0c1da1f56b226376df8c76c34375e3c73..3bfef8ed7dd73f603aef06172f362bb0ed0a5c83 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -456,13 +456,7 @@ public final class ItemStack {
if (tileentity instanceof JukeboxBlockEntity) {
JukeboxBlockEntity tileentityjukebox = (JukeboxBlockEntity) tileentity;
- // There can only be one
- ItemStack record = this.copy();
- if (!record.isEmpty()) {
- record.setCount(1);
- }
-
- tileentityjukebox.setFirstItem(record);
+ tileentityjukebox.setFirstItem(this.copy()); // Paper - sync this with record item, jukebox has now an inventory
world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entityhuman, world.getBlockState(blockposition)));
}
@@ -488,7 +482,7 @@ public final class ItemStack {
}
// SPIGOT-4678
- if (this.item instanceof SignItem && SignItem.openSign != null) {
+ if ((this.item instanceof SignItem || this.item instanceof HangingSignItem) && SignItem.openSign != null) { // Paper - trigger the hanging sign text editor now
try {
entityhuman.openTextEdit((SignBlockEntity) world.getBlockEntity(SignItem.openSign));
} finally {