use of net.minecraft.network.play.server.SEntityPropertiesPacket in project Arclight by IzzelAliz.
the class TrackedEntityMixin method a.
public void a(final Consumer<IPacket<?>> consumer, final ServerPlayerEntity entityplayer) {
if (this.trackedEntity.removed) {
return;
}
final IPacket<?> packet = this.trackedEntity.createSpawnPacket();
this.encodedRotationYawHead = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0f / 360.0f);
consumer.accept(packet);
if (!this.trackedEntity.getDataManager().isEmpty()) {
consumer.accept(new SEntityMetadataPacket(this.trackedEntity.getEntityId(), this.trackedEntity.getDataManager(), true));
}
boolean flag = this.sendVelocityUpdates;
if (this.trackedEntity instanceof LivingEntity) {
final AttributeMap attributemapserver = (AttributeMap) ((LivingEntity) this.trackedEntity).getAttributes();
final Collection<IAttributeInstance> collection = attributemapserver.getWatchedAttributes();
if (this.trackedEntity.getEntityId() == entityplayer.getEntityId()) {
((ServerPlayerEntityBridge) this.trackedEntity).bridge$getBukkitEntity().injectScaledMaxHealth(collection, false);
}
if (!collection.isEmpty()) {
consumer.accept(new SEntityPropertiesPacket(this.trackedEntity.getEntityId(), collection));
}
if (((LivingEntity) this.trackedEntity).isElytraFlying()) {
flag = true;
}
}
this.velocity = this.trackedEntity.getMotion();
if (flag && !(packet instanceof SSpawnMobPacket)) {
consumer.accept(new SEntityVelocityPacket(this.trackedEntity.getEntityId(), this.velocity));
}
if (this.trackedEntity instanceof LivingEntity) {
for (final EquipmentSlotType enumitemslot : EquipmentSlotType.values()) {
final ItemStack itemstack = ((LivingEntity) this.trackedEntity).getItemStackFromSlot(enumitemslot);
if (!itemstack.isEmpty()) {
consumer.accept(new SEntityEquipmentPacket(this.trackedEntity.getEntityId(), enumitemslot, itemstack));
}
}
}
this.encodedRotationYawHead = MathHelper.floor(this.trackedEntity.getRotationYawHead() * 256.0f / 360.0f);
consumer.accept(new SEntityHeadLookPacket(this.trackedEntity, (byte) this.encodedRotationYawHead));
if (this.trackedEntity instanceof LivingEntity) {
final LivingEntity entityliving = (LivingEntity) this.trackedEntity;
for (final EffectInstance mobeffect : entityliving.getActivePotionEffects()) {
consumer.accept(new SPlayEntityEffectPacket(this.trackedEntity.getEntityId(), mobeffect));
}
}
if (!this.trackedEntity.getPassengers().isEmpty()) {
consumer.accept(new SSetPassengersPacket(this.trackedEntity));
}
if (this.trackedEntity.isPassenger()) {
consumer.accept(new SSetPassengersPacket(this.trackedEntity.getRidingEntity()));
}
if (this.trackedEntity instanceof MobEntity) {
MobEntity mobentity = (MobEntity) this.trackedEntity;
if (mobentity.getLeashed()) {
consumer.accept(new SMountEntityPacket(mobentity, mobentity.getLeashHolder()));
}
}
}
Aggregations