diff --git a/src/main/java/net/raphimc/viabedrock/protocol/BedrockProtocol.java b/src/main/java/net/raphimc/viabedrock/protocol/BedrockProtocol.java index 13804f36..6bc2d43c 100644 --- a/src/main/java/net/raphimc/viabedrock/protocol/BedrockProtocol.java +++ b/src/main/java/net/raphimc/viabedrock/protocol/BedrockProtocol.java @@ -100,9 +100,9 @@ protected void registerPackets() { EntityPackets.register(this); HudPackets.register(this); InventoryPackets.register(this); + UnhandledPackets.register(this); // Fallback for unhandled packets (Temporary) - for (ClientboundBedrockPackets packet : this.unmappedClientboundPacketType.getEnumConstants()) { if (!this.hasRegisteredClientbound(packet)) { this.cancelClientbound(packet); diff --git a/src/main/java/net/raphimc/viabedrock/protocol/packet/ClientPlayerPackets.java b/src/main/java/net/raphimc/viabedrock/protocol/packet/ClientPlayerPackets.java index e8461d34..e58555fa 100644 --- a/src/main/java/net/raphimc/viabedrock/protocol/packet/ClientPlayerPackets.java +++ b/src/main/java/net/raphimc/viabedrock/protocol/packet/ClientPlayerPackets.java @@ -205,7 +205,6 @@ protected void register() { wrapper.read(Types.BOOLEAN); // show name tags wrapper.read(Types.BOOLEAN); // auto jump }); - protocol.cancelClientbound(ClientboundBedrockPackets.SET_HEALTH); // Seems to do nothing meaningful protocol.registerServerbound(ServerboundPackets1_20_5.CLIENT_COMMAND, ServerboundBedrockPackets.RESPAWN, wrapper -> { final ClientPlayerEntity clientPlayer = wrapper.user().get(EntityTracker.class).getClientPlayer(); diff --git a/src/main/java/net/raphimc/viabedrock/protocol/packet/UnhandledPackets.java b/src/main/java/net/raphimc/viabedrock/protocol/packet/UnhandledPackets.java new file mode 100644 index 00000000..4ccc2132 --- /dev/null +++ b/src/main/java/net/raphimc/viabedrock/protocol/packet/UnhandledPackets.java @@ -0,0 +1,52 @@ +/* + * This file is part of ViaBedrock - https://github.com/RaphiMC/ViaBedrock + * Copyright (C) 2023-2024 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package net.raphimc.viabedrock.protocol.packet; + +import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5; +import net.raphimc.viabedrock.protocol.BedrockProtocol; +import net.raphimc.viabedrock.protocol.ClientboundBedrockPackets; + +public class UnhandledPackets { + + public static void register(final BedrockProtocol protocol) { + protocol.cancelClientbound(ClientboundBedrockPackets.SET_HEALTH); // Seems to do nothing meaningful + protocol.cancelClientbound(ClientboundBedrockPackets.CAMERA); // Not relevant (Education Edition) + protocol.cancelClientbound(ClientboundBedrockPackets.PHOTO_TRANSFER); // Not relevant (Education Edition) + protocol.cancelClientbound(ClientboundBedrockPackets.SHOW_PROFILE); + protocol.cancelClientbound(ClientboundBedrockPackets.LAB_TABLE); // Not relevant (Education Edition) + protocol.cancelClientbound(ClientboundBedrockPackets.EDUCATION_SETTINGS); // Not relevant (Education Edition) + protocol.cancelClientbound(ClientboundBedrockPackets.EMOTE); // Not possible in Java Edition + protocol.cancelClientbound(ClientboundBedrockPackets.CODE_BUILDER); // Not relevant (Education Edition) + protocol.cancelClientbound(ClientboundBedrockPackets.EMOTE_LIST); // Not possible in Java Edition + protocol.cancelClientbound(ClientboundBedrockPackets.CAMERA_SHAKE); // Not possible in Java Edition + protocol.cancelClientbound(ClientboundBedrockPackets.PLAYER_FOG); // Not possible in Java Edition + protocol.cancelClientbound(ClientboundBedrockPackets.EDU_URI_RESOURCE); // Not relevant (Education Edition) + protocol.cancelClientbound(ClientboundBedrockPackets.SCRIPT_MESSAGE); // Not relevant (Education Edition) + protocol.cancelClientbound(ClientboundBedrockPackets.LESSON_PROGRESS); // Not relevant (Education Edition) + protocol.cancelClientbound(ClientboundBedrockPackets.CAMERA_PRESETS); // Not possible in Java Edition + protocol.cancelClientbound(ClientboundBedrockPackets.CAMERA_INSTRUCTION); // Not possible in Java Edition + protocol.cancelClientbound(ClientboundBedrockPackets.SET_HUD); // Not possible in Java Edition + + protocol.cancelServerbound(ServerboundPackets1_20_5.CHAT_ACK); + protocol.cancelServerbound(ServerboundPackets1_20_5.CHAT_SESSION_UPDATE); + protocol.cancelServerbound(ServerboundPackets1_20_5.CHUNK_BATCH_RECEIVED); + protocol.cancelServerbound(ServerboundPackets1_20_5.COOKIE_RESPONSE); + protocol.cancelServerbound(ServerboundPackets1_20_5.DEBUG_SAMPLE_SUBSCRIPTION); + } + +}