Search in sources :

Example 1 with Vector3

use of com.integral.enigmaticlegacy.helpers.Vector3 in project Enigmatic-Legacy by Aizistral-Studios.

the class UltimateWitherSkullEntity method tick.

@Override
public void tick() {
    super.tick();
    if (this.world.isRemote)
        return;
    if (!(this.shootingEntity instanceof PlayerEntity)) {
        return;
    }
    if (this.ticksExisted < 10) {
        Vector3 res = AOEMiningHelper.calcRayTrace(world, (PlayerEntity) this.shootingEntity, FluidMode.NONE, 128);
        this.initMotion(this.shootingEntity, res.x - this.posX, res.y - this.posY, res.z - this.posZ, 0.1F);
        return;
    }
    if (this.ticksExisted == 10) {
        Vector3 res = AOEMiningHelper.calcRayTrace(world, (PlayerEntity) this.shootingEntity, FluidMode.NONE, 128);
        this.initMotion(this.shootingEntity, res.x - this.posX, res.y - this.posY, res.z - this.posZ, 1.0F);
    }
    if (this.ticksExisted >= 400) {
        this.onImpact(BlockRayTraceResult.createMiss(this.getPositionVector(), Direction.DOWN, this.getPosition()));
    }
}
Also used : Vector3(com.integral.enigmaticlegacy.helpers.Vector3) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 2 with Vector3

use of com.integral.enigmaticlegacy.helpers.Vector3 in project Enigmatic-Legacy by Aizistral-Studios.

the class EnigmaticEventHandler method onEntityHurt.

