aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0842-Fix-spigot-sound-playing-for-BlockItem-ItemStacks.patch
blob: c2c946f528edaa7c40e923072ab4e14d79f2a7c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Thu, 8 Jun 2023 20:23:13 -0400
Subject: [PATCH] Fix spigot sound playing for BlockItem ItemStacks


diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 0f0d35955827ffa8cdc7d947b316704a42242ad3..f099e677041daf795ffee35d3a4659274fc3f3d9 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -566,7 +566,11 @@ public final class ItemStack implements DataComponentHolder {
 
                     // SPIGOT-1288 - play sound stripped from ItemBlock
                     if (this.item instanceof BlockItem) {
-                        SoundType soundeffecttype = ((BlockItem) this.item).getBlock().defaultBlockState().getSoundType(); // TODO: not strictly correct, however currently only affects decorated pots
+                        // Paper start - Fix spigot sound playing for BlockItem ItemStacks
+                        BlockPos position = new net.minecraft.world.item.context.BlockPlaceContext(context).getClickedPos();
+                        net.minecraft.world.level.block.state.BlockState blockData = world.getBlockState(position);
+                        SoundType soundeffecttype = blockData.getSoundType();
+                        // Paper end - Fix spigot sound playing for BlockItem ItemStacks
                         world.playSound(entityhuman, blockposition, soundeffecttype.getPlaceSound(), SoundSource.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
                     }