From b0f2d4916c334a4b6f3beede924039d7fe8e426a Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 7 Apr 2023 00:39:32 +0200 Subject: [PATCH] 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 --- ...move-existing-players-to-world-spawn.patch | 4 +- .../server/Entity-getEntitySpawnReason.patch | 4 +- patches/server/Fix-block-place-logic.patch | 68 +++++++++++++++++++ ...nts-being-fired-from-unloaded-chunks.patch | 2 + 4 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 patches/server/Fix-block-place-logic.patch diff --git a/patches/server/Don-t-move-existing-players-to-world-spawn.patch b/patches/server/Don-t-move-existing-players-to-world-spawn.patch index ee3b0cd67f..1c252138ee 100644 --- a/patches/server/Don-t-move-existing-players-to-world-spawn.patch +++ b/patches/server/Don-t-move-existing-players-to-world-spawn.patch @@ -39,10 +39,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { - // Paper + // Paper start if (nbttagcompound == null) { player.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT; // set Player SpawnReason to DEFAULT on first login + player.fudgeSpawnLocation(worldserver1); // only move to spawn on first login, otherwise, stay where you are.... } - // Paper + // Paper end player.setLevel(worldserver1); diff --git a/patches/server/Entity-getEntitySpawnReason.patch b/patches/server/Entity-getEntitySpawnReason.patch index 12e6da3e23..ae5a163da3 100644 --- a/patches/server/Entity-getEntitySpawnReason.patch +++ b/patches/server/Entity-getEntitySpawnReason.patch @@ -29,11 +29,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 worldserver1 = worldserver; } -+ // Paper ++ // Paper start + if (nbttagcompound == null) { + player.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT; // set Player SpawnReason to DEFAULT on first login + } -+ // Paper ++ // Paper end player.setLevel(worldserver1); String s1 = "local"; diff --git a/patches/server/Fix-block-place-logic.patch b/patches/server/Fix-block-place-logic.patch new file mode 100644 index 0000000000..bddd0b7cc7 --- /dev/null +++ b/patches/server/Fix-block-place-logic.patch @@ -0,0 +1,68 @@ +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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/BlockItem.java ++++ b/src/main/java/net/minecraft/world/item/BlockItem.java +@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/HangingSignItem.java ++++ b/src/main/java/net/minecraft/world/item/HangingSignItem.java +@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/ItemStack.java ++++ b/src/main/java/net/minecraft/world/item/ItemStack.java +@@ -0,0 +0,0 @@ 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))); + } + +@@ -0,0 +0,0 @@ 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 { diff --git a/patches/server/Prevent-GameEvents-being-fired-from-unloaded-chunks.patch b/patches/server/Prevent-GameEvents-being-fired-from-unloaded-chunks.patch index e9b5cb2fef..453dddc5bd 100644 --- a/patches/server/Prevent-GameEvents-being-fired-from-unloaded-chunks.patch +++ b/patches/server/Prevent-GameEvents-being-fired-from-unloaded-chunks.patch @@ -12,9 +12,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void gameEvent(GameEvent event, Vec3 emitterPos, GameEvent.Context emitter) { ++ // Paper start + if (this.getChunkIfLoadedImmediately((Mth.floor(emitterPos.x) >> 4), (Mth.floor(emitterPos.z) >> 4)) == null) { + return; + } ++ // Paper end this.gameEventDispatcher.post(event, emitterPos, emitter); }