@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event) {
    if (event.getEntityLiving() instanceof PlayerEntity & !event.getEntityLiving().world.isRemote) {
        PlayerEntity player = (PlayerEntity) event.getEntityLiving();
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.angelBlessing))
            if (AngelBlessing.resistanceList.containsKey(event.getSource().damageType))
                event.setAmount(event.getAmount() * AngelBlessing.resistanceList.get(event.getSource().damageType));
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.oceanStone)) {
            Entity attacker = event.getSource().getTrueSource();
            if (attacker instanceof DrownedEntity || attacker instanceof GuardianEntity || attacker instanceof ElderGuardianEntity)
                event.setAmount(event.getAmount() * ConfigHandler.OCEAN_STONE_UNDERWATER_CREATURES_RESISTANCE.getValue().asModifierInverted());
        }
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.eyeOfNebula))
            if (EyeOfNebula.resistanceList.containsKey(event.getSource().damageType))
                event.setAmount(event.getAmount() * EyeOfNebula.resistanceList.get(event.getSource().damageType).get());
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.golemHeart))
            if (GolemHeart.resistanceList.containsKey(event.getSource().damageType))
                event.setAmount(event.getAmount() * GolemHeart.resistanceList.get(event.getSource().damageType).get());
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.voidPearl))
            if (VoidPearl.resistanceList.containsKey(event.getSource().damageType))
                event.setAmount(event.getAmount() * VoidPearl.resistanceList.get(event.getSource().damageType).get());
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.magmaHeart)) {
            // System.out.println("Damage type: " + event.getSource().damageType);
            if (event.getSource().getTrueSource() instanceof LivingEntity && MagmaHeart.nemesisList.contains(event.getSource().damageType)) {
                LivingEntity attacker = (LivingEntity) event.getSource().getTrueSource();
                if (!attacker.isImmuneToFire()) {
                    attacker.attackEntityFrom(new EntityDamageSource(DamageSource.ON_FIRE.damageType, player), (float) ConfigHandler.BLAZING_CORE_DAMAGE_FEEDBACK.getValue());
                    attacker.setFire((int) ConfigHandler.BLAZING_CORE_IGNITION_FEEDBACK.getValue());
                }
            }
        }
        if (EtheriumArmor.hasShield(player)) {
            if (event.getSource().getImmediateSource() instanceof LivingEntity) {
                LivingEntity attacker = ((LivingEntity) event.getSource().getTrueSource());
                Vector3 vec = Vector3.fromEntityCenter(player).subtract(Vector3.fromEntityCenter(event.getSource().getTrueSource())).normalize();
                attacker.knockBack(player, 0.75F, vec.x, vec.y);
                player.world.playSound(null, player.getPosition(), EnigmaticLegacy.SHIELD_TRIGGER, SoundCategory.PLAYERS, 1.0F, 0.9F + (float) (Math.random() * 0.1D));
                player.world.playSound(null, player.getPosition(), EnigmaticLegacy.SHIELD_TRIGGER, SoundCategory.PLAYERS, 1.0F, 0.9F + (float) (Math.random() * 0.1D));
            }
            event.setAmount(event.getAmount() * ConfigHandler.ETHERIUM_ARMOR_SHIELD_REDUCTION.getValue().asModifierInverted());
        }
    } else if (event.getEntityLiving() instanceof MonsterEntity) {
        MonsterEntity monster = (MonsterEntity) event.getEntityLiving();
        if (event.getSource().getTrueSource() instanceof PlayerEntity) {
            PlayerEntity player = (PlayerEntity) event.getSource().getTrueSource();
            if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.monsterCharm)) {
                if (monster.isEntityUndead()) {
                    event.setAmount(event.getAmount() * ConfigHandler.MONSTER_CHARM_UNDEAD_DAMAGE.getValue().asModifier(true));
                } else if (monster.isAggressive() || monster instanceof CreeperEntity) {
                    if (monster instanceof EndermanEntity || monster instanceof ZombiePigmanEntity || monster instanceof BlazeEntity || monster instanceof GuardianEntity || monster instanceof ElderGuardianEntity || !monster.isNonBoss()) {
                    } else {
                        event.setAmount(event.getAmount() * ConfigHandler.MONSTER_CHARM_AGGRESSIVE_DAMAGE.getValue().asModifier(true));
                    }
                }
            }
            if (monster instanceof CreeperEntity)
                monster.setLastAttackedEntity(player);
        // TODO Test if required
        }
    }
    if (event.getSource().getTrueSource() instanceof PlayerEntity) {
        PlayerEntity player = (PlayerEntity) event.getSource().getTrueSource();
        if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.voidPearl)) {
            event.getEntityLiving().addPotionEffect(new EffectInstance(Effects.WITHER, ConfigHandler.VOID_PEARL_WITHERING_EFFECT_TIME.getValue(), ConfigHandler.VOID_PEARL_WITHERING_EFFECT_LEVEL.getValue(), false, true));
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) BlazeEntity(net.minecraft.entity.monster.BlazeEntity) EndermanEntity(net.minecraft.entity.monster.EndermanEntity) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) MonsterEntity(net.minecraft.entity.monster.MonsterEntity) ZombieEntity(net.minecraft.entity.monster.ZombieEntity) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) PermanentItemEntity(com.integral.enigmaticlegacy.entities.PermanentItemEntity) ZombiePigmanEntity(net.minecraft.entity.monster.ZombiePigmanEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) DrownedEntity(net.minecraft.entity.monster.DrownedEntity) GuardianEntity(net.minecraft.entity.monster.GuardianEntity) Entity(net.minecraft.entity.Entity) CreeperEntity(net.minecraft.entity.monster.CreeperEntity) WitherSkeletonEntity(net.minecraft.entity.monster.WitherSkeletonEntity) SkeletonEntity(net.minecraft.entity.monster.SkeletonEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) ElderGuardianEntity(net.minecraft.entity.monster.ElderGuardianEntity) ZombiePigmanEntity(net.minecraft.entity.monster.ZombiePigmanEntity) BlazeEntity(net.minecraft.entity.monster.BlazeEntity) GuardianEntity(net.minecraft.entity.monster.GuardianEntity) ElderGuardianEntity(net.minecraft.entity.monster.ElderGuardianEntity) MonsterEntity(net.minecraft.entity.monster.MonsterEntity) Vector3(com.integral.enigmaticlegacy.helpers.Vector3) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) EntityDamageSource(net.minecraft.util.EntityDamageSource) LivingEntity(net.minecraft.entity.LivingEntity) EndermanEntity(net.minecraft.entity.monster.EndermanEntity) ElderGuardianEntity(net.minecraft.entity.monster.ElderGuardianEntity) CreeperEntity(net.minecraft.entity.monster.CreeperEntity) DrownedEntity(net.minecraft.entity.monster.DrownedEntity) EffectInstance(net.minecraft.potion.EffectInstance) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with Vector3

