Search in sources :

Example 1 with PhantomEntity

use of net.minecraft.entity.monster.PhantomEntity 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 PhantomEntity

use of net.minecraft.entity.monster.PhantomEntity in project Hostile-Mobs-and-Girls by Mechalopa.

the class DyssomniaEntity method summonPhantom.

private void summonPhantom(ServerWorld serverworld, LivingEntity attacker, LivingEntity target, Random random, int count) {
    boolean flag = false;
    for (int i = 0; i < count; ++i) {
        double d1 = attacker.getX() + (random.nextDouble() - random.nextDouble()) * 3.0D;
        double d2 = attacker.getY() + 0.5D;
        double d3 = attacker.getZ() + (random.nextDouble() - random.nextDouble()) * 3.0D;
        PhantomEntity phantomentity = EntityType.PHANTOM.create(attacker.level);
        phantomentity.moveTo(d1, d2, d3, this.yRot + (random.nextFloat() - 0.5F) * 12.0F, 0.0F);
        phantomentity.finalizeSpawn(serverworld, attacker.level.getCurrentDifficultyAt(attacker.blockPosition()), SpawnReason.MOB_SUMMONED, (ILivingEntityData) null, (CompoundNBT) null);
        serverworld.addFreshEntityWithPassengers(phantomentity);
        phantomentity.getPersistentData().putBoolean(ModUtils.WITH_SPAWN_PARTICLE_KEY, true);
        if (this.isOnFire()) {
            phantomentity.setSecondsOnFire(this.getRemainingFireTicks() / 20 + 2);
            flag = true;
        }
    }
    if (flag) {
        this.clearFire();
    }
    attacker.level.levelEvent(2004, attacker.blockPosition(), 0);
    attacker.playSound(ModSoundEvents.DYSSOMNIA_SUMMON.get(), 5.0F, 1.0F);
}
Also used : PhantomEntity(net.minecraft.entity.monster.PhantomEntity)

Example 3 with PhantomEntity

use of net.minecraft.entity.monster.PhantomEntity in project AstralSorcery by HellFirePvP.

the class EntityFlare method tick.

