Search in sources :

Example 1 with EntityWalkerKingIllusion

use of team.cqr.cqrepoured.entity.misc.EntityWalkerKingIllusion in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityCQRWalkerKing method hurt.

@Override
public boolean hurt(DamageSource source, float amount, boolean sentFromPart) {
    if (source == DamageSource.WITHER) {
        this.heal(amount / 2);
        return true;
    }
    if (source == DamageSource.FALL) {
        return true;
    }
    if (source == DamageSource.IN_WALL && this.hasAttackTarget() && this.isServerWorld()) {
        EntityWalkerKingIllusion illusion = new EntityWalkerKingIllusion(1200, this, this.getWorld());
        illusion.setPos(this.getX(), this.getY(), this.getZ());
        this.level.addFreshEntity(illusion);
        this.teleportBehindEntity(this.getTarget(), true);
        this.canAttack(this.getTarget());
        return false;
    }
    /*
		 * boolean spectralFlag = false;
		 * if (source.getTrueSource() instanceof EntityLivingBase) {
		 * if (EnchantmentHelper.getEnchantmentLevel(CQREnchantments.SPECTRAL, ((EntityLivingBase)
		 * source.getTrueSource()).getHeldItemMainhand()) > 0 ||
		 * EnchantmentHelper.getEnchantmentLevel(CQREnchantments.SPECTRAL, ((EntityLivingBase)
		 * source.getTrueSource()).getHeldItemOffhand()) > 0) {
		 * amount *= 2;
		 * spectralFlag = true;
		 * }
		 * }
		 */
    if (/* !spectralFlag && */
    ((source.getDirectEntity() == null) || !(source.getDirectEntity() instanceof SpectralArrowEntity)) && !CQRConfig.bosses.armorForTheWalkerKing) {
        amount *= 0.5F;
    }
    if (source.getDirectEntity() != null) {
        if (source.getDirectEntity() instanceof SpectralArrowEntity) {
            amount *= 2;
            super.hurt(source, amount, sentFromPart);
            return true;
        }
        if ((source.getDirectEntity() instanceof ThrowableEntity || source.getDirectEntity() instanceof AbstractArrowEntity) && !this.level.isClientSide) {
            // STAB HIM IN THE BACK!!
            this.backStabAttacker(source);
            return false;
        }
    }
    this.handleActivation();
    if (source.getEntity() != null && !this.level.isClientSide) {
        ResourceLocation resLoc = EntityList.getKey(source.getEntity());
        if (resLoc != null) {
            // Start IceAndFire compatibility
            boolean flag = resLoc.getNamespace().equalsIgnoreCase("iceandfire") && CQRConfig.advanced.enableSpecialFeatures;
            if (flag) {
                amount /= 2;
            }
            // End IceAndFire compatibility
            Faction fac = FactionRegistry.instance(this).getFactionOf(source.getEntity());
            boolean dragonFactionFlag = fac != null && (fac.getName().equalsIgnoreCase("DRAGON") || fac.getName().equalsIgnoreCase("DRAGONS"));
            // If we are attacked by a dragon: KILL IT
            if (this.dragonAttackCooldown <= 0 && (dragonFactionFlag || resLoc.getPath().contains("dragon") || resLoc.getPath().contains("wyrm") || resLoc.getPath().contains("wyvern") || flag)) {
                this.dragonAttackCooldown = 80;
                this.handleAttackedByDragon(source.getEntity());
            }
        }
    }
    if (!this.level.isClientSide && source.getEntity() instanceof LivingEntity) {
        // How about killing the one who tries with the axe?
        // Maybe move this whole ability to the king shield itself??
        ItemStack shieldStack = this.getItemBySlot(EquipmentSlotType.OFFHAND);
        if (amount > 0F && this.canBlockDamageSource(source) && shieldStack != null && !shieldStack.isEmpty() && shieldStack.getItem() instanceof ShieldItem) {
            this.playSound(CQRSounds.WALKER_KING_LAUGH, 10.0F, 1.0F);
            if (source.getDirectEntity() instanceof LivingEntity && /* && (source.getImmediateSource() instanceof EntityPlayer) */
            ((LivingEntity) source.getDirectEntity()).getMainHandItem().getItem() instanceof AxeItem) {
                if (DungeonGenUtils.percentageRandom(0.75, this.getRandom())) {
                    Vector3d v = source.getDirectEntity().position().subtract(this.position()).normalize().scale(1.25);
                    v = v.add(0, 0.75, 0);
                    LivingEntity attacker = (LivingEntity) source.getDirectEntity();
                    /*attacker.motionX = v.x;
						attacker.motionY = v.y;
						attacker.motionZ = v.z;
						attacker.velocityChanged = true;*/
                    attacker.setDeltaMovement(v);
                    attacker.hasImpulse = true;
                    this.swing(Hand.OFF_HAND);
                    return false;
                }
            }
        }
        if (this.getRandom().nextDouble() < 0.2 && source.getEntity() != null) {
            // Revenge Attack
            if (this.getRandom().nextDouble() < 0.7) {
                this.canAttack((LivingEntity) source.getEntity());
                this.playSound(CQRSounds.WALKER_KING_LAUGH, 10.0F, 1.0F);
                this.teleportBehindEntity(source.getEntity());
            }
        }
    }
    return super.hurt(source, amount, sentFromPart);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) EntityWalkerKingIllusion(team.cqr.cqrepoured.entity.misc.EntityWalkerKingIllusion) ShieldItem(net.minecraft.item.ShieldItem) Vector3d(net.minecraft.util.math.vector.Vector3d) SpectralArrowEntity(net.minecraft.entity.projectile.SpectralArrowEntity) ThrowableEntity(net.minecraft.entity.projectile.ThrowableEntity) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) AxeItem(net.minecraft.item.AxeItem) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) Faction(team.cqr.cqrepoured.faction.Faction) EDefaultFaction(team.cqr.cqrepoured.faction.EDefaultFaction)

