mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-01-02 17:31:50 +01:00
Allow more blocks to have a place sound on standalone (#2183)
Items such as wall torch blocks currently do not have a place sound on standalone, as their block identifier differs from their item identifier. This commit uses the pick item logic in order to fix place sounds for such blocks.
This commit is contained in:
parent
2aa131f9dc
commit
dda0172ded
2 changed files with 13 additions and 1 deletions
|
@ -68,7 +68,7 @@ public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChang
|
|||
// We need to check if the identifier is the same, else a packet with the sound of what the
|
||||
// player has in their hand is played, despite if the block is being placed or not
|
||||
boolean contains = false;
|
||||
String identifier = BlockTranslator.getJavaIdBlockMap().inverse().get(packet.getRecord().getBlock()).split("\\[")[0];
|
||||
String identifier = BlockTranslator.getBlockMapping(packet.getRecord().getBlock()).getItemIdentifier();
|
||||
if (identifier.equals(session.getLastBlockPlacedId())) {
|
||||
contains = true;
|
||||
}
|
||||
|
|
|
@ -59,6 +59,18 @@ public class BlockMapping {
|
|||
return javaIdentifier.split("\\[")[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the corresponding Java identifier for this item
|
||||
*/
|
||||
public String getItemIdentifier() {
|
||||
if (pickItem != null && !pickItem.equals("minecraft:air")) {
|
||||
// Spawners can have air as their pick item which we are not interested in.
|
||||
return pickItem;
|
||||
}
|
||||
|
||||
return getCleanJavaIdentifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item a Java client would receive when pressing
|
||||
* the Pick Block key on a specific Java block state.
|
||||
|
|
Loading…
Reference in a new issue