mc-beta-server/server/Packets/Packet20NamedEntitySpawn.js

41 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2021-08-24 15:29:46 +01:00
/*
=====- Packet20NamedEntitySpawn.js -====
Created by Holly (tgpethan) (c) 2021
Licenced under MIT
========================================
*/
2021-08-20 22:42:00 +01:00
const Packet = require("./Packet.js");
const Converter = require("../Converter.js");
class Packet20NamedEntitySpawn extends Packet {
constructor(EID = 0, entityName = "", x = 0.0, y = 0.0, z = 0.0, yaw = 0.0, pitch = 0.0, currentItem = 0) {
super(0x14);
this.EID = EID;
this.entityName = entityName;
this.absX = Converter.toAbsoluteInt(x);
this.absY = Converter.toAbsoluteInt(y);
this.absZ = Converter.toAbsoluteInt(z);
2021-08-21 09:38:25 +01:00
this.packedYaw = Converter.to360Fraction(yaw);
this.packedPitch = Converter.to360Fraction(pitch);
2021-08-20 22:42:00 +01:00
this.currentItem = currentItem;
}
writePacket() {
super.writePacket();
this.writer.writeInt(this.EID);
this.writer.writeString(this.entityName);
this.writer.writeInt(this.absX);
this.writer.writeInt(this.absY);
this.writer.writeInt(this.absZ);
2021-08-24 15:08:48 +01:00
this.writer.writeUByte(this.packedYaw);
this.writer.writeUByte(this.packedPitch);
2021-08-20 22:42:00 +01:00
this.writer.writeShort(this.currentItem);
return this.toBuffer();
}
}
module.exports = Packet20NamedEntitySpawn;