Search in sources :

Example 1 with SEntityEquipmentPacket

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));
    }
}
Also used : SEntityEquipmentPacket(net.minecraft.network.play.server.SEntityEquipmentPacket) Pair(com.mojang.datafixers.util.Pair)

Example 2 with SEntityEquipmentPacket

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()));
        }
    }
}
Also used : SEntityPropertiesPacket(net.minecraft.network.play.server.SEntityPropertiesPacket) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) SEntityHeadLookPacket(net.minecraft.network.play.server.SEntityHeadLookPacket) SSetPassengersPacket(net.minecraft.network.play.server.SSetPassengersPacket) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) SMountEntityPacket(net.minecraft.network.play.server.SMountEntityPacket) SPlayEntityEffectPacket(net.minecraft.network.play.server.SPlayEntityEffectPacket) SEntityEquipmentPacket(net.minecraft.network.play.server.SEntityEquipmentPacket) SSpawnMobPacket(net.minecraft.network.play.server.SSpawnMobPacket) LivingEntity(net.minecraft.entity.LivingEntity) SEntityVelocityPacket(net.minecraft.network.play.server.SEntityVelocityPacket) AttributeMap(net.minecraft.entity.ai.attributes.AttributeMap) SEntityMetadataPacket(net.minecraft.network.play.server.SEntityMetadataPacket) ItemStack(net.minecraft.item.ItemStack) EffectInstance(net.minecraft.potion.EffectInstance) MobEntity(net.minecraft.entity.MobEntity)

Example 3 with SEntityEquipmentPacket

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));
    }
}
Also used : SEntityEquipmentPacket(net.minecraft.network.play.server.SEntityEquipmentPacket) Pair(com.mojang.datafixers.util.Pair)

Aggregations

SEntityEquipmentPacket (net.minecraft.network.play.server.SEntityEquipmentPacket)3 Pair (com.mojang.datafixers.util.Pair)2 LivingEntity (net.minecraft.entity.LivingEntity)1 MobEntity (net.minecraft.entity.MobEntity)1 AttributeMap (net.minecraft.entity.ai.attributes.AttributeMap)1 IAttributeInstance (net.minecraft.entity.ai.attributes.IAttributeInstance)1 EquipmentSlotType (net.minecraft.inventory.EquipmentSlotType)1 ItemStack (net.minecraft.item.ItemStack)1 SEntityHeadLookPacket (net.minecraft.network.play.server.SEntityHeadLookPacket)1 SEntityMetadataPacket (net.minecraft.network.play.server.SEntityMetadataPacket)1 SEntityPropertiesPacket (net.minecraft.network.play.server.SEntityPropertiesPacket)1 SEntityVelocityPacket (net.minecraft.network.play.server.SEntityVelocityPacket)1 SMountEntityPacket (net.minecraft.network.play.server.SMountEntityPacket)1 SPlayEntityEffectPacket (net.minecraft.network.play.server.SPlayEntityEffectPacket)1 SSetPassengersPacket (net.minecraft.network.play.server.SSetPassengersPacket)1 SSpawnMobPacket (net.minecraft.network.play.server.SSpawnMobPacket)1 EffectInstance (net.minecraft.potion.EffectInstance)1