Search in sources :

Example 1 with ArmorStandEntity

use of net.minecraft.entity.item.ArmorStandEntity in project minecolonies by Minecolonies.

the class KnightCombatAI method doAoeAttack.

/**
 * Does an aoe attack if researched
 *
 * @param source          normal attack damage source
 * @param damageToBeDealt normal attack damage to be distributed to targets
 */
private void doAoeAttack(final DamageSource source, final double damageToBeDealt) {
    if (user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(KNIGHT_WHIRLWIND) > 0 && user.getRandom().nextInt(KNOCKBACK_CHANCE) == 0) {
        List<LivingEntity> entities = user.level.getLoadedEntitiesOfClass(LivingEntity.class, user.getBoundingBox().inflate(2.0D, 0.5D, 2.0D));
        for (LivingEntity livingentity : entities) {
            if (livingentity != user && isEntityValidTarget(livingentity) && (!(livingentity instanceof ArmorStandEntity))) {
                livingentity.knockback(2F, MathHelper.sin(livingentity.yRot * ((float) Math.PI)), (-MathHelper.cos(livingentity.yRot * ((float) Math.PI))));
                livingentity.hurt(source, (float) (damageToBeDealt / entities.size()));
            }
        }
        user.level.playSound(null, user.getX(), user.getY(), user.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, user.getSoundSource(), 1.0F, 1.0F);
        double d0 = (double) (-MathHelper.sin(user.yRot * ((float) Math.PI / 180)));
        double d1 = (double) MathHelper.cos(user.yRot * ((float) Math.PI / 180));
        if (user.level instanceof ServerWorld) {
            ((ServerWorld) user.level).sendParticles(ParticleTypes.SWEEP_ATTACK, user.getX() + d0, user.getY(0.5D), user.getZ() + d1, 2, d0, 0.0D, d1, 0.0D);
        }
        lastAoeUseTime = user.level.getGameTime();
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ServerWorld(net.minecraft.world.server.ServerWorld) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity)

Example 2 with ArmorStandEntity

use of net.minecraft.entity.item.ArmorStandEntity in project Arclight by IzzelAliz.

the class PlayerEntityMixin method attackTargetEntityWithCurrentItem.

/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
public void attackTargetEntityWithCurrentItem(final Entity entity) {
    if (!net.minecraftforge.common.ForgeHooks.onPlayerAttackTarget((PlayerEntity) (Object) this, entity))
        return;
    if (entity.canBeAttackedWithItem() && !entity.hitByEntity((PlayerEntity) (Object) this)) {
        float f = (float) this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getValue();
        float f2;
        if (entity instanceof LivingEntity) {
            f2 = EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((LivingEntity) entity).getCreatureAttribute());
        } else {
            f2 = EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), CreatureAttribute.UNDEFINED);
        }
        final float f3 = this.getCooledAttackStrength(0.5f);
        f *= 0.2f + f3 * f3 * 0.8f;
        f2 *= f3;
        this.resetCooldown();
        if (f > 0.0f || f2 > 0.0f) {
            final boolean flag = f3 > 0.9f;
            boolean flag2 = false;
            final byte b0 = 0;
            int i = b0 + EnchantmentHelper.getKnockbackModifier((PlayerEntity) (Object) this);
            if (this.isSprinting() && flag) {
                this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.getSoundCategory(), 1.0f, 1.0f);
                ++i;
                flag2 = true;
            }
            boolean flag3 = flag && this.fallDistance > 0.0f && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(Effects.BLINDNESS) && !this.isPassenger() && entity instanceof LivingEntity;
            net.minecraftforge.event.entity.player.CriticalHitEvent hitResult = net.minecraftforge.common.ForgeHooks.getCriticalHit((PlayerEntity) (Object) this, entity, flag3, flag3 ? 1.5F : 1.0F);
            flag3 = hitResult != null;
            if (flag3) {
                f *= hitResult.getDamageModifier();
            }
            f += f2;
            boolean flag4 = false;
            final double d0 = this.distanceWalkedModified - this.prevDistanceWalkedModified;
            if (flag && !flag3 && !flag2 && this.onGround && d0 < this.getAIMoveSpeed()) {
                final ItemStack itemstack = this.getHeldItem(Hand.MAIN_HAND);
                if (itemstack.getItem() instanceof SwordItem) {
                    flag4 = true;
                }
            }
            float f4 = 0.0f;
            boolean flag5 = false;
            final int j = EnchantmentHelper.getFireAspectModifier((PlayerEntity) (Object) this);
            if (entity instanceof LivingEntity) {
                f4 = ((LivingEntity) entity).getHealth();
                if (j > 0 && !entity.isBurning()) {
                    final EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity(), 1);
                    Bukkit.getPluginManager().callEvent(combustEvent);
                    if (!combustEvent.isCancelled()) {
                        flag5 = true;
                        ((EntityBridge) entity).bridge$setOnFire(combustEvent.getDuration(), false);
                    }
                }
            }
            final Vec3d vec3d = entity.getMotion();
            final boolean flag6 = entity.attackEntityFrom(DamageSource.causePlayerDamage((PlayerEntity) (Object) this), f);
            if (flag6) {
                if (i > 0) {
                    if (entity instanceof LivingEntity) {
                        ((LivingEntity) entity).knockBack((PlayerEntity) (Object) this, i * 0.5f, MathHelper.sin(this.rotationYaw * 0.017453292f), -MathHelper.cos(this.rotationYaw * 0.017453292f));
                    } else {
                        entity.addVelocity(-MathHelper.sin(this.rotationYaw * 0.017453292f) * i * 0.5f, 0.1, MathHelper.cos(this.rotationYaw * 0.017453292f) * i * 0.5f);
                    }
                    this.setMotion(this.getMotion().mul(0.6, 1.0, 0.6));
                    this.setSprinting(false);
                }
                if (flag4) {
                    final float f5 = 1.0f + EnchantmentHelper.getSweepingDamageRatio((PlayerEntity) (Object) this) * f;
                    final List<LivingEntity> list = this.world.getEntitiesWithinAABB((Class<? extends LivingEntity>) LivingEntity.class, entity.getBoundingBox().grow(1.0, 0.25, 1.0));
                    for (final LivingEntity entityliving : list) {
                        if (entityliving != (Object) this && entityliving != entity && !this.isOnSameTeam(entityliving) && (!(entityliving instanceof ArmorStandEntity) || !((ArmorStandEntity) entityliving).hasMarker()) && this.getDistanceSq(entityliving) < 9.0 && entityliving.attackEntityFrom(((DamageSourceBridge) DamageSource.causePlayerDamage((PlayerEntity) (Object) this)).bridge$sweep(), f5)) {
                            entityliving.knockBack((PlayerEntity) (Object) this, 0.4f, MathHelper.sin(this.rotationYaw * 0.017453292f), -MathHelper.cos(this.rotationYaw * 0.017453292f));
                        }
                    }
                    this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, this.getSoundCategory(), 1.0f, 1.0f);
                    this.spawnSweepParticles();
                }
                if (entity instanceof ServerPlayerEntity && entity.velocityChanged) {
                    boolean cancelled = false;
                    final Player player = ((ServerPlayerEntityBridge) entity).bridge$getBukkitEntity();
                    final Vector velocity = CraftVector.toBukkit(vec3d);
                    final PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
                    Bukkit.getPluginManager().callEvent(event);
                    if (event.isCancelled()) {
                        cancelled = true;
                    } else if (!velocity.equals(event.getVelocity())) {
                        player.setVelocity(event.getVelocity());
                    }
                    if (!cancelled) {
                        ((ServerPlayerEntity) entity).connection.sendPacket(new SEntityVelocityPacket(entity));
                        entity.velocityChanged = false;
                        entity.setMotion(vec3d);
                    }
                }
                if (flag3) {
                    this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_CRIT, this.getSoundCategory(), 1.0f, 1.0f);
                    this.onCriticalHit(entity);
                }
                if (!flag3 && !flag4) {
                    if (flag) {
                        this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_STRONG, this.getSoundCategory(), 1.0f, 1.0f);
                    } else {
                        this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_WEAK, this.getSoundCategory(), 1.0f, 1.0f);
                    }
                }
                if (f2 > 0.0f) {
                    this.onEnchantmentCritical(entity);
                }
                this.setLastAttackedEntity(entity);
                if (entity instanceof LivingEntity) {
                    EnchantmentHelper.applyThornEnchantments((LivingEntity) entity, (PlayerEntity) (Object) this);
                }
                EnchantmentHelper.applyArthropodEnchantments((PlayerEntity) (Object) this, entity);
                final ItemStack itemstack2 = this.getHeldItemMainhand();
                Object object = entity;
                if (entity instanceof EnderDragonPartEntity) {
                    object = ((EnderDragonPartEntity) entity).dragon;
                }
                if (!this.world.isRemote && !itemstack2.isEmpty() && object instanceof LivingEntity) {
                    ItemStack copy = itemstack2.copy();
                    itemstack2.hitEntity((LivingEntity) object, (PlayerEntity) (Object) this);
                    if (itemstack2.isEmpty()) {
                        net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem((PlayerEntity) (Object) this, copy, Hand.MAIN_HAND);
                        this.setHeldItem(Hand.MAIN_HAND, ItemStack.EMPTY);
                    }
                }
                if (entity instanceof LivingEntity) {
                    final float f6 = f4 - ((LivingEntity) entity).getHealth();
                    this.addStat(Stats.DAMAGE_DEALT, Math.round(f6 * 10.0f));
                    if (j > 0) {
                        final EntityCombustByEntityEvent combustEvent2 = new EntityCombustByEntityEvent(this.getBukkitEntity(), ((EntityBridge) entity).bridge$getBukkitEntity(), j * 4);
                        Bukkit.getPluginManager().callEvent(combustEvent2);
                        if (!combustEvent2.isCancelled()) {
                            ((EntityBridge) entity).bridge$setOnFire(combustEvent2.getDuration(), false);
                        }
                    }
                    if (this.world instanceof ServerWorld && f6 > 2.0f) {
                        final int k = (int) (f6 * 0.5);
                        ((ServerWorld) this.world).spawnParticle(ParticleTypes.DAMAGE_INDICATOR, entity.posX, entity.posY + entity.getHeight() * 0.5f, entity.posZ, k, 0.1, 0.0, 0.1, 0.2);
                    }
                }
                this.addExhaustion(0.1f);
            } else {
                this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0f, 1.0f);
                if (flag5) {
                    entity.extinguish();
                }
                if (this instanceof ServerPlayerEntityBridge) {
                    ((ServerPlayerEntityBridge) this).bridge$getBukkitEntity().updateInventory();
                }
            }
        }
    }
}
Also used : PlayerVelocityEvent(org.bukkit.event.player.PlayerVelocityEvent) SwordItem(net.minecraft.item.SwordItem) EntityCombustByEntityEvent(org.bukkit.event.entity.EntityCombustByEntityEvent) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ServerPlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge) LivingEntity(net.minecraft.entity.LivingEntity) SEntityVelocityPacket(net.minecraft.network.play.server.SEntityVelocityPacket) ServerWorld(net.minecraft.world.server.ServerWorld) InternalEntityBridge(io.izzel.arclight.common.bridge.entity.InternalEntityBridge) ServerPlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge) EntityBridge(io.izzel.arclight.common.bridge.entity.EntityBridge) PlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.PlayerEntityBridge) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity) Vector(org.bukkit.util.Vector) CraftVector(org.bukkit.craftbukkit.v.util.CraftVector) Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) DamageSourceBridge(io.izzel.arclight.common.bridge.util.DamageSourceBridge) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) Vec3d(net.minecraft.util.math.Vec3d) EnderDragonPartEntity(net.minecraft.entity.boss.dragon.EnderDragonPartEntity) ItemStack(net.minecraft.item.ItemStack) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 3 with ArmorStandEntity

