Closed DefinitlyEvil closed 6 years ago
A server written using MCProtocolLib can definitely send chunks. But you will need to implement the protocol correctly http://wiki.vg/Protocol
@0-x-2-2 Yes, I did. I implemented all required procedures and I sent chunks. I used MCProtocolLib to write a debugger client but I found there is no chunk received at all.
Yeah it works fine for me.
@Steveice10 Sorry I was at my phone. Here:
public static void test_chunk() {
try {
Chunk[] chunks = new Chunk[16];
for (int i = 0; i < chunks.length; i++) {
chunks[i] = new Chunk(false);
if (i < 4) {
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
chunks[i].getBlocks().set(x, y, z, new BlockState(1, 0));
}
}
}
}
}
Column col = new Column(8, 8, chunks, null);
ServerChunkDataPacket packet = new ServerChunkDataPacket(col);
MineClashServer.getServer().getOnlinePlayer("_ZexyZek").sendPacket(packet);
} catch (Exception e) {
e.printStackTrace();
MineClashServer.getServer().getLogger().error(e);
}
}
I used this function after this(in login handler, I tried to send all probably-needed packets):
player.sendPacket(new ServerJoinGamePacket(0, false, GameMode.CREATIVE, 0, Difficulty.PEACEFUL, -1, WorldType.DEFAULT, false));
player.sendPacket(new ServerPlayerHealthPacket(20f, 100, 20f));
player.sendPacket(new ServerSpawnPositionPacket(new Position(128, MapRenderer.START_Y + 32, 128)));
player.sendPacket(new ServerPlayerAbilitiesPacket(true, true, true, false, 0.4000000059604645f, 0.699999988079071f));
player.sendPacket(new ServerEntityMetadataPacket(0, EntityMetadataUtil.createDefault()));
ItemStack[] items = new ItemStack[45];
Arrays.fill(items, new ItemStack(1));
player.sendPacket(new ServerWindowItemsPacket(0, items));
player.sendPacket(new ServerPlayerPositionRotationPacket(128d, MapRenderer.START_Y + 32d, 128d, 0f, 0f, 0, null));
The important thing is, it seemed that the server didn't send that packet at all, the client can not receive it at all! It's weird! xD
@Steveice10 Hello, thanks for your quick reply. After few code-inspections, I found that I must pass biome data to Column's constructor or I will cause a hidden NullPointerException with absolutely no error messages.
No, I was totally wrong. There's no problems but it is weird that the packet won't be sent(by networking, does not mean client's reception) unless biome data is set? Sky light doesn't matter at all.
@Steveice10 Yes, but the server doesn't send the packet at all if no biome data present. There won't be packets received by clients, not even read on wire,
Nevermind then... Maybe there's something I couldn't notice. xD Thanks so much for your help!!
Chunk packets are not sending by calling send() on Session objects.