use of com.integral.enigmaticlegacy.helpers.Vector3 in project Enigmatic-Legacy by Aizistral-Studios.

the class SuperpositionHandler method getObservedEntity.

/**
 * Gets the entity player is looking at.
 *
 * @param range Defines the size of bounding box checked for entities with each iteration.
 * Smaller box may provide more precise results, but is ineffective over large distances.
 * @param maxDist Maximum amount of iteration the method should trace for.
 * @return First entity found on the path, or null if none exist.
 */
@Nullable
public static LivingEntity getObservedEntity(final PlayerEntity player, final World world, final float range, final int maxDist) {
    LivingEntity newTarget = null;
    Vector3 target = Vector3.fromEntityCenter((Entity) player);
    List<LivingEntity> entities = new ArrayList<LivingEntity>();
    for (int distance = 1; entities.size() == 0 && distance < maxDist; ++distance) {
        target = target.add(new Vector3(player.getLookVec()).multiply((double) distance)).add(0.0, 0.5, 0.0);
        entities = (List<LivingEntity>) player.world.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(target.x - range, target.y - range, target.z - range, target.x + range, target.y + range, target.z + range));
        if (entities.contains(player)) {
            entities.remove(player);
        }
        for (final LivingEntity checked : entities) {
            if (!checked.isNonBoss()) {
                entities.remove(checked);
            }
        }
    }
    if (entities.size() > 0) {
        newTarget = entities.get(0);
    }
    return newTarget;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ArrayList(java.util.ArrayList) Vector3(com.integral.enigmaticlegacy.helpers.Vector3) Nullable(javax.annotation.Nullable)

Example 4 with Vector3

use of com.integral.enigmaticlegacy.helpers.Vector3 in project Enigmatic-Legacy by Aizistral-Studios.

the class EyeOfNebula method triggerActiveAbility.