Example 2 with EntityWalkerKingIllusion

use of team.cqr.cqrepoured.entity.misc.EntityWalkerKingIllusion in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityCQRWalkerKing method handleInWeb.

private void handleInWeb() {
    if (this.hasAttackTarget()) {
        this.level.destroyBlock(this.blockPosition(), false);
        EntityWalkerKingIllusion illusion = new EntityWalkerKingIllusion(1200, this, this.getWorld());
        illusion.setPos(this.getX(), this.getY(), this.getZ());
        this.level.addFreshEntity(illusion);
        this.teleportBehindEntity(this.getTarget());
        this.canAttack(this.getTarget());
    }
}
Also used : EntityWalkerKingIllusion(team.cqr.cqrepoured.entity.misc.EntityWalkerKingIllusion)

Example 3 with EntityWalkerKingIllusion

use of team.cqr.cqrepoured.entity.misc.EntityWalkerKingIllusion in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityAIWalkerIllusions method startCastingSpell.

@Override
public void startCastingSpell() {
    // entity.getAttackTarget().addPotionEffect(new PotionEffect(Potion.getPotionById(15), 40));
    this.entity.level.getEntities(this.entity, new AxisAlignedBB(this.entity.blockPosition().offset(-20, -10, -20), this.entity.blockPosition().offset(20, 10, 20)), TargetUtil.createPredicateNonAlly(this.entity.getFaction())).forEach(t -> {
        if (t instanceof LivingEntity) {
            ((LivingEntity) t).addEffect(new EffectInstance(Effects.BLINDNESS, 40));
        }
    });
    Vector3d v = new Vector3d(2.5, 0, 0);
    for (int i = 0; i < 3; i++) {
        Vector3d pos = this.entity.position().add(VectorUtil.rotateVectorAroundY(v, 120 * i));
        EntityWalkerKingIllusion illusion = new EntityWalkerKingIllusion(1200, (EntityCQRWalkerKing) this.entity, this.entity.level);
        illusion.setPos(pos.x, pos.y, pos.z);
        this.entity.level.addFreshEntity(illusion);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) LivingEntity(net.minecraft.entity.LivingEntity) EntityWalkerKingIllusion(team.cqr.cqrepoured.entity.misc.EntityWalkerKingIllusion) Vector3d(net.minecraft.util.math.vector.Vector3d) EffectInstance(net.minecraft.potion.EffectInstance)

Aggregations

EntityWalkerKingIllusion (team.cqr.cqrepoured.entity.misc.EntityWalkerKingIllusion)3 LivingEntity (net.minecraft.entity.LivingEntity)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2 AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)1 SpectralArrowEntity (net.minecraft.entity.projectile.SpectralArrowEntity)1 ThrowableEntity (net.minecraft.entity.projectile.ThrowableEntity)1 AxeItem (net.minecraft.item.AxeItem)1 ItemStack (net.minecraft.item.ItemStack)1 ShieldItem (net.minecraft.item.ShieldItem)1 EffectInstance (net.minecraft.potion.EffectInstance)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 EDefaultFaction (team.cqr.cqrepoured.faction.EDefaultFaction)1 Faction (team.cqr.cqrepoured.faction.Faction)1