3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 16:12:46 +01:00

Add precautions to prevent stack traces on incomplete/unknown place sounds (#1717)

Dieser Commit ist enthalten in:
Camotoy 2020-12-20 20:42:14 -05:00 committet von GitHub
Ursprung f5c0c549ef
Commit dbfdae63f1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 12 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -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());

Datei anzeigen

@ -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