use of stevekung.mods.moreplanets.core.data.WorldDataStartedDimension in project MorePlanets by SteveKunG.
the class WorldTickEventHandler method onServerTick.
@SubscribeEvent
public void onServerTick(ServerTickEvent event) {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server == null) {
return;
}
if (event.phase == Phase.START) {
if (WorldTickEventHandler.startedDimensionData == null) {
World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(0);
WorldTickEventHandler.startedDimensionData = (WorldDataStartedDimension) world.getMapStorage().getOrLoadData(WorldDataStartedDimension.class, WorldDataStartedDimension.saveDataID);
if (WorldTickEventHandler.startedDimensionData == null) {
WorldTickEventHandler.startedDimensionData = new WorldDataStartedDimension(WorldDataStartedDimension.saveDataID);
world.getMapStorage().setData(WorldDataStartedDimension.saveDataID, WorldTickEventHandler.startedDimensionData);
}
}
}
if (event.phase == Phase.END) {
World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(ConfigManagerMP.idDimensionDiona);
if (world.provider instanceof WorldProviderDiona) {
if (world instanceof WorldServer) {
WorldServer worldServer = (WorldServer) world;
for (Iterator<Chunk> iterator = world.getPersistentChunkIterable(worldServer.getPlayerChunkMap().getChunkIterator()); iterator.hasNext(); world.profiler.endSection()) {
Chunk chunk = iterator.next();
int j = chunk.x * 16;
int k = chunk.z * 16;
if (world.rand.nextInt(75000) == 0) {
this.updateLCG = this.updateLCG * 3 + 1013904223;
int l = this.updateLCG >> 2;
BlockPos blockpos = this.adjustPosToNearbyEntity(world, new BlockPos(j + (l & 15), 0, k + (l >> 8 & 15)));
if (this.canBeamStrike(world, blockpos)) {
EntityAlienBeam beam = new EntityAlienBeam(world);
beam.setLocationAndAngles(blockpos.getX(), blockpos.getY(), blockpos.getZ(), 0.0F, 0.0F);
world.spawnEntity(beam);
}
}
}
}
}
world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(ConfigManagerMP.idDimensionNibiru);
if (world.provider instanceof WorldProviderNibiru) {
if (world instanceof WorldServer) {
WorldServer worldServer = (WorldServer) world;
for (Iterator<Chunk> iterator = world.getPersistentChunkIterable(worldServer.getPlayerChunkMap().getChunkIterator()); iterator.hasNext(); world.profiler.endSection()) {
Chunk chunk = iterator.next();
int j = chunk.x * 16;
int k = chunk.z * 16;
boolean flag = world.isRaining();
boolean flag1 = world.isThundering();
if (world.provider.canDoLightning(chunk) && flag && flag1 && world.rand.nextInt(1000) == 0) {
this.updateLCG = this.updateLCG * 3 + 1013904223;
int l = this.updateLCG >> 2;
BlockPos blockpos = this.adjustPosToNearbyEntity(world, new BlockPos(j + (l & 15), 0, k + (l >> 8 & 15)));
if (world.isRainingAt(blockpos)) {
world.spawnEntity(new EntityNibiruLightningBolt(world, blockpos.getX(), blockpos.getY(), blockpos.getZ(), true));
}
}
if (world.rand.nextInt(16) == 0) {
this.updateLCG = this.updateLCG * 3 + 1013904223;
int j2 = this.updateLCG >> 2;
BlockPos blockpos1 = world.getPrecipitationHeight(new BlockPos(j + (j2 & 15), 0, k + (j2 >> 8 & 15)));
BlockPos blockpos2 = blockpos1.down();
if (world.canBlockFreezeNoWater(blockpos2)) {
world.setBlockState(blockpos2, NibiruBlocks.INFECTED_ICE.getDefaultState());
}
if (flag && world.canSnowAt(blockpos1, true)) {
world.setBlockState(blockpos1, NibiruBlocks.INFECTED_SNOW_LAYER.getDefaultState());
}
if (flag && world.getBiome(blockpos2).canRain()) {
world.getBlockState(blockpos2).getBlock().fillWithRain(world, blockpos2);
}
}
if (world.getBiome(new BlockPos(j, 0, k)) == MPBiomes.INFECTED_DESERT || world.getBiome(new BlockPos(j, 0, k)) == MPBiomes.INFECTED_EXTREME_HILLS) {
if (world.rand.nextInt(250000) == 0) {
this.updateLCG = this.updateLCG * 3 + 1013904223;
int l = this.updateLCG >> 2;
BlockPos blockpos = this.adjustPosToNearbyEntity(world, new BlockPos(j + (l & 15), 0, k + (l >> 8 & 15)));
world.spawnEntity(new EntityNibiruLightningBolt(world, blockpos.getX(), blockpos.getY(), blockpos.getZ(), false));
}
}
}
}
}
}
}
Aggregations