use of org.bukkit.inventory.EquipmentSlot in project BKCommonLib by bergerhealer.
the class EntityNetworkController method initMetaData.
/**
* Synchronizes all Entity Meta Data including Entity Attributes and other
* specific flags. Movement and positioning information is not
* updated.<br><br>
* <p/>
* This should be called when making this Entity visible to a viewer.
*
* @param viewer to send the meta data to
*/
public void initMetaData(Player viewer) {
// Meta Data
DataWatcher metaData = entity.getMetaData();
if (!metaData.isEmpty()) {
PacketUtil.sendPacket(viewer, PacketType.OUT_ENTITY_METADATA.newInstance(entity.getEntityId(), metaData, true));
}
// Living Entity - only data
Object entityHandle = this.entity.getHandle();
if (EntityLivingHandle.T.isAssignableFrom(entityHandle)) {
EntityLivingHandle living = EntityLivingHandle.createHandle(entityHandle);
// Entity Attributes
AttributeMapServerHandle attributeMap = living.getAttributeMap();
Collection<?> attributes = attributeMap.attributes();
if (!attributes.isEmpty()) {
PacketUtil.sendPacket(viewer, PacketType.OUT_ENTITY_UPDATE_ATTRIBUTES.newInstance(entity.getEntityId(), attributes));
}
// Entity Equipment
for (EquipmentSlot slot : EquipmentSlot.values()) {
org.bukkit.inventory.ItemStack itemstack = living.getEquipment(slot);
if (itemstack != null) {
PacketUtil.sendPacket(viewer, PacketType.OUT_ENTITY_EQUIPMENT.newInstance(entity.getEntityId(), slot, itemstack));
}
}
// Entity Mob Effects
for (MobEffectHandle effect : living.getEffects()) {
PacketUtil.sendPacket(viewer, PacketType.OUT_ENTITY_EFFECT_ADD.newInstance(entity.getEntityId(), effect.getRaw()));
}
}
}
Aggregations