public void triggerActiveAbility(World world, ServerPlayerEntity player, ItemStack stack) {
    if (SuperpositionHandler.hasSpellstoneCooldown(player))
        return;
    LivingEntity target = SuperpositionHandler.getObservedEntity(player, world, 3.0F, (int) ConfigHandler.EYE_OF_NEBULA_PHASE_RANGE.getValue());
    if (target != null) {
        Vector3 targetPos = Vector3.fromEntityCenter(target);
        Vector3 chaserPos = Vector3.fromEntityCenter(player);
        // Vector3 targetSight = new Vector3(target.getLookVec());
        Vector3 dir = targetPos.subtract(chaserPos);
        dir = dir.normalize();
        dir = dir.multiply(1.5D);
        dir = targetPos.add(dir);
        // player.
        world.playSound(null, player.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
        EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(player.posX, player.posY, player.posZ, 128, player.dimension)), new PacketPortalParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 72, 1.0F, false));
        player.setPositionAndUpdate(dir.x, target.posY + 0.25D, dir.z);
        EnigmaticLegacy.packetInstance.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new PacketPlayerSetlook(target.posX, target.posY - 1.0D + (target.getHeight() / 2), target.posZ));
        world.playSound(null, player.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
        EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(player.posX, player.posY, player.posZ, 128, player.dimension)), new PacketRecallParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 24, false));
        SuperpositionHandler.setSpellstoneCooldown(player, ConfigHandler.EYE_OF_NEBULA_COOLDOWN.getValue());
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) PacketPlayerSetlook(com.integral.enigmaticlegacy.packets.clients.PacketPlayerSetlook) PacketRecallParticles(com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles) Vector3(com.integral.enigmaticlegacy.helpers.Vector3) PacketPortalParticles(com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 5 with Vector3

use of com.integral.enigmaticlegacy.helpers.Vector3 in project Enigmatic-Legacy by Aizistral-Studios.

the class AngelBlessing method redirect.

public void redirect(LivingEntity bearer, Entity redirected) {
    if (redirected instanceof UltimateWitherSkullEntity || redirected instanceof WitherSkullEntity)
        return;
    /*if (redirected instanceof TridentEntity)
	 	 if (((TridentEntity)redirected).getShooter() == bearer)
	 		 return;*/
    Vector3 entityPos = Vector3.fromEntityCenter(redirected);
    Vector3 bearerPos = Vector3.fromEntityCenter(bearer);
    Vector3 redirection = entityPos.subtract(bearerPos);
    redirection = redirection.normalize();
    if (redirected instanceof AbstractArrowEntity && ((AbstractArrowEntity) redirected).getShooter() == bearer) {
        if (redirected instanceof TridentEntity) {
            TridentEntity trident = (TridentEntity) redirected;
            if (trident.returningTicks > 0)
                return;
        }
        redirected.setMotion(redirected.getMotion().x * 1.75D, redirected.getMotion().y * 1.75D, redirected.getMotion().z * 1.75D);
    } else
        redirected.setMotion(redirection.x, redirection.y, redirection.z);
    if (redirected instanceof DamagingProjectileEntity) {
        DamagingProjectileEntity redirectedProjectile = (DamagingProjectileEntity) redirected;
        redirectedProjectile.accelerationX = (redirection.x / 4.0);
        redirectedProjectile.accelerationY = (redirection.y / 4.0);
        redirectedProjectile.accelerationZ = (redirection.z / 4.0);
    }
}
Also used : UltimateWitherSkullEntity(com.integral.enigmaticlegacy.entities.UltimateWitherSkullEntity) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity) Vector3(com.integral.enigmaticlegacy.helpers.Vector3) TridentEntity(net.minecraft.entity.projectile.TridentEntity) UltimateWitherSkullEntity(com.integral.enigmaticlegacy.entities.UltimateWitherSkullEntity) WitherSkullEntity(net.minecraft.entity.projectile.WitherSkullEntity) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity)

Aggregations

Vector3 (com.integral.enigmaticlegacy.helpers.Vector3)10 LivingEntity (net.minecraft.entity.LivingEntity)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)3 UltimateWitherSkullEntity (com.integral.enigmaticlegacy.entities.UltimateWitherSkullEntity)2 ItemEntity (net.minecraft.entity.item.ItemEntity)2 AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)2 DamagingProjectileEntity (net.minecraft.entity.projectile.DamagingProjectileEntity)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 PermanentItemEntity (com.integral.enigmaticlegacy.entities.PermanentItemEntity)1 PacketPlayerMotion (com.integral.enigmaticlegacy.packets.clients.PacketPlayerMotion)1 PacketPlayerSetlook (com.integral.enigmaticlegacy.packets.clients.PacketPlayerSetlook)1 PacketPortalParticles (com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles)1 PacketRecallParticles (com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles)1 PacketWitherParticles (com.integral.enigmaticlegacy.packets.clients.PacketWitherParticles)1 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 Entity (net.minecraft.entity.Entity)1 EnderDragonEntity (net.minecraft.entity.boss.dragon.EnderDragonEntity)1 BlazeEntity (net.minecraft.entity.monster.BlazeEntity)1