Entity Status Packet
This commit is contained in:
parent
84bbe26454
commit
3123dac2c2
3 changed files with 59 additions and 2 deletions
|
@ -22,6 +22,7 @@ export enum Packet {
|
|||
EntityAction = 0x13,
|
||||
NamedEntitySpawn = 0x14,
|
||||
|
||||
EntityStatus = 0x26,
|
||||
EntityMetadata = 0x28,
|
||||
|
||||
PreChunk = 0x32,
|
||||
|
|
30
server/packets/EntityStatus.ts
Normal file
30
server/packets/EntityStatus.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { createWriter, IReader, Endian } from "bufferstuff";
|
||||
import { IPacket } from "./IPacket";
|
||||
import { Packet } from "../enums/Packet";
|
||||
|
||||
export class PacketEntityStatus implements IPacket {
|
||||
public packetId = Packet.EntityStatus;
|
||||
public entityId:number;
|
||||
public status:number;
|
||||
|
||||
public constructor(entityId?:number, status?:number) {
|
||||
if (typeof(entityId) == "number" && typeof(status) === "number") {
|
||||
this.entityId = entityId;
|
||||
this.status = status;
|
||||
} else {
|
||||
this.entityId = Number.MIN_VALUE;
|
||||
this.status = Number.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
public readData(reader:IReader) {
|
||||
this.entityId = reader.readInt();
|
||||
this.status = reader.readByte();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public writeData() {
|
||||
return createWriter(Endian.BE, 6).writeUByte(this.packetId).writeInt(this.entityId).writeByte(this.status).toBuffer();
|
||||
}
|
||||
}
|
|
@ -39,14 +39,40 @@ export class PacketMapChunk implements IPacket {
|
|||
fakeLighting.writeUByte(0xFF);
|
||||
}*/
|
||||
|
||||
const data = createWriter(Endian.BE).writeBuffer(this.chunk.getBlockBuffer()).writeBuffer(this.chunk.getMetadataBuffer()).writeBuffer(this.chunk.blockLight.toBuffer()).writeBuffer(this.chunk.skyLight.toBuffer());//.writeBuffer(fakeLighting.toBuffer()).writeBuffer(fakeLighting.toBuffer());
|
||||
const data = createWriter(Endian.BE)
|
||||
// Write Chunk Blocks
|
||||
.writeBuffer(this.chunk.getBlockBuffer())
|
||||
// Write Chunk Blocks Metadata
|
||||
.writeBuffer(this.chunk.getMetadataBuffer())
|
||||
// Write Chunk Block Light
|
||||
.writeBuffer(this.chunk.blockLight.toBuffer())
|
||||
// Write Chunk Sky Light
|
||||
.writeBuffer(this.chunk.skyLight.toBuffer());
|
||||
|
||||
deflate(data.toBuffer(), (err, data) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
resolve(createWriter(Endian.BE, 18).writeUByte(this.packetId).writeInt(this.x << 4).writeShort(this.y).writeInt(this.z << 4).writeUByte(this.sizeX).writeUByte(this.sizeY).writeUByte(this.sizeZ).writeInt(data.length).writeBuffer(data).toBuffer());
|
||||
resolve(createWriter(Endian.BE, 18)
|
||||
// Write PacketID
|
||||
.writeUByte(this.packetId)
|
||||
// Write Chunk X
|
||||
.writeInt(this.x << 4)
|
||||
// Write Chunk Y
|
||||
.writeShort(this.y)
|
||||
// Write Chunk Z
|
||||
.writeInt(this.z << 4)
|
||||
// Write Chunk Size X
|
||||
.writeUByte(this.sizeX)
|
||||
// Write Chunk Size Y
|
||||
.writeUByte(this.sizeY)
|
||||
// Write Chunk Size Z
|
||||
.writeUByte(this.sizeZ)
|
||||
// Write Compressed Chunk Data Length
|
||||
.writeInt(data.length)
|
||||
// Write Compressed Chunk Data
|
||||
.writeBuffer(data).toBuffer());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue