Search in sources :

Example 1 with EntityNibiruLightningBolt

use of stevekung.mods.moreplanets.planets.nibiru.entity.weather.EntityNibiruLightningBolt in project MorePlanets by SteveKunG.

the class WorldTickEventHandler method onWeatherTick.

@SubscribeEvent
public void onWeatherTick(WeatherTickEvent event) {
    World world = event.getWorld();
    BlockPos pos = event.getStrikePos();
    if (DimensionManager.getWorld(ConfigManagerMP.moreplanets_dimension.idDimensionDiona) != null) {
        if (world.provider instanceof WorldProviderDiona) {
            if (this.canBeamStrike(world, pos) && world.rand.nextInt(75000) == 0) {
                if (world.isBlockLoaded(pos)) {
                    EntityAlienBeam beam = new EntityAlienBeam(world, pos.getX(), pos.getY(), pos.getZ());
                    beam.spawnWeather();
                }
            }
        }
    }
    if (DimensionManager.getWorld(ConfigManagerMP.moreplanets_dimension.idDimensionNibiru) != null) {
        if (world.provider instanceof WorldProviderNibiru) {
            boolean raining = world.isRaining();
            boolean thunder = world.isThundering();
            Biome biome = world.getBiome(pos);
            if (world.provider.canDoLightning(event.getChunk()) && raining && thunder && world.rand.nextInt(1000) == 0) {
                if (world.isRainingAt(pos)) {
                    EntityNibiruLightningBolt boltFire = new EntityNibiruLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), true);
                    boltFire.spawnWeather();
                }
            }
            if (world.rand.nextInt(16) == 0) {
                BlockPos pos1 = pos.down();
                if (world.isAreaLoaded(pos1, 1)) {
                    if (world.canBlockFreezeNoWater(pos1)) {
                        world.setBlockState(pos1, MPBlocks.INFECTED_ICE.getDefaultState());
                    }
                }
                if (raining) {
                    if (world.canSnowAt(pos, true)) {
                        world.setBlockState(pos, biome == MPBiomes.COLD_GREEN_VEIN_MOUTAINS ? MPBlocks.PURIFIED_SNOW_LAYER.getDefaultState() : MPBlocks.INFECTED_SNOW_LAYER.getDefaultState());
                    }
                    if (world.getBiome(pos1).canRain()) {
                        world.getBlockState(pos1).getBlock().fillWithRain(world, pos1);
                    }
                }
            }
            if (biome instanceof BiomeInfectedDesert || biome instanceof BiomeInfectedMountains || biome instanceof BiomeInfectedBadlands) {
                if (world.rand.nextInt(250000) == 0) {
                    EntityNibiruLightningBolt bolt = new EntityNibiruLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), false);
                    bolt.spawnWeather();
                }
            }
        }
    }
}
Also used : BiomeInfectedMountains(stevekung.mods.moreplanets.planets.nibiru.world.gen.biome.BiomeInfectedMountains) WorldProviderDiona(stevekung.mods.moreplanets.planets.diona.dimension.WorldProviderDiona) Biome(net.minecraft.world.biome.Biome) WorldProviderNibiru(stevekung.mods.moreplanets.planets.nibiru.dimension.WorldProviderNibiru) BiomeInfectedDesert(stevekung.mods.moreplanets.planets.nibiru.world.gen.biome.BiomeInfectedDesert) BlockPos(net.minecraft.util.math.BlockPos) EntityAlienBeam(stevekung.mods.moreplanets.planets.diona.entity.EntityAlienBeam) EntityNibiruLightningBolt(stevekung.mods.moreplanets.planets.nibiru.entity.weather.EntityNibiruLightningBolt) World(net.minecraft.world.World) BiomeInfectedBadlands(stevekung.mods.moreplanets.planets.nibiru.world.gen.biome.BiomeInfectedBadlands) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with EntityNibiruLightningBolt

use of stevekung.mods.moreplanets.planets.nibiru.entity.weather.EntityNibiruLightningBolt in project MorePlanets by SteveKunG.

