Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-07 16:50:12 +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.
Dieser Commit ist enthalten in:
Ursprung
2aa131f9dc
Commit
dda0172ded
@ -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.
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren