From 91bc2da8ce61fd577a9b14c853c369b258855e85 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Mon, 10 Jun 2024 17:54:41 +0800 Subject: [PATCH] feat: forward LevelSoundEvent2Packet --- .../processor/AllayPacketProcessorHolder.java | 1 + .../LevelSoundEvent2PacketProcessor.java | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Allay-Server/src/main/java/org/allaymc/server/network/processor/LevelSoundEvent2PacketProcessor.java diff --git a/Allay-Server/src/main/java/org/allaymc/server/network/processor/AllayPacketProcessorHolder.java b/Allay-Server/src/main/java/org/allaymc/server/network/processor/AllayPacketProcessorHolder.java index 83dfcbd53..08d2f1210 100644 --- a/Allay-Server/src/main/java/org/allaymc/server/network/processor/AllayPacketProcessorHolder.java +++ b/Allay-Server/src/main/java/org/allaymc/server/network/processor/AllayPacketProcessorHolder.java @@ -51,6 +51,7 @@ protected void registerDefaultPacketProcessors(AllayPacketProcessorHolder holder holder.registerProcessor(new ModalFormResponsePacketProcessor()); holder.registerProcessor(new ServerSettingsRequestProcessor()); holder.registerProcessor(new PlayerSkinPacketProcessor()); + holder.registerProcessor(new LevelSoundEvent2PacketProcessor()); } public PacketProcessor getProcessor(BedrockPacket packet) { diff --git a/Allay-Server/src/main/java/org/allaymc/server/network/processor/LevelSoundEvent2PacketProcessor.java b/Allay-Server/src/main/java/org/allaymc/server/network/processor/LevelSoundEvent2PacketProcessor.java new file mode 100644 index 000000000..e54040450 --- /dev/null +++ b/Allay-Server/src/main/java/org/allaymc/server/network/processor/LevelSoundEvent2PacketProcessor.java @@ -0,0 +1,28 @@ +package org.allaymc.server.network.processor; + +import org.allaymc.api.entity.interfaces.EntityPlayer; +import org.allaymc.api.network.processor.PacketProcessor; +import org.cloudburstmc.protocol.bedrock.data.GameType; +import org.cloudburstmc.protocol.bedrock.packet.BedrockPacketType; +import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEvent2Packet; +import org.cloudburstmc.protocol.common.PacketSignal; + +/** + * Allay Project 2024/6/10 + * + * @author daoge_cmd + */ +public class LevelSoundEvent2PacketProcessor extends PacketProcessor { + @Override + public BedrockPacketType getPacketType() { + return BedrockPacketType.LEVEL_SOUND_EVENT_2; + } + + @Override + public PacketSignal handleAsync(EntityPlayer player, LevelSoundEvent2Packet packet) { + if (player.getGameType() != GameType.SPECTATOR) { + player.getCurrentChunk().addChunkPacket(packet); + } + return PacketSignal.HANDLED; + } +}