mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add precautions to prevent stack traces on incomplete/unknown place sounds (#1717)
This commit is contained in:
parent
f5c0c549ef
commit
dbfdae63f1
3 changed files with 12 additions and 4 deletions
|
@ -34,8 +34,8 @@ import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
|||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
import org.geysermc.connector.network.translators.sound.SoundRegistry;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
|
||||
@Translator(packet = ServerPlayBuiltinSoundPacket.class)
|
||||
public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayBuiltinSoundPacket> {
|
||||
|
@ -82,7 +82,11 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
|
|||
// 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 if (sound == SoundEvent.PLACE && soundMapping.getExtraData() == -1) {
|
||||
soundPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(soundMapping.getIdentifier())));
|
||||
if (!soundMapping.getIdentifier().equals(":")) {
|
||||
soundPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(soundMapping.getIdentifier())));
|
||||
} else {
|
||||
session.getConnector().getLogger().debug("PLACE sound mapping identifier was invalid! Please report: " + packet.toString());
|
||||
}
|
||||
soundPacket.setIdentifier(":");
|
||||
} else {
|
||||
soundPacket.setExtraData(soundMapping.getExtraData());
|
||||
|
|
|
@ -343,8 +343,12 @@ public class BlockTranslator {
|
|||
return BLOCK_STATE_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param javaId the Java string identifier to search for
|
||||
* @return the Java block state integer, or {@link #JAVA_AIR_ID} if there is no valid entry.
|
||||
*/
|
||||
public static int getJavaBlockState(String javaId) {
|
||||
return JAVA_ID_BLOCK_MAP.get(javaId);
|
||||
return JAVA_ID_BLOCK_MAP.getOrDefault(javaId, JAVA_AIR_ID);
|
||||
}
|
||||
|
||||
public static boolean isWaterlogged(int state) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2d14c9dc3d75df7463fc7605a6cff63b5926a03e
|
||||
Subproject commit 3f4707c0d26427dfe2ac79eca68e6048732f4412
|
Loading…
Reference in a new issue