Search in sources :

Example 1 with EndermanEntity

use of net.minecraft.entity.monster.EndermanEntity 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 2 with EndermanEntity

use of net.minecraft.entity.monster.EndermanEntity in project Arclight by IzzelAliz.

the class EntityTeleportEventDispatcher method onTeleport.

@SubscribeEvent(receiveCanceled = true)
public void onTeleport(EnderTeleportEvent event) {
    if (!(event.getEntity() instanceof EndermanEntity)) {
        if (event.getEntity() instanceof ServerPlayerEntity) {
            CraftPlayer player = ((ServerPlayerEntityBridge) event.getEntity()).bridge$getBukkitEntity();
            PlayerTeleportEvent bukkitEvent = new PlayerTeleportEvent(player, player.getLocation(), new Location(player.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()), PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
            Bukkit.getPluginManager().callEvent(bukkitEvent);
            event.setCanceled(bukkitEvent.isCancelled());
            event.setTargetX(bukkitEvent.getTo().getX());
            event.setTargetY(bukkitEvent.getTo().getY());
            event.setTargetZ(bukkitEvent.getTo().getZ());
        } else {
            CraftEntity entity = ((EntityBridge) event.getEntity()).bridge$getBukkitEntity();
            EntityTeleportEvent bukkitEvent = new EntityTeleportEvent(entity, entity.getLocation(), new Location(entity.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()));
            Bukkit.getPluginManager().callEvent(bukkitEvent);
            event.setCanceled(bukkitEvent.isCancelled());
            event.setTargetX(bukkitEvent.getTo().getX());
            event.setTargetY(bukkitEvent.getTo().getY());
            event.setTargetZ(bukkitEvent.getTo().getZ());
        }
    }
}
Also used : EndermanEntity(net.minecraft.entity.monster.EndermanEntity) PlayerTeleportEvent(org.bukkit.event.player.PlayerTeleportEvent) CraftEntity(org.bukkit.craftbukkit.v.entity.CraftEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) CraftPlayer(org.bukkit.craftbukkit.v.entity.CraftPlayer) EntityBridge(io.izzel.arclight.common.bridge.entity.EntityBridge) ServerPlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge) EntityTeleportEvent(org.bukkit.event.entity.EntityTeleportEvent) ServerPlayerEntityBridge(io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge) Location(org.bukkit.Location) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with EndermanEntity

use of net.minecraft.entity.monster.EndermanEntity in project Champions by TheIllusiveC4.

the class InfestedAffix method spawnParasites.

private static void spawnParasites(LivingEntity livingEntity, int amount, @Nullable LivingEntity target, ServerWorld world) {
    boolean isEnder = livingEntity instanceof EndermanEntity || livingEntity instanceof ShulkerEntity || livingEntity instanceof EndermiteEntity || livingEntity instanceof EnderDragonEntity;
    EntityType<?> type = isEnder ? ChampionsConfig.infestedEnderParasite : ChampionsConfig.infestedParasite;
    for (int i = 0; i < amount; i++) {
        Entity entity = type.create(world, null, null, null, livingEntity.getPosition(), SpawnReason.MOB_SUMMONED, false, false);
        if (entity instanceof LivingEntity) {
            ChampionCapability.getCapability((LivingEntity) entity).ifPresent(champion -> champion.getServer().setRank(RankManager.getLowestRank()));
            livingEntity.getEntityWorld().addEntity(entity);
            if (entity instanceof MobEntity) {
                ((MobEntity) entity).spawnExplosionParticle();
                ((MobEntity) entity).setRevengeTarget(target);
                ((MobEntity) entity).setAttackTarget(target);
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) EndermanEntity(net.minecraft.entity.monster.EndermanEntity) MobEntity(net.minecraft.entity.MobEntity) ShulkerEntity(net.minecraft.entity.monster.ShulkerEntity) EndermiteEntity(net.minecraft.entity.monster.EndermiteEntity) Entity(net.minecraft.entity.Entity) LivingEntity(net.minecraft.entity.LivingEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) EnderDragonEntity(net.minecraft.entity.boss.dragon.EnderDragonEntity) EndermanEntity(net.minecraft.entity.monster.EndermanEntity) EndermiteEntity(net.minecraft.entity.monster.EndermiteEntity) ShulkerEntity(net.minecraft.entity.monster.ShulkerEntity) MobEntity(net.minecraft.entity.MobEntity)

Aggregations

EndermanEntity (net.minecraft.entity.monster.EndermanEntity)3 Entity (net.minecraft.entity.Entity)2 LivingEntity (net.minecraft.entity.LivingEntity)2 EnderDragonEntity (net.minecraft.entity.boss.dragon.EnderDragonEntity)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 PermanentItemEntity (com.integral.enigmaticlegacy.entities.PermanentItemEntity)1 Vector3 (com.integral.enigmaticlegacy.helpers.Vector3)1 EntityBridge (io.izzel.arclight.common.bridge.entity.EntityBridge)1 ServerPlayerEntityBridge (io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge)1 MobEntity (net.minecraft.entity.MobEntity)1 ItemEntity (net.minecraft.entity.item.ItemEntity)1 BlazeEntity (net.minecraft.entity.monster.BlazeEntity)1 CreeperEntity (net.minecraft.entity.monster.CreeperEntity)1 DrownedEntity (net.minecraft.entity.monster.DrownedEntity)1 ElderGuardianEntity (net.minecraft.entity.monster.ElderGuardianEntity)1 EndermiteEntity (net.minecraft.entity.monster.EndermiteEntity)1 GuardianEntity (net.minecraft.entity.monster.GuardianEntity)1 MonsterEntity (net.minecraft.entity.monster.MonsterEntity)1 ShulkerEntity (net.minecraft.entity.monster.ShulkerEntity)1