8989import org .cloudburstmc .protocol .bedrock .packet .SubChunkRequestPacket ;
9090import org .cloudburstmc .protocol .bedrock .packet .SubClientLoginPacket ;
9191import org .cloudburstmc .protocol .common .util .VarInts ;
92+ import org .geysermc .geyser .network .netty .IllegalPacketException ;
9293
9394/**
9495 * Processes the Bedrock codec to remove or modify unused or unsafe packets and fields.
@@ -103,12 +104,12 @@ class CodecProcessor {
103104 static final BedrockPacketSerializer ILLEGAL_SERIALIZER = new BedrockPacketSerializer <>() {
104105 @ Override
105106 public void serialize (ByteBuf buffer , BedrockCodecHelper helper , BedrockPacket packet ) {
106- throw new IllegalArgumentException ("Server tried to send unused packet " + packet .getClass ().getSimpleName () + "!" );
107+ throw new IllegalPacketException ("Server tried to send unused packet " + packet .getClass ().getSimpleName () + "!" );
107108 }
108109
109110 @ Override
110111 public void deserialize (ByteBuf buffer , BedrockCodecHelper helper , BedrockPacket packet ) {
111- throw new IllegalArgumentException ("Client tried to send unused packet " + packet .getClass ().getSimpleName () + "!" );
112+ throw new IllegalPacketException ("Client tried to send unused packet " + packet .getClass ().getSimpleName () + "!" );
112113 }
113114 };
114115
@@ -131,14 +132,14 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, BedrockPacket
131132 private static final BedrockPacketSerializer <InventoryContentPacket > INVENTORY_CONTENT_SERIALIZER_V748 = new InventoryContentSerializer_v748 () {
132133 @ Override
133134 public void deserialize (ByteBuf buffer , BedrockCodecHelper helper , InventoryContentPacket packet ) {
134- throw new IllegalArgumentException ("Client cannot send InventoryContentPacket in server-auth inventory environment!" );
135+ throw new IllegalPacketException ("Client cannot send InventoryContentPacket in server-auth inventory environment!" );
135136 }
136137 };
137138
138139 private static final BedrockPacketSerializer <InventoryContentPacket > INVENTORY_CONTENT_SERIALIZER_V1001 = new InventoryContentSerializer_v1001 () {
139140 @ Override
140141 public void deserialize (ByteBuf buffer , BedrockCodecHelper helper , InventoryContentPacket packet ) {
141- throw new IllegalArgumentException ("Client cannot send InventoryContentPacket in server-auth inventory environment!" );
142+ throw new IllegalPacketException ("Client cannot send InventoryContentPacket in server-auth inventory environment!" );
142143 }
143144 };
144145
@@ -148,35 +149,35 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, InventoryCont
148149 private static final BedrockPacketSerializer <InventorySlotPacket > INVENTORY_SLOT_SERIALIZER_V748 = new InventorySlotSerializer_v748 () {
149150 @ Override
150151 public void deserialize (ByteBuf buffer , BedrockCodecHelper helper , InventorySlotPacket packet ) {
151- throw new IllegalArgumentException ("Client cannot send InventorySlotPacket in server-auth inventory environment!" );
152+ throw new IllegalPacketException ("Client cannot send InventorySlotPacket in server-auth inventory environment!" );
152153 }
153154 };
154155
155156 private static final BedrockPacketSerializer <InventorySlotPacket > INVENTORY_SLOT_SERIALIZER_V975 = new InventorySlotSerializer_v975 () {
156157 @ Override
157158 public void deserialize (ByteBuf buffer , BedrockCodecHelper helper , InventorySlotPacket packet ) {
158- throw new IllegalArgumentException ("Client cannot send InventorySlotPacket in server-auth inventory environment!" );
159+ throw new IllegalPacketException ("Client cannot send InventorySlotPacket in server-auth inventory environment!" );
159160 }
160161 };
161162
162163 private static final BedrockPacketSerializer <MovePlayerPacket > MOVE_PLAYER_SERIALIZER = new MovePlayerSerializer_v419 () {
163164 @ Override
164165 public void deserialize (ByteBuf buffer , BedrockCodecHelper helper , MovePlayerPacket packet ) {
165- throw new IllegalArgumentException ("Client cannot send MovePlayerPacket in server-auth movement environment!" );
166+ throw new IllegalPacketException ("Client cannot send MovePlayerPacket in server-auth movement environment!" );
166167 }
167168 };
168169
169170 private static final BedrockPacketSerializer <MoveEntityAbsolutePacket > MOVE_ENTITY_SERIALIZER_V291 = new MoveEntityAbsoluteSerializer_v291 () {
170171 @ Override
171172 public void deserialize (ByteBuf buffer , BedrockCodecHelper helper , MoveEntityAbsolutePacket packet ) {
172- throw new IllegalArgumentException ("Client cannot send MoveEntityAbsolutePacket in server-auth movement environment!" );
173+ throw new IllegalPacketException ("Client cannot send MoveEntityAbsolutePacket in server-auth movement environment!" );
173174 }
174175 };
175176
176177 private static final BedrockPacketSerializer <MoveEntityAbsolutePacket > MOVE_ENTITY_SERIALIZER_V975 = new MoveEntityAbsoluteSerializer_v975 () {
177178 @ Override
178179 public void deserialize (ByteBuf buffer , BedrockCodecHelper helper , MoveEntityAbsolutePacket packet ) {
179- throw new IllegalArgumentException ("Client cannot send MoveEntityAbsolutePacket in server-auth movement environment!" );
180+ throw new IllegalPacketException ("Client cannot send MoveEntityAbsolutePacket in server-auth movement environment!" );
180181 }
181182 };
182183
@@ -396,7 +397,7 @@ private static void fakeItemDescriptorRead(ByteBuf buffer) {
396397 VarInts .readInt (buffer ); // netId
397398 break ;
398399 default :
399- throw new IllegalArgumentException ("Not oneOf<ItemStackNetId, ItemStackRequestId, ItemStackLegacyRequestId>" );
400+ throw new IllegalPacketException ("Not oneOf<ItemStackNetId, ItemStackRequestId, ItemStackLegacyRequestId>" );
400401 }
401402 }
402403 VarInts .readUnsignedInt (buffer ); // block runtime id
0 commit comments