Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +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
|
* @return a Bedrock sound
|
||||||
*/
|
*/
|
||||||
public static String translatePlaySound(String javaIdentifier) {
|
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) {
|
if (soundMapping == null || soundMapping.getPlaysound() == null) {
|
||||||
// no mapping
|
// no mapping
|
||||||
GeyserImpl.getInstance().getLogger().debug("[PlaySound] Defaulting to sound server gave us for " + javaIdentifier);
|
GeyserImpl.getInstance().getLogger().debug("[PlaySound] Defaulting to sound server gave us for " + javaIdentifier);
|
||||||
return javaIdentifier;
|
return soundIdentifier;
|
||||||
}
|
}
|
||||||
return soundMapping.getPlaysound();
|
return soundMapping.getPlaysound();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String trim(String identifier) {
|
private static String removeMinecraftNamespace(String identifier) {
|
||||||
// Drop any namespace if applicable
|
// Drop any minecraft namespace if applicable
|
||||||
int i = identifier.indexOf(':');
|
if (identifier.startsWith("minecraft:")) {
|
||||||
if (i >= 0) {
|
return identifier.substring("minecraft:".length());
|
||||||
return identifier.substring(i + 1);
|
|
||||||
}
|
}
|
||||||
return identifier;
|
return identifier;
|
||||||
}
|
}
|
||||||
@ -101,12 +101,12 @@ public final class SoundUtils {
|
|||||||
* @param pitch the pitch
|
* @param pitch the pitch
|
||||||
*/
|
*/
|
||||||
public static void playSound(GeyserSession session, Sound javaSound, Vector3f position, float volume, float 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) {
|
if (soundMapping == null) {
|
||||||
session.getGeyser().getLogger().debug("[Builtin] Sound mapping for " + packetSound + " not found; assuming custom.");
|
session.getGeyser().getLogger().debug("[Builtin] Sound mapping for " + soundIdentifier + " not found; assuming custom.");
|
||||||
playSound(session, packetSound, position, volume, pitch);
|
playSound(session, soundIdentifier, position, volume, pitch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,10 +128,10 @@ public final class SoundUtils {
|
|||||||
LevelSoundEventPacket soundPacket = new LevelSoundEventPacket();
|
LevelSoundEventPacket soundPacket = new LevelSoundEventPacket();
|
||||||
SoundEvent sound = SoundUtils.toSoundEvent(soundMapping.getBedrock());
|
SoundEvent sound = SoundUtils.toSoundEvent(soundMapping.getBedrock());
|
||||||
if (sound == null) {
|
if (sound == null) {
|
||||||
sound = SoundUtils.toSoundEvent(packetSound);
|
sound = SoundUtils.toSoundEvent(soundIdentifier);
|
||||||
}
|
}
|
||||||
if (sound == null) {
|
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.");
|
+ "' was not a playable level sound, or has yet to be mapped to an enum in SoundEvent.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren