Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +01:00
Fix /playsound command by stripping only the Minecraft namespace (#3956)
Fixes https://github.com/GeyserMC/Geyser/issues/3953
Dieser Commit ist enthalten in:
Ursprung
966270d3c8
Commit
b17191b553
@ -65,20 +65,20 @@ public final class SoundUtils {
|
||||
* @return a Bedrock sound
|
||||
*/
|
||||
public static String translatePlaySound(String javaIdentifier) {
|
||||
SoundMapping soundMapping = Registries.SOUNDS.get(trim(javaIdentifier));
|
||||
String soundIdentifier = removeMinecraftNamespace(javaIdentifier);
|
||||
SoundMapping soundMapping = Registries.SOUNDS.get(soundIdentifier);
|
||||
if (soundMapping == null || soundMapping.getPlaysound() == null) {
|
||||
// no mapping
|
||||
GeyserImpl.getInstance().getLogger().debug("[PlaySound] Defaulting to sound server gave us for " + javaIdentifier);
|
||||
return javaIdentifier;
|
||||
return soundIdentifier;
|
||||
}
|
||||
return soundMapping.getPlaysound();
|
||||
}
|
||||
|
||||
private static String trim(String identifier) {
|
||||
// Drop any namespace if applicable
|
||||
int i = identifier.indexOf(':');
|
||||
if (i >= 0) {
|
||||
return identifier.substring(i + 1);
|
||||
private static String removeMinecraftNamespace(String identifier) {
|
||||
// Drop any minecraft namespace if applicable
|
||||
if (identifier.startsWith("minecraft:")) {
|
||||
return identifier.substring("minecraft:".length());
|
||||
}
|
||||
return identifier;
|
||||
}
|
||||
@ -101,12 +101,12 @@ public final class SoundUtils {
|
||||
* @param pitch the pitch
|
||||
*/
|
||||
public static void playSound(GeyserSession session, Sound javaSound, Vector3f position, float volume, float pitch) {
|
||||
String packetSound = javaSound.getName();
|
||||
String soundIdentifier = removeMinecraftNamespace(javaSound.getName());
|
||||
|
||||
SoundMapping soundMapping = Registries.SOUNDS.get(packetSound);
|
||||
SoundMapping soundMapping = Registries.SOUNDS.get(soundIdentifier);
|
||||
if (soundMapping == null) {
|
||||
session.getGeyser().getLogger().debug("[Builtin] Sound mapping for " + packetSound + " not found; assuming custom.");
|
||||
playSound(session, packetSound, position, volume, pitch);
|
||||
session.getGeyser().getLogger().debug("[Builtin] Sound mapping for " + soundIdentifier + " not found; assuming custom.");
|
||||
playSound(session, soundIdentifier, position, volume, pitch);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -128,10 +128,10 @@ public final class SoundUtils {
|
||||
LevelSoundEventPacket soundPacket = new LevelSoundEventPacket();
|
||||
SoundEvent sound = SoundUtils.toSoundEvent(soundMapping.getBedrock());
|
||||
if (sound == null) {
|
||||
sound = SoundUtils.toSoundEvent(packetSound);
|
||||
sound = SoundUtils.toSoundEvent(soundIdentifier);
|
||||
}
|
||||
if (sound == null) {
|
||||
session.getGeyser().getLogger().debug("[Builtin] Sound for original '" + packetSound + "' to mappings '" + soundMapping.getBedrock()
|
||||
session.getGeyser().getLogger().debug("[Builtin] Sound for original '" + soundIdentifier + "' to mappings '" + soundMapping.getBedrock()
|
||||
+ "' was not a playable level sound, or has yet to be mapped to an enum in SoundEvent.");
|
||||
return;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren