Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrease cpu load to 30%. #60

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public void translate(ServerChunkDataPacket packet, GeyserSession session) {
levelChunkPacket.setChunkX(packet.getColumn().getX());
levelChunkPacket.setChunkZ(packet.getColumn().getZ());
levelChunkPacket.setData(payload);
session.getUpstream().sendPacket(levelChunkPacket);
try {
session.getUpstream().sendPacket(levelChunkPacket);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how the connection being closed should be handled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then how should it

} catch (Exception e) {
//Usually a connection has been closed.
}
session.getChunkCache().addToCache(packet.getColumn());
} catch (Exception ex) {
ex.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,41 @@ public static ChunkData translateToBedrock(Column column) {
chunkData.sections[i] = new ChunkSection();
}

for (int chunkY = 0; chunkY < chunkSectionCount; chunkY++) {
Chunk chunk = chunks[chunkY];
try {
for (int chunkY = 0; chunkY < chunkSectionCount; chunkY++) {
Chunk chunk = chunks[chunkY];

if (chunk == null || chunk.isEmpty())
continue;
if (chunk == null || chunk.isEmpty())
continue;

BlockStorage storage = chunk.getBlocks();
ChunkSection section = chunkData.sections[chunkY];
BlockStorage storage = chunk.getBlocks();
ChunkSection section = chunkData.sections[chunkY];

for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
BlockState blockState = storage.get(x, y, z);
BlockEntry block = TranslatorsInit.getBlockTranslator().getBedrockBlock(blockState);
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
BlockState blockState = storage.get(x, y, z);
BlockEntry block = TranslatorsInit.getBlockTranslator().getBedrockBlock(blockState);

section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z),
block.getBedrockId() << 4 | block.getBedrockData());
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z),
block.getBedrockId() << 4 | block.getBedrockData());

if (block.getJavaIdentifier().contains("waterlogged=true")) {
section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z),
9 << 4); // water id
if (block.getJavaIdentifier().contains("waterlogged=true")) {
section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z),
9 << 4); // water id
}
}

Thread.sleep(0, 3000);
}

Thread.sleep(0, 15000);
}

Thread.sleep(0, 30000);
}
} catch (InterruptedException e) {
//Shouldn't happen
}
return chunkData;
}
Expand Down