Skip to content

Commit

Permalink
Use sub chunk request system
Browse files Browse the repository at this point in the history
  • Loading branch information
valaphee committed Dec 16, 2022
1 parent c721883 commit d70ec58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -870,4 +870,9 @@ public boolean handle(RequestAbilityPacket packet) {
public boolean handle(RequestNetworkSettingsPacket packet) {
return defaultHandler(packet);
}

@Override
public boolean handle(SubChunkRequestPacket packet) {
return defaultHandler(packet);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void translate(GeyserSession session, SubChunkRequestPacket packet) {
int bedrockSubChunkMinY = bedrockDimension.minY() >> 4;
int bedrockSubChunkMaxY = bedrockSubChunkMinY + (bedrockDimension.height() >> 4);

ByteBuf byteBuf = null, blobByteBuf = null;
ByteBuf byteBuf = null;

try {
for (Vector3i positionOffset : packet.getPositionOffsets()) {
Expand Down Expand Up @@ -255,22 +255,11 @@ public void translate(GeyserSession session, SubChunkRequestPacket packet) {

if (byteBuf == null) {
byteBuf = ByteBufAllocator.DEFAULT.buffer(section.estimateNetworkSize() + bedrockBlockEntities.size() * 64);
if (!subChunkPacket.isCacheEnabled()) {
blobByteBuf = byteBuf;
}
} else {
byteBuf.clear();
}

if (subChunkPacket.isCacheEnabled()) {
if (blobByteBuf != null) {
blobByteBuf.clear();
} else {
blobByteBuf = ByteBufAllocator.DEFAULT.buffer(section.estimateNetworkSize());
}
}

section.writeToNetwork(blobByteBuf);
section.writeToNetwork(byteBuf);
NBTOutputStream nbtStream = NbtUtils.createNetworkWriter(new ByteBufOutputStream(byteBuf));
for (NbtMap blockEntity : bedrockBlockEntities) {
nbtStream.writeTag(blockEntity);
Expand All @@ -288,9 +277,6 @@ public void translate(GeyserSession session, SubChunkRequestPacket packet) {
if (byteBuf != null) {
byteBuf.release();
}
if (subChunkPacket.isCacheEnabled() && blobByteBuf != null) {
blobByteBuf.release();
}
}
}
}

0 comments on commit d70ec58

Please sign in to comment.