use of stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru in project MorePlanets by SteveKunG.
the class EntityEventHandler method onLivingUpdate.
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
EntityLivingBase living = event.getEntityLiving();
World world = living.world;
if (living.isDead) {
int id = GCCoreUtil.getDimensionID(living.world);
PacketSimpleMP.sendToAllAround(new PacketSimpleMP(EnumSimplePacketMP.C_REMOVE_ENTITY_ID, id, String.valueOf(living.getEntityId())), living.world, id, living.getPosition(), 64);
}
if (living instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) living;
if (ConfigManagerMP.enableStartedPlanet && !WorldTickEventHandler.startedDimensionData.startedDimension && !(ConfigManagerMP.startedPlanet.equals("planet.") || ConfigManagerMP.startedPlanet.equals("moon.") || ConfigManagerMP.startedPlanet.equals("satellite."))) {
MPLog.debug("Start teleporting player to dimension {}", ConfigManagerMP.startedPlanet);
TeleportUtil.startNewDimension(player);
WorldTickEventHandler.startedDimensionData.startedDimension = true;
WorldTickEventHandler.startedDimensionData.planetToBack = ConfigManagerMP.startedPlanet;
WorldTickEventHandler.startedDimensionData.setDirty(true);
}
if (player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) || this.isInOxygen(world, player)) {
player.removePotionEffect(MPPotions.INFECTED_SPORE);
}
if (player.isPotionActive(MPPotions.DARK_ENERGY_PROTECTION)) {
player.removePotionEffect(MPPotions.DARK_ENERGY);
}
if (world.provider instanceof WorldProviderNibiru) {
if (world.isRainingAt(player.getPosition()) && !this.isGodPlayer(player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && world.getBiome(player.getPosition()) != MPBiomes.GREEN_VEIN) {
player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
}
if (player.ticksExisted % 128 == 0 && !this.isGodPlayer(player) && !this.isInOxygen(world, player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && world.getBiome(player.getPosition()) != MPBiomes.GREEN_VEIN) {
player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
}
}
if (world.provider instanceof IMeteorType) {
// this.spawnMeteor(world, player, (IMeteorType)world.provider);
}
}
if (world.provider instanceof WorldProviderNibiru) {
if (!(living instanceof EntityPlayer) && !EntityEffectHelper.isGalacticraftMob(living) && !(living instanceof EntityJuicer)) {
if (living.ticksExisted % 128 == 0 && world.getBiome(living.getPosition()) != MPBiomes.GREEN_VEIN) {
living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
}
if (world.isRainingAt(living.getPosition()) && world.getBiome(living.getPosition()) != MPBiomes.GREEN_VEIN) {
living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
}
}
}
}
use of stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru 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