use of net.minecraft.network.play.server.SEntityEquipmentPacket in project minecolonies by Minecolonies.
the class AbstractEntityCitizen method detectEquipmentUpdates.
@Override
public void detectEquipmentUpdates() {
if (this.isEquipmentDirty) {
this.isEquipmentDirty = false;
List<Pair<EquipmentSlotType, ItemStack>> list = Lists.newArrayListWithCapacity(6);
list.add(new Pair<>(EquipmentSlotType.CHEST, getItemBySlot(EquipmentSlotType.CHEST)));
list.add(new Pair<>(EquipmentSlotType.FEET, getItemBySlot(EquipmentSlotType.FEET)));
list.add(new Pair<>(EquipmentSlotType.HEAD, getItemBySlot(EquipmentSlotType.HEAD)));
list.add(new Pair<>(EquipmentSlotType.LEGS, getItemBySlot(EquipmentSlotType.LEGS)));
list.add(new Pair<>(EquipmentSlotType.OFFHAND, getItemBySlot(EquipmentSlotType.OFFHAND)));
list.add(new Pair<>(EquipmentSlotType.MAINHAND, getItemBySlot(EquipmentSlotType.MAINHAND)));
((ServerWorld) this.level).getChunkSource().broadcast(this, new SEntityEquipmentPacket(this.getId(), list));
}
}
use of net.minecraft.network.play.server.SEntityEquipmentPacket 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()));
}
}
}
use of net.minecraft.network.play.server.SEntityEquipmentPacket in project minecolonies by ldtteam.
the class AbstractEntityCitizen method detectEquipmentUpdates.
@Override
public void detectEquipmentUpdates() {
if (this.isEquipmentDirty) {
this.isEquipmentDirty = false;
List<Pair<EquipmentSlotType, ItemStack>> list = Lists.newArrayListWithCapacity(6);
list.add(new Pair<>(EquipmentSlotType.CHEST, getItemBySlot(EquipmentSlotType.CHEST)));
list.add(new Pair<>(EquipmentSlotType.FEET, getItemBySlot(EquipmentSlotType.FEET)));
list.add(new Pair<>(EquipmentSlotType.HEAD, getItemBySlot(EquipmentSlotType.HEAD)));
list.add(new Pair<>(EquipmentSlotType.LEGS, getItemBySlot(EquipmentSlotType.LEGS)));
list.add(new Pair<>(EquipmentSlotType.OFFHAND, getItemBySlot(EquipmentSlotType.OFFHAND)));
list.add(new Pair<>(EquipmentSlotType.MAINHAND, getItemBySlot(EquipmentSlotType.MAINHAND)));
((ServerWorld) this.level).getChunkSource().broadcast(this, new SEntityEquipmentPacket(this.getId(), list));
}
}
Aggregations