This commit is contained in:
Camotoy 2023-04-27 13:09:38 -04:00
parent 97e91ef962
commit 1f18e4fe4f
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
2 changed files with 27 additions and 15 deletions

View file

@ -56,7 +56,10 @@ public class JavaLevelEventTranslator extends PacketTranslator<ClientboundLevelE
// Separate case since each RecordEventData in Java is an individual track in Bedrock // Separate case since each RecordEventData in Java is an individual track in Bedrock
if (packet.getEvent() == LevelEvent.RECORD) { if (packet.getEvent() == LevelEvent.RECORD) {
RecordEventData recordEventData = (RecordEventData) packet.getData(); RecordEventData recordEventData = (RecordEventData) packet.getData();
SoundEvent soundEvent = Registries.RECORDS.getOrDefault(recordEventData.getRecordId(), SoundEvent.STOP_RECORD); SoundEvent soundEvent = Registries.RECORDS.get(recordEventData.getRecordId());
if (soundEvent == null) {
return;
}
Vector3i origin = packet.getPosition(); Vector3i origin = packet.getPosition();
Vector3f pos = Vector3f.from(origin.getX() + 0.5f, origin.getY() + 0.5f, origin.getZ() + 0.5f); Vector3f pos = Vector3f.from(origin.getX() + 0.5f, origin.getY() + 0.5f, origin.getZ() + 0.5f);
@ -69,7 +72,6 @@ public class JavaLevelEventTranslator extends PacketTranslator<ClientboundLevelE
levelSoundEvent.setBabySound(false); levelSoundEvent.setBabySound(false);
session.sendUpstreamPacket(levelSoundEvent); session.sendUpstreamPacket(levelSoundEvent);
if (soundEvent != SoundEvent.STOP_RECORD) {
// Send text packet as it seems to be handled in Java Edition client-side. // Send text packet as it seems to be handled in Java Edition client-side.
TextPacket textPacket = new TextPacket(); TextPacket textPacket = new TextPacket();
textPacket.setType(TextPacket.Type.JUKEBOX_POPUP); textPacket.setType(TextPacket.Type.JUKEBOX_POPUP);
@ -81,7 +83,6 @@ public class JavaLevelEventTranslator extends PacketTranslator<ClientboundLevelE
String recordString = "%item." + soundEvent.name().toLowerCase(Locale.ROOT) + ".desc"; String recordString = "%item." + soundEvent.name().toLowerCase(Locale.ROOT) + ".desc";
textPacket.setParameters(Collections.singletonList(MinecraftLocale.getLocaleString(recordString, session.locale()))); textPacket.setParameters(Collections.singletonList(MinecraftLocale.getLocaleString(recordString, session.locale())));
session.sendUpstreamPacket(textPacket); session.sendUpstreamPacket(textPacket);
}
return; return;
} }
@ -310,6 +311,17 @@ public class JavaLevelEventTranslator extends PacketTranslator<ClientboundLevelE
session.sendUpstreamPacket(soundEventPacket); session.sendUpstreamPacket(soundEventPacket);
return; return;
} }
case STOP_RECORD -> {
LevelSoundEventPacket levelSoundEvent = new LevelSoundEventPacket();
levelSoundEvent.setIdentifier("");
levelSoundEvent.setSound(SoundEvent.STOP_RECORD);
levelSoundEvent.setPosition(pos);
levelSoundEvent.setRelativeVolumeDisabled(false);
levelSoundEvent.setExtraData(-1);
levelSoundEvent.setBabySound(false);
session.sendUpstreamPacket(levelSoundEvent);
return;
}
default -> { default -> {
GeyserImpl.getInstance().getLogger().debug("Unhandled level event: " + packet.getEvent()); GeyserImpl.getInstance().getLogger().debug("Unhandled level event: " + packet.getEvent());
return; return;

View file

@ -13,7 +13,7 @@ protocol = "3.0.0.Beta1-20230424.095344-69"
protocol-connection = "3.0.0.Beta1-20230424.095344-68" protocol-connection = "3.0.0.Beta1-20230424.095344-68"
raknet = "1.0.0.CR1-20230311.162635-3" raknet = "1.0.0.CR1-20230311.162635-3"
mcauthlib = "d9d773e" mcauthlib = "d9d773e"
mcprotocollib = "1.19.4-2-20230426.171506-1" mcprotocollib = "1.19.4-2-20230427.170624-2"
adventure = "4.14.0-20230424.215040-7" adventure = "4.14.0-20230424.215040-7"
adventure-platform = "4.1.2" adventure-platform = "4.1.2"
junit = "5.9.2" junit = "5.9.2"