Search in sources :

Example 1 with WorldProviderDiona

use of stevekung.mods.moreplanets.planets.diona.dimension.WorldProviderDiona 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 WorldProviderDiona

use of stevekung.mods.moreplanets.planets.diona.dimension.WorldProviderDiona in project MorePlanets by SteveKunG.

the class ClientEventHandler method runAlienBeamTick.

private void runAlienBeamTick(EntityPlayer player) {
    Iterator<Map.Entry<BlockPos, Integer>> it = this.beamList.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<BlockPos, Integer> entry = it.next();
        int val = entry.getValue();
        if (val - 1 <= 0) {
            it.remove();
        } else {
            entry.setValue(val - 1);
        }
    }
    if (player.getRNG().nextInt(512) == 0 && player.world.provider instanceof WorldProviderDiona) {
        if (player.world.getSunBrightness(1.0F) < 0.1F) {
            double freq = player.getRNG().nextDouble() * Math.PI * 2.0F;
            double dist = 64.0F;
            double dX = dist * Math.cos(freq);
            double dZ = dist * Math.sin(freq);
            double posX = player.posX + dX;
            double posY = 48;
            double posZ = player.posZ + dZ;
            this.mc.world.playSound(player, posX, player.posY, posZ, MPSounds.ALIEN_BEAM, SoundCategory.WEATHER, 100.0F, 1.0F + player.getRNG().nextFloat() * 0.8F);
            this.beamList.put(new BlockPos(posX, posY, posZ), 40);
        }
    }
}
Also used : WorldProviderDiona(stevekung.mods.moreplanets.planets.diona.dimension.WorldProviderDiona) BlockPos(net.minecraft.util.math.BlockPos) TextureMap(net.minecraft.client.renderer.texture.TextureMap)

Aggregations

BlockPos (net.minecraft.util.math.BlockPos)2 WorldProviderDiona (stevekung.mods.moreplanets.planets.diona.dimension.WorldProviderDiona)2 TextureMap (net.minecraft.client.renderer.texture.TextureMap)1 World (net.minecraft.world.World)1 Biome (net.minecraft.world.biome.Biome)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 EntityAlienBeam (stevekung.mods.moreplanets.planets.diona.entity.EntityAlienBeam)1 WorldProviderNibiru (stevekung.mods.moreplanets.planets.nibiru.dimension.WorldProviderNibiru)1 EntityNibiruLightningBolt (stevekung.mods.moreplanets.planets.nibiru.entity.weather.EntityNibiruLightningBolt)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