use of net.minecraft.entity.item.ArmorStandEntity in project Structurize by ldtteam.

the class ItemStackUtils method getListOfStackForEntity.

/**
 * Get the list of required resources for entities.
 *
 * @param entity the entity object.
 * @param pos the placer pos..
 * @return a list of stacks.
 */
public static List<ItemStack> getListOfStackForEntity(final Entity entity, final BlockPos pos) {
    if (entity != null) {
        final List<ItemStack> request = new ArrayList<>();
        if (entity instanceof ItemFrameEntity) {
            final ItemStack stack = ((ItemFrameEntity) entity).getItem();
            if (!ItemStackUtils.isEmpty(stack)) {
                stack.setCount(1);
                request.add(stack);
            }
            request.add(new ItemStack(Items.ITEM_FRAME, 1));
        } else if (entity instanceof ArmorStandEntity) {
            request.add(entity.getPickedResult(new RayTraceResult(Vector3d.atLowerCornerOf(pos)) {

                @NotNull
                @Override
                public Type getType() {
                    return Type.ENTITY;
                }
            }));
            entity.getArmorSlots().forEach(request::add);
            entity.getHandSlots().forEach(request::add);
        }
        return request.stream().filter(stack -> !stack.isEmpty()).collect(Collectors.toList());
    }
    return Collections.emptyList();
}
Also used : ContainerBlock(net.minecraft.block.ContainerBlock) Entity(net.minecraft.entity.Entity) IItemHandler(net.minecraftforge.items.IItemHandler) java.util(java.util) ICapabilityProvider(net.minecraftforge.common.capabilities.ICapabilityProvider) CompoundNBT(net.minecraft.nbt.CompoundNBT) net.minecraft.item(net.minecraft.item) BlockPos(net.minecraft.util.math.BlockPos) Type(net.minecraft.util.math.RayTraceResult.Type) Direction(net.minecraft.util.Direction) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity) Collectors(java.util.stream.Collectors) net.minecraft.tileentity(net.minecraft.tileentity) ItemFrameEntity(net.minecraft.entity.item.ItemFrameEntity) RayTraceResult(net.minecraft.util.math.RayTraceResult) Nullable(org.jetbrains.annotations.Nullable) Vector3d(net.minecraft.util.math.vector.Vector3d) ItemStackHelper(net.minecraft.inventory.ItemStackHelper) ITEM_HANDLER_CAPABILITY(net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) NonNullList(net.minecraft.util.NonNullList) BlockState(net.minecraft.block.BlockState) NotNull(org.jetbrains.annotations.NotNull) Type(net.minecraft.util.math.RayTraceResult.Type) ItemFrameEntity(net.minecraft.entity.item.ItemFrameEntity) RayTraceResult(net.minecraft.util.math.RayTraceResult) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ArmorStandEntity

