stash 1
This commit is contained in:
@@ -87,6 +87,7 @@ public enum State {
|
|||||||
.put(PluginMessagePacket.class, 0x18)
|
.put(PluginMessagePacket.class, 0x18)
|
||||||
.put(ChangeGameState.class, 0x1E)
|
.put(ChangeGameState.class, 0x1E)
|
||||||
.put(KeepAlivePacket.class, 0x1F)
|
.put(KeepAlivePacket.class, 0x1F)
|
||||||
|
.put(ChunkDataPacket.class, 0x20)
|
||||||
.put(JoinGamePacket.class, 0x23)
|
.put(JoinGamePacket.class, 0x23)
|
||||||
.put(PlayerAbilitiesPacket.class, 0x2C)
|
.put(PlayerAbilitiesPacket.class, 0x2C)
|
||||||
.put(PlayerListItemPacket.class, 0x2E)
|
.put(PlayerListItemPacket.class, 0x2E)
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <dimon550@gmail.com>
|
||||||
|
* 2018-07-21
|
||||||
|
*/
|
||||||
|
package mc.core.network.proto_1_12_2.packets;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import mc.core.network.NetOutputStream;
|
||||||
|
import mc.core.network.SCPacket;
|
||||||
|
import mc.core.world.Chunk;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ChunkDataPacket implements SCPacket {
|
||||||
|
@Setter
|
||||||
|
private int x;
|
||||||
|
@Setter
|
||||||
|
private int z;
|
||||||
|
@Setter
|
||||||
|
private boolean initChunk = true; // "Ground-Up Continuous"
|
||||||
|
@Getter
|
||||||
|
private List<Chunk> chunks = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeSelf(NetOutputStream netStream) {
|
||||||
|
netStream.writeInt(x);
|
||||||
|
netStream.writeInt(z);
|
||||||
|
netStream.writeBoolean(initChunk);
|
||||||
|
netStream.writeVarInt(0b11111111); // Primary Bit Mask
|
||||||
|
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
try {
|
||||||
|
for (Chunk chunk : chunks) {
|
||||||
|
netStream.writeByte(4); // Bits Per Block
|
||||||
|
// <Palette />
|
||||||
|
// <Data Array Length />
|
||||||
|
// <Data Array />
|
||||||
|
// <Block Light />
|
||||||
|
// <Sky Light />
|
||||||
|
// baos.write(ChunkSerializer.serializeBiomes(chunk));
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Error serialize chunk", e); // what? is it possible??
|
||||||
|
}
|
||||||
|
netStream.writeVarInt(baos.size()); // Size of Data in bytes
|
||||||
|
netStream.writeBytes(baos.toByteArray()); // Data chunks
|
||||||
|
netStream.writeVarInt(0); // size NBT
|
||||||
|
/* writeNBT */
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -80,6 +80,14 @@ public class LoginHandler extends AbstractStateHandler implements LoginStateHand
|
|||||||
channel.write(pkt3);
|
channel.write(pkt3);
|
||||||
channel.flush();
|
channel.flush();
|
||||||
|
|
||||||
|
// Send chunk data
|
||||||
|
ChunkDataPacket pkt8 = new ChunkDataPacket();
|
||||||
|
pkt8.setX(0);
|
||||||
|
pkt8.setZ(0);
|
||||||
|
pkt8.getChunks().add(world.getChunk(0,0));
|
||||||
|
pkt8.setInitChunk(true);
|
||||||
|
channel.writeAndFlush(pkt8);
|
||||||
|
|
||||||
// Player Position And Look
|
// Player Position And Look
|
||||||
PlayerPositionAndLookPacket pkt4 = new PlayerPositionAndLookPacket();
|
PlayerPositionAndLookPacket pkt4 = new PlayerPositionAndLookPacket();
|
||||||
pkt4.setLocation(player.getLocation());
|
pkt4.setLocation(player.getLocation());
|
||||||
|
|||||||
Reference in New Issue
Block a user