Search in sources :

Example 1 with WorldProviderNibiru

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));
            }
        }
    }
}
Also used : WorldProviderNibiru(stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru) PotionEffect(net.minecraft.potion.PotionEffect) EntityJuicer(micdoodle8.mods.galacticraft.planets.venus.entities.EntityJuicer) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) IMeteorType(stevekung.mods.moreplanets.world.IMeteorType) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with WorldProviderNibiru

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));
                        }
                    }
                }
            }
        }
    }
}
Also used : WorldProviderNibiru(stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru) WorldServer(net.minecraft.world.WorldServer) EntityAlienBeam(stevekung.mods.moreplanets.module.planets.diona.entity.EntityAlienBeam) World(net.minecraft.world.World) Chunk(net.minecraft.world.chunk.Chunk) WorldDataStartedDimension(stevekung.mods.moreplanets.core.data.WorldDataStartedDimension) MinecraftServer(net.minecraft.server.MinecraftServer) WorldProviderDiona(stevekung.mods.moreplanets.module.planets.diona.dimension.WorldProviderDiona) BlockPos(net.minecraft.util.math.BlockPos) EntityNibiruLightningBolt(stevekung.mods.moreplanets.module.planets.nibiru.entity.weather.EntityNibiruLightningBolt) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

World (net.minecraft.world.World)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 WorldProviderNibiru (stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru)2 EntityJuicer (micdoodle8.mods.galacticraft.planets.venus.entities.EntityJuicer)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 PotionEffect (net.minecraft.potion.PotionEffect)1 MinecraftServer (net.minecraft.server.MinecraftServer)1 BlockPos (net.minecraft.util.math.BlockPos)1 WorldServer (net.minecraft.world.WorldServer)1 Chunk (net.minecraft.world.chunk.Chunk)1 WorldDataStartedDimension (stevekung.mods.moreplanets.core.data.WorldDataStartedDimension)1 WorldProviderDiona (stevekung.mods.moreplanets.module.planets.diona.dimension.WorldProviderDiona)1 EntityAlienBeam (stevekung.mods.moreplanets.module.planets.diona.entity.EntityAlienBeam)1 EntityNibiruLightningBolt (stevekung.mods.moreplanets.module.planets.nibiru.entity.weather.EntityNibiruLightningBolt)1 PacketSimpleMP (stevekung.mods.moreplanets.network.PacketSimpleMP)1 IMeteorType (stevekung.mods.moreplanets.world.IMeteorType)1