use of cn.nukkit.entity.data.EntityMetadata in project Nukkit by Nukkit.
the class DummyBossBar method createBossEntity.
private void createBossEntity() {
AddEntityPacket pkAdd = new AddEntityPacket();
pkAdd.type = EntityCreeper.NETWORK_ID;
pkAdd.entityUniqueId = bossBarId;
pkAdd.entityRuntimeId = bossBarId;
pkAdd.x = (float) player.x;
// Below the bedrock
pkAdd.y = (float) -10;
pkAdd.z = (float) player.z;
pkAdd.speedX = 0;
pkAdd.speedY = 0;
pkAdd.speedZ = 0;
pkAdd.metadata = new EntityMetadata().putLong(Entity.DATA_FLAGS, 0).putShort(Entity.DATA_AIR, 400).putShort(Entity.DATA_MAX_AIR, 400).putLong(Entity.DATA_LEAD_HOLDER_EID, -1).putString(Entity.DATA_NAMETAG, // Set the entity name
text).putFloat(Entity.DATA_SCALE, // And make it invisible
0);
player.dataPacket(pkAdd);
}
use of cn.nukkit.entity.data.EntityMetadata in project Nukkit by Nukkit.
the class EntityXPOrb method spawnTo.
@Override
public void spawnTo(Player player) {
AddEntityPacket packet = new AddEntityPacket();
packet.type = getNetworkId();
packet.entityUniqueId = this.getId();
packet.entityRuntimeId = getId();
packet.x = (float) this.x;
packet.y = (float) this.y;
packet.z = (float) this.z;
packet.speedX = (float) this.motionX;
packet.speedY = (float) this.motionY;
packet.speedZ = (float) this.motionZ;
packet.metadata = new EntityMetadata();
player.dataPacket(packet);
// this.sendData(player);
super.spawnTo(player);
}
use of cn.nukkit.entity.data.EntityMetadata 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