Revert non-full chunk fix

This fix causes far too much lag on big non-full chunk updates
This commit is contained in:
AJ Ferguson 2020-03-05 10:45:50 -09:00
parent 3863cdb58f
commit 223e94a31d

View file

@ -25,10 +25,7 @@
package org.geysermc.connector.network.translators.java.world; package org.geysermc.connector.network.translators.java.world;
import com.github.steveice10.mc.protocol.data.game.chunk.Chunk;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket;
import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.network.VarInts; import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
@ -49,7 +46,6 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
// Not sure if this is safe or not, however without this the client usually times out // Not sure if this is safe or not, however without this the client usually times out
GeyserConnector.getInstance().getGeneralThreadPool().execute(() -> { GeyserConnector.getInstance().getGeneralThreadPool().execute(() -> {
try { try {
if (packet.getColumn().getBiomeData() != null) { //Full chunk
ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(packet.getColumn()); ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(packet.getColumn());
ByteBuf byteBuf = Unpooled.buffer(32); ByteBuf byteBuf = Unpooled.buffer(32);
ChunkSection[] sections = chunkData.sections; ChunkSection[] sections = chunkData.sections;
@ -81,28 +77,6 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
levelChunkPacket.setChunkZ(packet.getColumn().getZ()); levelChunkPacket.setChunkZ(packet.getColumn().getZ());
levelChunkPacket.setData(payload); levelChunkPacket.setData(payload);
session.getUpstream().sendPacket(levelChunkPacket); session.getUpstream().sendPacket(levelChunkPacket);
} else {
final int xOffset = packet.getColumn().getX() << 4;
final int zOffset = packet.getColumn().getZ() << 4;
Chunk[] chunks = packet.getColumn().getChunks();
for (int i = 0; i < chunks.length; i++) {
Chunk chunk = chunks[i];
if (chunk == null) continue;
final int yOffset = i * 16;
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
BlockState blockState = chunk.get(x, y, z);
Vector3i pos = Vector3i.from(
x + xOffset,
y + yOffset,
z + zOffset);
ChunkUtils.updateBlock(session, blockState, pos);
}
}
}
}
}
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }