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();
}
}
}
}
}
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);
}
}
}
Aggregations