3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-08 10:50:11 +02: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:
Camotoy 2021-05-09 01:19:06 -04:00 committet von GitHub
Ursprung 2aa131f9dc
Commit dda0172ded
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 13 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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.