use of cn.nukkit.network.protocol.RemoveEntityPacket in project Nukkit by Nukkit.
the class EntityHuman method despawnFrom.
@Override
public void despawnFrom(Player player) {
if (this.hasSpawned.containsKey(player.getLoaderId())) {
RemoveEntityPacket pk = new RemoveEntityPacket();
pk.eid = this.getId();
player.dataPacket(pk);
this.hasSpawned.remove(player.getLoaderId());
}
}
use of cn.nukkit.network.protocol.RemoveEntityPacket in project Nukkit by Nukkit.
the class FloatingTextParticle method encode.
@Override
public DataPacket[] encode() {
ArrayList<DataPacket> packets = new ArrayList<>();
if (this.entityId == -1) {
this.entityId = 1095216660480L + ThreadLocalRandom.current().nextLong(0, 0x7fffffffL);
} else {
RemoveEntityPacket pk = new RemoveEntityPacket();
pk.eid = this.entityId;
packets.add(pk);
}
if (!this.invisible) {
AddPlayerPacket pk = new AddPlayerPacket();
pk.uuid = UUID.randomUUID();
pk.username = "";
pk.entityUniqueId = this.entityId;
pk.entityRuntimeId = this.entityId;
pk.x = (float) this.x;
pk.y = (float) (this.y - 0.75);
pk.z = (float) this.z;
pk.speedX = 0;
pk.speedY = 0;
pk.speedZ = 0;
pk.yaw = 0;
pk.pitch = 0;
long flags = ((1L << Entity.DATA_FLAG_CAN_SHOW_NAMETAG) | (1L << Entity.DATA_FLAG_ALWAYS_SHOW_NAMETAG) | (1L << Entity.DATA_FLAG_IMMOBILE));
pk.metadata = new EntityMetadata().putLong(Entity.DATA_FLAGS, flags).putString(Entity.DATA_NAMETAG, this.title + (!this.text.isEmpty() ? "\n" + this.text : "")).putLong(Entity.DATA_LEAD_HOLDER_EID, -1).putFloat(Entity.DATA_SCALE, // zero causes problems on debug builds?
0.01f);
pk.item = Item.get(Item.AIR);
packets.add(pk);
}
return packets.stream().toArray(DataPacket[]::new);
}
Aggregations