the class EntityVeinFloater method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    this.motionY *= 0.5D;
    if (this.getHealth() <= 0.0F) {
        GalacticraftCore.packetPipeline.sendToServer(new PacketSimpleMP(EnumSimplePacketMP.S_UPDATE_NIBIRU_WEATHER, GCCoreUtil.getDimensionID(this.world), new Object[] { false }));
        this.dataManager.set(VINE_PULL, false);
        return;
    }
    int tick = this.ticksExisted;
    tick %= 600;
    if (this.getHealth() <= this.getMaxHealth() / 3) {
        GalacticraftCore.packetPipeline.sendToServer(new PacketSimpleMP(EnumSimplePacketMP.S_UPDATE_NIBIRU_WEATHER, GCCoreUtil.getDimensionID(this.world), new Object[] { true }));
        if (this.rand.nextFloat() > 0.975F && !this.isDead) {
            EntityPlayer player = this.world.getClosestPlayer(this.posX, this.posY, this.posZ, 32, false);
            if (player != null && !player.capabilities.isCreativeMode && !player.isDead) {
                EntityNibiruLightningBolt bolt = new EntityNibiruLightningBolt(this.world);
                bolt.setLocationAndAngles(player.posX, player.posY, player.posZ, 0.0F, 0.0F);
                this.world.spawnEntity(bolt);
            }
        }
    } else if (this.getHealth() <= this.getMaxHealth() / 2) {
        if (!this.isDead) {
            if (tick > 300) {
                this.dataManager.set(VINE_PULL, true);
            } else {
                this.dataManager.set(VINE_PULL, false);
            }
        }
    } else {
        this.dataManager.set(VINE_PULL, false);
        if (!this.world.isRemote && this.ticksExisted % 200 == 0) {
            List<EntityVeinFloaterMinion> minionList = this.world.getEntitiesWithinAABB(EntityVeinFloaterMinion.class, new AxisAlignedBB(this.posX - 32, this.posY - 32, this.posZ - 32, this.posX + 32, this.posY + 32, this.posZ + 32));
            if (minionList.size() <= 32) {
                EntityVeinFloaterMinion tentacle1 = new EntityVeinFloaterMinion(this.world);
                tentacle1.setLocationAndAngles(this.posX + 2.0F, this.posY + 12.0F, this.posZ + 2.0F, 0.0F, 0.0F);
                tentacle1.setAbsorptionAmount(20.0F);
                this.world.spawnEntity(tentacle1);
                EntityVeinFloaterMinion tentacle2 = new EntityVeinFloaterMinion(this.world);
                tentacle2.setLocationAndAngles(this.posX - 2.0F, this.posY + 12.0F, this.posZ - 2.0F, 0.0F, 0.0F);
                tentacle2.setAbsorptionAmount(20.0F);
                this.world.spawnEntity(tentacle2);
                EntityVeinFloaterMinion tentacle3 = new EntityVeinFloaterMinion(this.world);
                tentacle3.setLocationAndAngles(this.posX + 2.0F, this.posY + 12.0F, this.posZ - 2.0F, 0.0F, 0.0F);
                tentacle3.setAbsorptionAmount(20.0F);
                this.world.spawnEntity(tentacle3);
                EntityVeinFloaterMinion tentacle4 = new EntityVeinFloaterMinion(this.world);
                tentacle4.setLocationAndAngles(this.posX - 2.0F, this.posY + 12.0F, this.posZ + 2.0F, 0.0F, 0.0F);
                tentacle4.setAbsorptionAmount(20.0F);
                this.world.spawnEntity(tentacle4);
            }
        }
    }
    if (this.getVinePull()) {
        int range = 16;
        List<EntityPlayer> entitiesAroundBH = this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(this.posX - range, this.posY - range, this.posZ - range, this.posX + range, this.posY + range, this.posZ + range));
        for (EntityPlayer entity : entitiesAroundBH) {
            if (!entity.capabilities.isCreativeMode) {
                double motionX = this.posX - entity.posX;
                double motionY = this.posY - entity.posY + 12.0D;
                double motionZ = this.posZ - entity.posZ;
                entity.motionX = motionX * 0.025F;
                entity.motionY = motionY * 0.025F;
                entity.motionZ = motionZ * 0.025F;
                this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(this.posX - 1.0D, this.posY - 1.0D, this.posZ - 1.0D, this.posX + 5.0D, this.posY + 12.5D, this.posZ + 5.0D)).forEach(near -> near.attackEntityFrom(DamageSource.causeMobDamage(this), 8.0F));
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP) List(java.util.List) EntityNibiruLightningBolt(stevekung.mods.moreplanets.planets.nibiru.entity.weather.EntityNibiruLightningBolt) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)

Aggregations

EntityNibiruLightningBolt (stevekung.mods.moreplanets.planets.nibiru.entity.weather.EntityNibiruLightningBolt)2 List (java.util.List)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 Biome (net.minecraft.world.biome.Biome)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)1 PacketSimpleMP (stevekung.mods.moreplanets.network.PacketSimpleMP)1 WorldProviderDiona (stevekung.mods.moreplanets.planets.diona.dimension.WorldProviderDiona)1 EntityAlienBeam (stevekung.mods.moreplanets.planets.diona.entity.EntityAlienBeam)1 WorldProviderNibiru (stevekung.mods.moreplanets.planets.nibiru.dimension.WorldProviderNibiru)1 BiomeInfectedBadlands (stevekung.mods.moreplanets.planets.nibiru.world.gen.biome.BiomeInfectedBadlands)1 BiomeInfectedDesert (stevekung.mods.moreplanets.planets.nibiru.world.gen.biome.BiomeInfectedDesert)1 BiomeInfectedMountains (stevekung.mods.moreplanets.planets.nibiru.world.gen.biome.BiomeInfectedMountains)1