@Override
public void tick() {
    super.tick();
    this.entityAge++;
    if (this.getEntityWorld().isRemote()) {
        this.tickClient();
    } else {
        if (this.isAmbient() && this.entityAge > 600 && rand.nextInt(600) == 0) {
            DamageUtil.attackEntityFrom(this, CommonProxy.DAMAGE_SOURCE_STELLAR, 1F);
        }
        if (this.isAlive()) {
            if (EntityConfig.CONFIG.flareAttackBats.get() && rand.nextInt(30) == 0) {
                BatEntity closest = EntityUtils.getClosestEntity(this.getEntityWorld(), BatEntity.class, this.getBoundingBox().grow(10), Vector3.atEntityCenter(this));
                if (closest != null) {
                    this.doLightningAttack(closest, 100F);
                }
            }
            if (EntityConfig.CONFIG.flareAttackPhantoms.get() && rand.nextInt(30) == 0) {
                PhantomEntity closest = EntityUtils.getClosestEntity(this.getEntityWorld(), PhantomEntity.class, this.getBoundingBox().grow(10), Vector3.atEntityCenter(this));
                if (closest != null) {
                    this.doLightningAttack(closest, 100F);
                }
            }
            if (this.isAmbient()) {
                boolean atTarget = this.currentMoveTarget == null || this.currentMoveTarget.distance(this) < 5.0;
                if (atTarget) {
                    this.currentMoveTarget = null;
                }
                if (this.currentMoveTarget == null && rand.nextInt(150) == 0) {
                    BlockPos newTarget = this.getPosition().add(rand.nextInt(RANDOM_WANDER_RANGE) * (rand.nextBoolean() ? 1 : -1), rand.nextInt(RANDOM_WANDER_RANGE) * (rand.nextBoolean() ? 1 : -1), rand.nextInt(RANDOM_WANDER_RANGE) * (rand.nextBoolean() ? 1 : -1));
                    if (newTarget.getY() > 1 && newTarget.getY() < 254 && new Vector3(newTarget).distance(this) >= 5.0) {
                        MiscUtils.executeWithChunk(this.getEntityWorld(), newTarget, () -> {
                            this.currentMoveTarget = new Vector3(newTarget);
                        });
                    }
                }
            } else if (this.getAttackTarget() != null) {
                if (!this.getAttackTarget().isAlive() || (this.getFollowingTarget() != null && this.getFollowingTarget().getDistance(this) > 30.0F)) {
                    this.setAttackTarget(null);
                } else {
                    Vector3 newTarget = Vector3.atEntityCenter(this.getAttackTarget()).addY(1.5F);
                    if (newTarget.getY() > 1 && newTarget.getY() < 254 && newTarget.distance(this) >= 3.0) {
                        this.currentMoveTarget = newTarget;
                    } else {
                        this.currentMoveTarget = null;
                    }
                }
            } else if (this.followingEntityId != -1) {
                LivingEntity following = this.getFollowingTarget();
                if (following == null) {
                    DamageUtil.attackEntityFrom(this, CommonProxy.DAMAGE_SOURCE_STELLAR, 1F);
                } else {
                    MantleEffectBootes effect = ItemMantle.getEffect(following, ConstellationsAS.bootes);
                    if (effect == null) {
                        DamageUtil.attackEntityFrom(this, CommonProxy.DAMAGE_SOURCE_STELLAR, 1F);
                        return;
                    }
                    if (this.getAttackTarget() != null && !this.getAttackTarget().isAlive()) {
                        this.setAttackTarget(null);
                    }
                    if (this.getAttackTarget() == null) {
                        Vector3 newTarget = Vector3.atEntityCenter(following).addY(2.5F);
                        if (newTarget.distance(this) >= 2.0) {
                            this.currentMoveTarget = newTarget;
                        } else {
                            this.currentMoveTarget = null;
                        }
                    }
                }
            } else {
                DamageUtil.attackEntityFrom(this, CommonProxy.DAMAGE_SOURCE_STELLAR, 1F);
                return;
            }
            LivingEntity target = this.getAttackTarget();
            if (target != null && target.isAlive() && target.getDistance(this) < 10 && rand.nextInt(40) == 0) {
                DamageUtil.shotgunAttack(target, e -> this.doLightningAttack(e, 2F + rand.nextFloat() * 2F));
            }
            this.doMovement();
        }
    }
}
Also used : MantleEffectBootes(hellfirepvp.astralsorcery.common.constellation.mantle.effect.MantleEffectBootes) PhantomEntity(net.minecraft.entity.monster.PhantomEntity) BatEntity(net.minecraft.entity.passive.BatEntity) BlockPos(net.minecraft.util.math.BlockPos) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3)

Example 4 with PhantomEntity

use of net.minecraft.entity.monster.PhantomEntity 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)

Example 5 with PhantomEntity

use of net.minecraft.entity.monster.PhantomEntity in project upgrade-aquatic by team-abnormals.

the class EntityEvents method onEntityUpdate.

@SubscribeEvent
public static void onEntityUpdate(LivingUpdateEvent event) {
    LivingEntity entity = event.getEntityLiving();
    if (entity instanceof PhantomEntity) {
        if (((PhantomEntity) entity).getAttackTarget() instanceof ServerPlayerEntity) {
            ServerPlayerEntity playerMP = (ServerPlayerEntity) ((PhantomEntity) entity).getAttackTarget();
            StatisticsManager statisticsManager = playerMP.getStats();
            if (statisticsManager.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)) < 72000) {
                ((PhantomEntity) entity).setAttackTarget(null);
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) PhantomEntity(net.minecraft.entity.monster.PhantomEntity) StatisticsManager(net.minecraft.stats.StatisticsManager) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

PhantomEntity (net.minecraft.entity.monster.PhantomEntity)5 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)3 StatisticsManager (net.minecraft.stats.StatisticsManager)3 FlareEntity (com.minecraftabnormals.upgrade_aquatic.common.entities.FlareEntity)2 MantleEffectBootes (hellfirepvp.astralsorcery.common.constellation.mantle.effect.MantleEffectBootes)1 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)1 LivingEntity (net.minecraft.entity.LivingEntity)1 MobEntity (net.minecraft.entity.MobEntity)1 BatEntity (net.minecraft.entity.passive.BatEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1