Search in sources :

Example 1 with DamagingProjectileEntity

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);
                }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) PacketDistributor(net.minecraftforge.fml.network.PacketDistributor) PacketRecallParticles(com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity) PacketPortalParticles(com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles) ItemStack(net.minecraft.item.ItemStack) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with DamagingProjectileEntity

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

Example 3 with DamagingProjectileEntity

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);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity) PotionEntity(net.minecraft.entity.projectile.PotionEntity) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity)

Example 4 with DamagingProjectileEntity

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);
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity) SmallFireballEntity(net.minecraft.entity.projectile.SmallFireballEntity) SmallFireballEntity(net.minecraft.entity.projectile.SmallFireballEntity) FireballEntity(net.minecraft.entity.projectile.FireballEntity)

Example 5 with DamagingProjectileEntity

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);
    }
}
Also used : Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) Vector3d(net.minecraft.util.math.vector.Vector3d) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity)

Aggregations

DamagingProjectileEntity (net.minecraft.entity.projectile.DamagingProjectileEntity)5 AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2 UltimateWitherSkullEntity (com.integral.enigmaticlegacy.entities.UltimateWitherSkullEntity)1 Vector3 (com.integral.enigmaticlegacy.helpers.Vector3)1 PacketPortalParticles (com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles)1 PacketRecallParticles (com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles)1 Entity (net.minecraft.entity.Entity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 FireballEntity (net.minecraft.entity.projectile.FireballEntity)1 PotionEntity (net.minecraft.entity.projectile.PotionEntity)1 ProjectileEntity (net.minecraft.entity.projectile.ProjectileEntity)1 SmallFireballEntity (net.minecraft.entity.projectile.SmallFireballEntity)1 TridentEntity (net.minecraft.entity.projectile.TridentEntity)1 WitherSkullEntity (net.minecraft.entity.projectile.WitherSkullEntity)1 ItemStack (net.minecraft.item.ItemStack)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1