use of net.minecraft.entity.item.ArmorStandEntity in project Champions by TheIllusiveC4.

the class BasicAffix method canTarget.

public static boolean canTarget(LivingEntity livingEntity, LivingEntity target, boolean sightCheck) {
    if (target == null || !target.isAlive() || target instanceof ArmorStandEntity || (sightCheck && !livingEntity.canEntityBeSeen(target))) {
        return false;
    }
    ModifiableAttributeInstance attributeInstance = livingEntity.getAttribute(Attributes.FOLLOW_RANGE);
    double range = attributeInstance == null ? 16.0D : attributeInstance.getValue();
    range = ChampionsConfig.affixTargetRange == 0 ? range : Math.min(range, ChampionsConfig.affixTargetRange);
    return livingEntity.getDistance(target) <= range;
}
Also used : ModifiableAttributeInstance(net.minecraft.entity.ai.attributes.ModifiableAttributeInstance) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity)

Example 5 with ArmorStandEntity

use of net.minecraft.entity.item.ArmorStandEntity in project BetterDiving by Meldexun.

the class ModelCustomArmor method setupAnim.

@Override
public void setupAnim(LivingEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
    if (entity instanceof ArmorStandEntity) {
        ArmorStandEntity armorStand = (ArmorStandEntity) entity;
        this.head.xRot = 0.017453292F * armorStand.getHeadPose().getX();
        this.head.yRot = 0.017453292F * armorStand.getHeadPose().getY();
        this.head.zRot = 0.017453292F * armorStand.getHeadPose().getZ();
        this.head.setPos(0.0F, 1.0F, 0.0F);
        this.body.xRot = 0.017453292F * armorStand.getBodyPose().getX();
        this.body.yRot = 0.017453292F * armorStand.getBodyPose().getY();
        this.body.zRot = 0.017453292F * armorStand.getBodyPose().getZ();
        this.leftArm.xRot = 0.017453292F * armorStand.getLeftArmPose().getX();
        this.leftArm.yRot = 0.017453292F * armorStand.getLeftArmPose().getY();
        this.leftArm.zRot = 0.017453292F * armorStand.getLeftArmPose().getZ();
        this.rightArm.xRot = 0.017453292F * armorStand.getRightArmPose().getX();
        this.rightArm.yRot = 0.017453292F * armorStand.getRightArmPose().getY();
        this.rightArm.zRot = 0.017453292F * armorStand.getRightArmPose().getZ();
        this.leftLeg.xRot = 0.017453292F * armorStand.getLeftLegPose().getX();
        this.leftLeg.yRot = 0.017453292F * armorStand.getLeftLegPose().getY();
        this.leftLeg.zRot = 0.017453292F * armorStand.getLeftLegPose().getZ();
        this.leftLeg.setPos(1.9F, 11.0F, 0.0F);
        this.rightLeg.xRot = 0.017453292F * armorStand.getRightLegPose().getX();
        this.rightLeg.yRot = 0.017453292F * armorStand.getRightLegPose().getY();
        this.rightLeg.zRot = 0.017453292F * armorStand.getRightLegPose().getZ();
        this.rightLeg.setPos(-1.9F, 11.0F, 0.0F);
        this.hat.copyFrom(this.head);
    } else {
        super.setupAnim(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
    }
}
Also used : ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity)

Aggregations

ArmorStandEntity (net.minecraft.entity.item.ArmorStandEntity)11 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 Entity (net.minecraft.entity.Entity)3 LivingEntity (net.minecraft.entity.LivingEntity)3 ItemFrameEntity (net.minecraft.entity.item.ItemFrameEntity)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 net.minecraft.item (net.minecraft.item)3 CompoundNBT (net.minecraft.nbt.CompoundNBT)3 Lists (com.google.common.collect.Lists)2 MinecoloniesAPIProxy (com.minecolonies.api.MinecoloniesAPIProxy)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 Compatibility (com.minecolonies.api.compatibility.Compatibility)2 ItemStorage (com.minecolonies.api.crafting.ItemStorage)2 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)2 ModItems (com.minecolonies.api.items.ModItems)2 ModTags.fungi (com.minecolonies.api.items.ModTags.fungi)2 FUEL_SLOT (com.minecolonies.api.util.constant.Constants.FUEL_SLOT)2 SMELTABLE_SLOT (com.minecolonies.api.util.constant.Constants.SMELTABLE_SLOT)2 IToolType (com.minecolonies.api.util.constant.IToolType)2