Search in sources :

Example 1 with FlareEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.FlareEntity in project upgrade-aquatic by team-abnormals.

the class RestfulnessEffect method performEffect.

@Override
public void performEffect(LivingEntity entity, int amplifier) {
    if (entity instanceof ServerPlayerEntity) {
        ServerPlayerEntity playerMP = (ServerPlayerEntity) entity;
        StatisticsManager statisticsManager = playerMP.getStats();
        statisticsManager.increment(playerMP, Stats.CUSTOM.get(Stats.TIME_SINCE_REST), -(24000 * (amplifier + 1)));
    } else if (entity instanceof PhantomEntity) {
        entity.attackEntityFrom(DamageSource.MAGIC, Float.MAX_VALUE);
    } else if (entity instanceof FlareEntity) {
        PhantomEntity phantom = EntityType.PHANTOM.create(entity.world);
        phantom.setLocationAndAngles(entity.getPosX(), entity.getPosY(), entity.getPosZ(), entity.rotationYaw, entity.rotationPitch);
        phantom.setNoAI(((MobEntity) entity).isAIDisabled());
        if (entity.hasCustomName()) {
            phantom.setCustomName(entity.getCustomName());
            phantom.setCustomNameVisible(entity.isCustomNameVisible());
        }
        phantom.setHealth(entity.getHealth());
        if (phantom.getHealth() > 0) {
            entity.world.addEntity(phantom);
            entity.remove(true);
        }
        entity.remove(true);
    }
}
Also used : FlareEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.FlareEntity) PhantomEntity(net.minecraft.entity.monster.PhantomEntity) StatisticsManager(net.minecraft.stats.StatisticsManager) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 2 with FlareEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.FlareEntity in project upgrade-aquatic by team-abnormals.

the class InsomniaEffect method performEffect.

@Override
public void performEffect(LivingEntity entity, int amplifier) {
    if (entity instanceof ServerPlayerEntity) {
        ServerPlayerEntity playerMP = (ServerPlayerEntity) entity;
        StatisticsManager statisticsManager = playerMP.getStats();
        statisticsManager.increment(playerMP, Stats.CUSTOM.get(Stats.TIME_SINCE_REST), (24000 * (amplifier + 1)));
    } else if (entity instanceof PhantomEntity) {
        FlareEntity flare = UAEntities.FLARE.get().create(entity.world);
        flare.setLocationAndAngles(entity.getPosX(), entity.getPosY(), entity.getPosZ(), entity.rotationYaw, entity.rotationPitch);
        flare.setNoAI(((MobEntity) entity).isAIDisabled());
        if (entity.hasCustomName()) {
            flare.setCustomName(entity.getCustomName());
            flare.setCustomNameVisible(entity.isCustomNameVisible());
        }
        flare.setHealth(entity.getHealth());
        if (flare.getHealth() > 0) {
            entity.world.addEntity(flare);
            entity.remove(true);
        }
        PlayerEntity player = entity.getEntityWorld().getClosestPlayer(entity, 11);
        if (player instanceof ServerPlayerEntity && player.isAlive()) {
            ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
            if (!entity.world.isRemote()) {
                UACriteriaTriggers.CONVERT_PHANTOM.trigger(serverPlayer);
            }
        }
    } else if (entity instanceof FlareEntity) {
        entity.attackEntityFrom(DamageSource.MAGIC, Float.MAX_VALUE);
    }
}
Also used : FlareEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.FlareEntity) PhantomEntity(net.minecraft.entity.monster.PhantomEntity) StatisticsManager(net.minecraft.stats.StatisticsManager) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) MobEntity(net.minecraft.entity.MobEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Aggregations

FlareEntity (com.minecraftabnormals.upgrade_aquatic.common.entities.FlareEntity)2 PhantomEntity (net.minecraft.entity.monster.PhantomEntity)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 StatisticsManager (net.minecraft.stats.StatisticsManager)2 MobEntity (net.minecraft.entity.MobEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1