3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00
Dieser Commit ist enthalten in:
DoctorMacc 2020-04-08 15:30:36 -04:00
Ursprung 9e03c9b93a
Commit 7993f38437
2 geänderte Dateien mit 13 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -47,7 +47,14 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
soundPacket.setSound(sound); soundPacket.setSound(sound);
soundPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ())); soundPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
soundPacket.setExtraData(-1); if (sound == SoundEvent.NOTE) {
// Minecraft Wiki: 2^(x/12) = Java pitch where x is -12 to 12
// Java sends the note value as above starting with -12 and ending at 12
// Bedrock has a number for each type of note, then proceeds up the scale by adding to that number
soundPacket.setExtraData(soundMapping.getExtraData() + (int)(Math.round((Math.log10(packet.getPitch()) / Math.log10(2)) * 12)) + 12);
} else {
soundPacket.setExtraData(soundMapping.getExtraData());
}
soundPacket.setIdentifier(":"); // ??? soundPacket.setIdentifier(":"); // ???
soundPacket.setBabySound(false); // might need to adjust this in the future soundPacket.setBabySound(false); // might need to adjust this in the future
soundPacket.setRelativeVolumeDisabled(false); soundPacket.setRelativeVolumeDisabled(false);

Datei anzeigen

@ -43,7 +43,8 @@ public class SoundMap {
new SoundMapping( new SoundMapping(
next.getKey(), next.getKey(),
brMap.has("bedrock_mapping") && brMap.get("bedrock_mapping").isTextual() ? brMap.get("bedrock_mapping").asText() : null, brMap.has("bedrock_mapping") && brMap.get("bedrock_mapping").isTextual() ? brMap.get("bedrock_mapping").asText() : null,
brMap.has("playsound_mapping") && brMap.get("playsound_mapping").isTextual() ? brMap.get("playsound_mapping").asText() : null brMap.has("playsound_mapping") && brMap.get("playsound_mapping").isTextual() ? brMap.get("playsound_mapping").asText() : null,
brMap.has("extra_data") && brMap.get("extra_data").isInt() ? brMap.get("extra_data").asInt() : -1
) )
); );
} }
@ -98,11 +99,13 @@ public class SoundMap {
private final String java; private final String java;
private final String bedrock; private final String bedrock;
private final String playsound; private final String playsound;
private final int extraData;
public SoundMapping(String java, String bedrock, String playsound) { public SoundMapping(String java, String bedrock, String playsound, int extraData) {
this.java = java; this.java = java;
this.bedrock = bedrock == null || bedrock.equalsIgnoreCase("") ? null : bedrock; this.bedrock = bedrock == null || bedrock.equalsIgnoreCase("") ? null : bedrock;
this.playsound = playsound == null || playsound.equalsIgnoreCase("") ? null : playsound; this.playsound = playsound == null || playsound.equalsIgnoreCase("") ? null : playsound;
this.extraData = extraData;
} }
} }