Search in sources :

Example 1 with EntityGhastling

use of nex.entity.monster.EntityGhastling in project NetherEx by LogicTechCorp.

the class EventHandler method onLivingUpdate.

@SubscribeEvent
public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
    World world = event.getEntityLiving().getEntityWorld();
    BlockPos pos = new BlockPos(event.getEntityLiving());
    EntityLivingBase entity = event.getEntityLiving();
    boolean canFreeze = !(entity instanceof EntityPlayer) && !Arrays.asList(ConfigHandler.potionEffect.freeze.blacklist).contains(EntityList.getKey(entity).toString());
    if (world.getBiomeForCoordsBody(pos) == NetherExBiomes.ARCTIC_ABYSS) {
        if (canFreeze && !entity.isPotionActive(NetherExEffects.FREEZE) && world.rand.nextInt(ConfigHandler.biome.arcticAbyss.chanceOfFreezing) == 0) {
            entity.addPotionEffect(new PotionEffect(NetherExEffects.FREEZE, 300, 0));
        }
    }
    if (entity instanceof EntityLiving && canFreeze) {
        if (!entity.isPotionActive(NetherExEffects.FREEZE)) {
            if (((EntityLiving) entity).isAIDisabled()) {
                ((EntityLiving) entity).setNoAI(false);
                entity.setSilent(false);
            }
        } else {
            ((EntityLiving) entity).setNoAI(true);
            entity.setSilent(true);
            if (world.rand.nextInt(ConfigHandler.potionEffect.freeze.chanceOfThawing) == 0) {
                entity.removePotionEffect(NetherExEffects.FREEZE);
            }
        }
    }
    if (entity instanceof EntityPlayer && entity.isPotionActive(NetherExEffects.FREEZE)) {
        entity.setPosition(entity.prevPosX, entity.posY, entity.prevPosZ);
    }
    boolean canSpawnSpore = entity instanceof EntityPlayer || !Arrays.asList(ConfigHandler.potionEffect.spore.blacklist).contains(EntityList.getKey(entity).toString());
    if (canSpawnSpore && entity.isPotionActive(NetherExEffects.SPORE) && world.rand.nextInt(ConfigHandler.potionEffect.spore.chanceOfSporeSpawning) == 0) {
        if (world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos).expand(1, 1, 1)).size() < 3) {
            BlockPos newPos = pos.offset(EnumFacing.Plane.HORIZONTAL.random(world.rand));
            if (!world.isRemote && world.isAirBlock(newPos) && world.getBlockState(newPos.down()).isSideSolid(world, newPos.down(), EnumFacing.UP)) {
                EntitySpore spore = new EntitySpore(world, 0);
                spore.setPosition(newPos.getX(), newPos.getY(), newPos.getZ());
                world.spawnEntity(spore);
            }
        }
    }
    boolean canSpawnGhastling = entity instanceof EntityPlayer && world.provider.getDimension() == DimensionType.NETHER.getId();
    if (canSpawnGhastling && entity.isPotionActive(NetherExEffects.LOST) && world.rand.nextInt(ConfigHandler.potionEffect.lost.chanceOfGhastlingSpawning) == 0) {
        BlockPos newPos = pos.add(0, 5, 0).offset(entity.getHorizontalFacing().getOpposite(), 5);
        if (!world.isRemote && world.isAirBlock(newPos)) {
            EntityGhastling ghastling = new EntityGhastling(world);
            ghastling.setPosition(newPos.getX(), newPos.getY(), newPos.getZ());
            ghastling.setAttackTarget(entity);
            world.spawnEntity(ghastling);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntitySpore(nex.entity.monster.EntitySpore) EntityGhastling(nex.entity.monster.EntityGhastling) EntityLiving(net.minecraft.entity.EntityLiving) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with EntityGhastling

use of nex.entity.monster.EntityGhastling in project NetherEx by LogicTechCorp.

the class EntityGhastQueen method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (getCooldown() == 0) {
        if (tasks.taskEntries.size() == 2) {
            tasks.addTask(0, fireballAttack);
        }
        if (getStage() < 4) {
            if (!getStageStarted(getStage()) && getHealth() < getMaxHealth() - getStage() * 35.0D) {
                setShouldSpawnGhastlings(true);
            }
            if (!getEntityWorld().isRemote && shouldSpawnGhastlings()) {
                for (int i = 0; i < ConfigHandler.entity.ghastQueen.ghastlingSpawns; i++) {
                    EntityGhastling ghastling = new EntityGhastling(getEntityWorld());
                    ghastling.setPosition(getPosition().getX(), getPosition().getY() - 1, getPosition().getZ());
                    getEntityWorld().spawnEntity(ghastling);
                }
                setStageStarted(getStage(), true);
                setCooldown(ConfigHandler.entity.ghastQueen.ghastlingSpawnCooldown * 20);
                setStage(getStage() + 1);
                setShouldSpawnGhastlings(false);
            }
        }
    } else {
        if (tasks.taskEntries.size() == 3) {
            tasks.removeTask(fireballAttack);
        }
        setCooldown(getCooldown() - 1);
    }
    bossInfo.setPercent(getHealth() / getMaxHealth());
}
Also used : EntityGhastling(nex.entity.monster.EntityGhastling)

Aggregations

EntityGhastling (nex.entity.monster.EntityGhastling)2 EntityLiving (net.minecraft.entity.EntityLiving)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 PotionEffect (net.minecraft.potion.PotionEffect)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 EntitySpore (nex.entity.monster.EntitySpore)1