Skip to content

Commit

Permalink
Increase sub chunk request limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Alemiz112 committed Jun 27, 2024
1 parent b82e88b commit 1f3375f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class SubChunkRequestSerializer_v486 extends SubChunkRequestSerializer_v471 {
// A limit of how many sub chunks can client request within a single packet
// It seems that client does not have any cap on how many sub chunks it can request,
// and in some edge cases it requests all sub chunks within the view distance
// The limit set here is based on maximum view distance vanilla client supports (96 chunks)
private static final int MAX_SUB_CHUNKS = (int) (0.785 * 96 * 96 * 24); // circle area * 96 chunks * 24 sub chunks per chunk

public static final SubChunkRequestSerializer_v486 INSTANCE = new SubChunkRequestSerializer_v486();

Expand All @@ -25,7 +30,7 @@ public void serialize(ByteBuf buffer, BedrockCodecHelper helper, SubChunkRequest
public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, SubChunkRequestPacket packet) {
packet.setDimension(VarInts.readInt(buffer));
packet.setSubChunkPosition(helper.readVector3i(buffer));
helper.readArray(buffer, packet.getPositionOffsets(), ByteBuf::readIntLE, this::readSubChunkOffset, 3072); // Somehow client sometimes requests over 1000 sub chunks
helper.readArray(buffer, packet.getPositionOffsets(), ByteBuf::readIntLE, this::readSubChunkOffset, MAX_SUB_CHUNKS);
}

protected void writeSubChunkOffset(ByteBuf buffer, Vector3i offsetPosition) {
Expand Down

0 comments on commit 1f3375f

Please sign in to comment.