use of net.minecraft.entity.projectile.DamagingProjectileEntity in project Enigmatic-Legacy by Aizistral-Studios.
the class EnigmaticEventHandler method onEntityAttacked.
@SubscribeEvent
public void onEntityAttacked(LivingAttackEvent event) {
if (event.getEntityLiving().world.isRemote)
return;
if (event.getEntityLiving() instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
if (EtheriumArmor.hasShield(player)) {
if (event.getSource().getImmediateSource() instanceof DamagingProjectileEntity || event.getSource().getImmediateSource() instanceof AbstractArrowEntity) {
event.setCanceled(true);
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));
}
}
if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.enigmaticItem))
if (EnigmaticItem.immunityList.contains(event.getSource().damageType))
event.setCanceled(true);
if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.angelBlessing))
if (AngelBlessing.immunityList.contains(event.getSource().damageType))
event.setCanceled(true);
if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.oceanStone))
if (OceanStone.immunityList.contains(event.getSource().damageType))
event.setCanceled(true);
if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.magmaHeart))
if (MagmaHeart.immunityList.contains(event.getSource().damageType))
event.setCanceled(true);
if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.golemHeart))
if (GolemHeart.immunityList.contains(event.getSource().damageType))
event.setCanceled(true);
if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.voidPearl)) {
if (VoidPearl.immunityList.contains(event.getSource().damageType))
event.setCanceled(true);
else if (VoidPearl.healList.contains(event.getSource().damageType)) {
player.heal(event.getAmount());
event.setCanceled(true);
} else {
}
}
if (SuperpositionHandler.hasCurio(player, EnigmaticLegacy.eyeOfNebula)) {
if (EyeOfNebula.immunityList.contains(event.getSource().damageType)) {
event.setCanceled(true);
} else if (Math.random() <= ConfigHandler.EYE_OF_NEBULA_DODGE_PROBABILITY.getValue().asMultiplier(false) && player.hurtResistantTime <= 10 && event.getSource().getTrueSource() instanceof LivingEntity) {
for (int counter = 0; counter <= 32; counter++) {
if (SuperpositionHandler.validTeleportRandomly(player, player.world, (int) ConfigHandler.EYE_OF_NEBULA_DODGE_RANGE.getValue()))
break;
}
player.hurtResistantTime = 20;
event.setCanceled(true);
}
}
} else if (event.getSource().getImmediateSource() instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) event.getSource().getImmediateSource();
if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == EnigmaticLegacy.extradimensionalEye)
if (ItemNBTHelper.verifyExistance(player.getHeldItemMainhand(), "BoundDimension"))
if (ItemNBTHelper.getInt(player.getHeldItemMainhand(), "BoundDimension", 0) == event.getEntityLiving().dimension.getId()) {
event.setCanceled(true);
ItemStack stack = player.getHeldItemMainhand();
EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, 128, event.getEntityLiving().dimension)), new PacketPortalParticles(event.getEntityLiving().posX, event.getEntityLiving().posY + (event.getEntityLiving().getHeight() / 2), event.getEntityLiving().posZ, 96, 1.5D, false));
event.getEntityLiving().world.playSound(null, event.getEntityLiving().getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2)));
event.getEntityLiving().setPositionAndUpdate(ItemNBTHelper.getDouble(stack, "BoundX", 0D), ItemNBTHelper.getDouble(stack, "BoundY", 0D), ItemNBTHelper.getDouble(stack, "BoundZ", 0D));
event.getEntityLiving().world.playSound(null, event.getEntityLiving().getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2)));
EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, 128, event.getEntityLiving().dimension)), new PacketRecallParticles(event.getEntityLiving().posX, event.getEntityLiving().posY + (event.getEntityLiving().getHeight() / 2), event.getEntityLiving().posZ, 48, false));
if (!player.abilities.isCreativeMode)
stack.shrink(1);
}
}
}
use of net.minecraft.entity.projectile.DamagingProjectileEntity 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);
}
}
use of net.minecraft.entity.projectile.DamagingProjectileEntity in project Enigmatic-Legacy by Aizistral-Studios.
the class AngelBlessing method onCurioTick.
@Override
public void onCurioTick(String identifier, LivingEntity living) {
List<DamagingProjectileEntity> projectileEntities = living.world.getEntitiesWithinAABB(DamagingProjectileEntity.class, new AxisAlignedBB(living.posX - range, living.posY - range, living.posZ - range, living.posX + range, living.posY + range, living.posZ + range));
List<AbstractArrowEntity> arrowEntities = living.world.getEntitiesWithinAABB(AbstractArrowEntity.class, new AxisAlignedBB(living.posX - range, living.posY - range, living.posZ - range, living.posX + range, living.posY + range, living.posZ + range));
List<PotionEntity> potionEntities = living.world.getEntitiesWithinAABB(PotionEntity.class, new AxisAlignedBB(living.posX - range, living.posY - range, living.posZ - range, living.posX + range, living.posY + range, living.posZ + range));
for (DamagingProjectileEntity entity : projectileEntities) this.redirect(living, entity);
for (AbstractArrowEntity entity : arrowEntities) this.redirect(living, entity);
for (PotionEntity entity : potionEntities) this.redirect(living, entity);
}
use of net.minecraft.entity.projectile.DamagingProjectileEntity in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityAIFireball method start.
@Override
public void start() {
super.start();
this.cooldown = 140;
this.entity.getMainHandItem().shrink(1);
Vector3d v = this.entity.getTarget().position().subtract(this.entity.position());
DamagingProjectileEntity fireball = this.entity.getRandom().nextDouble() > 0.7 ? new FireballEntity(this.entity.level, this.entity, v.x, v.y, v.z) : new SmallFireballEntity(this.entity.level, this.entity, v.x, v.y, v.z);
this.entity.level.addFreshEntity(fireball);
}
use of net.minecraft.entity.projectile.DamagingProjectileEntity in project BudschieMorphMod by Budschie.
the class ProjectileShootingAbility method onUsedAbility.
@Override
public void onUsedAbility(PlayerEntity player, MorphItem currentMorph) {
if (!isCurrentlyStunned(player.getUniqueID())) {
// Entity createdEntity = projectileSupplier.apply(player, Vector3d.fromPitchYaw(player.getPitchYaw()));
Entity createdEntity = projectileEntityType.create(player.getEntityWorld());
createdEntity.read(nbtData);
Vector3d dir = Vector3d.fromPitchYaw(player.getPitchYaw());
createdEntity.setMotion(dir.x * motion, dir.y * motion, dir.z * motion);
createdEntity.setPosition(player.getPosX(), player.getPosY() + player.getEyeHeight(), player.getPosZ());
if (createdEntity instanceof ProjectileEntity) {
ProjectileEntity proj = (ProjectileEntity) createdEntity;
proj.setShooter(player);
}
if (createdEntity instanceof DamagingProjectileEntity) {
DamagingProjectileEntity dmgProjectile = (DamagingProjectileEntity) createdEntity;
dmgProjectile.accelerationX = dir.x * acceleration;
dmgProjectile.accelerationY = dir.y * acceleration;
dmgProjectile.accelerationZ = dir.z * acceleration;
}
player.world.addEntity(createdEntity);
stun(player.getUniqueID());
if (this.soundInstance.isPresent())
this.soundInstance.get().playSoundAt(player);
}
}
Aggregations