3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 00:23:03 +01:00

Fix stopsound bug (#1771)

* Fix stopsound not working bug

* removed extra imports

* Update JavaPlayerStopSoundTranslator.java

* Update JavaPlayerStopSoundTranslator.java

* Update JavaPlayerStopSoundTranslator.java

* Fix packet names and fix specific sounds not stopping

Co-authored-by: YHDiamond <47502993+yehudahrrs@users.noreply.github.com>
Co-authored-by: Camotoy <20743703+Camotoy@users.noreply.github.com>
Dieser Commit ist enthalten in:
YHDiamond 2021-01-02 18:51:41 -05:00 committet von GitHub
Ursprung 396d1b6b61
Commit 1a08e1104d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 18 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -36,7 +36,7 @@ import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.sound.SoundRegistry; import org.geysermc.connector.network.translators.sound.SoundRegistry;
@Translator(packet = ServerPlaySoundPacket.class) @Translator(packet = ServerPlaySoundPacket.class)
public class JavaPlayerPlaySoundTranslator extends PacketTranslator<ServerPlaySoundPacket> { public class JavaPlaySoundTranslator extends PacketTranslator<ServerPlaySoundPacket> {
@Override @Override
public void translate(ServerPlaySoundPacket packet, GeyserSession session) { public void translate(ServerPlaySoundPacket packet, GeyserSession session) {

Datei anzeigen

@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.connector.network.translators.java.entity.player; package org.geysermc.connector.network.translators.java.world;
import com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound; import com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound;
import com.github.steveice10.mc.protocol.data.game.world.sound.CustomSound; import com.github.steveice10.mc.protocol.data.game.world.sound.CustomSound;
@ -35,10 +35,19 @@ import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.sound.SoundRegistry; import org.geysermc.connector.network.translators.sound.SoundRegistry;
@Translator(packet = ServerStopSoundPacket.class) @Translator(packet = ServerStopSoundPacket.class)
public class JavaPlayerStopSoundTranslator extends PacketTranslator<ServerStopSoundPacket> { public class JavaStopSoundTranslator extends PacketTranslator<ServerStopSoundPacket> {
@Override @Override
public void translate(ServerStopSoundPacket packet, GeyserSession session) { public void translate(ServerStopSoundPacket packet, GeyserSession session) {
// Runs if all sounds are stopped
if (packet.getSound() == null) {
StopSoundPacket stopPacket = new StopSoundPacket();
stopPacket.setStoppingAllSound(true);
stopPacket.setSoundName("");
session.sendUpstreamPacket(stopPacket);
return;
}
String packetSound; String packetSound;
if (packet.getSound() instanceof BuiltinSound) { if (packet.getSound() instanceof BuiltinSound) {
packetSound = ((BuiltinSound) packet.getSound()).getName(); packetSound = ((BuiltinSound) packet.getSound()).getName();
@ -48,7 +57,7 @@ public class JavaPlayerStopSoundTranslator extends PacketTranslator<ServerStopSo
session.getConnector().getLogger().debug("Unknown sound packet, we were unable to map this. " + packet.toString()); session.getConnector().getLogger().debug("Unknown sound packet, we were unable to map this. " + packet.toString());
return; return;
} }
SoundRegistry.SoundMapping soundMapping = SoundRegistry.fromJava(packetSound); SoundRegistry.SoundMapping soundMapping = SoundRegistry.fromJava(packetSound.replace("minecraft:", ""));
session.getConnector().getLogger() session.getConnector().getLogger()
.debug("[StopSound] Sound mapping " + packetSound + " -> " .debug("[StopSound] Sound mapping " + packetSound + " -> "
+ soundMapping + (soundMapping == null ? "[not found]" : "") + soundMapping + (soundMapping == null ? "[not found]" : "")