Prepare for PR

This commit is contained in:
DoctorMacc 2020-04-08 15:30:36 -04:00
parent 9e03c9b93a
commit 7993f38437
2 changed files with 13 additions and 3 deletions

View file

@ -47,7 +47,14 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
soundPacket.setSound(sound);
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.setBabySound(false); // might need to adjust this in the future
soundPacket.setRelativeVolumeDisabled(false);

View file

@ -43,7 +43,8 @@ public class SoundMap {
new SoundMapping(
next.getKey(),
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 bedrock;
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.bedrock = bedrock == null || bedrock.equalsIgnoreCase("") ? null : bedrock;
this.playsound = playsound == null || playsound.equalsIgnoreCase("") ? null : playsound;
this.extraData = extraData;
}
}