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()));
}
}
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));
}
}
}
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;
}
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());
}
}
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);
}
}
Aggregations