Search in sources :

Example 1 with EntityMeteor

use of micdoodle8.mods.galacticraft.core.entities.EntityMeteor in project MorePlanets by SteveKunG.

the class EntityEventHandler method spawnMeteor.

public void spawnMeteor(World world, EntityPlayerMP player, IMeteorType meteor) {
    Entity meteorEntity = null;
    if (FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT) {
        if (((IMeteorType) world.provider).getMeteorSpawnFrequency() > 0.0D && meteor.getMeteorType() != null) {
            int f = (int) (((IMeteorType) world.provider).getMeteorSpawnFrequency() * 750D);
            int r = ((WorldServer) world).getMinecraftServer().getPlayerList().getViewDistance();
            int x, z;
            double motX, motZ;
            x = world.rand.nextInt(20) + 160;
            z = world.rand.nextInt(20) - 10;
            motX = world.rand.nextDouble() * 2 - 2.5D;
            motZ = world.rand.nextDouble() * 5 - 2.5D;
            int px = MathHelper.floor(player.posX);
            if (world.rand.nextInt(f) == 0) {
                EntityPlayer closestPlayer = world.getClosestPlayerToEntity(player, 100);
                if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) {
                    if ((x + px >> 4) - (px >> 4) >= r) {
                        x = ((px >> 4) + r << 4) - 1 - px;
                    }
                    switch(meteor.getMeteorType()) {
                        case ANTAROS:
                            // TODO
                            meteorEntity = new EntityMeteor(world, player.posX + x, 355.0D, player.posZ + z, motX - 2.5D, 0, motZ - 2.5D, 1);
                            break;
                    }
                    if (!world.isRemote) {
                        world.spawnEntity(meteorEntity);
                        MPLog.debug("Spawn {} at {} {} {}", meteor.getClass().getSimpleName(), (int) meteorEntity.posX, (int) meteorEntity.posY, (int) meteorEntity.posZ);
                    }
                }
            }
            if (world.rand.nextInt(f * 3) == 0) {
                EntityPlayer closestPlayer = world.getClosestPlayerToEntity(player, 100);
                if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) {
                    switch(meteor.getMeteorType()) {
                        case ANTAROS:
                            // TODO
                            meteorEntity = new EntityMeteor(world, player.posX + x, 355.0D, player.posZ + z, motX - 2.5D, 0, motZ - 2.5D, 1);
                            break;
                    }
                    if (!world.isRemote) {
                        world.spawnEntity(meteorEntity);
                        MPLog.debug("Spawn {} at {} {} {}", meteor.getClass().getSimpleName(), (int) meteorEntity.posX, (int) meteorEntity.posY, (int) meteorEntity.posZ);
                    }
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer) EntityMeteor(micdoodle8.mods.galacticraft.core.entities.EntityMeteor) IMeteorType(stevekung.mods.moreplanets.world.IMeteorType)

Example 2 with EntityMeteor

use of micdoodle8.mods.galacticraft.core.entities.EntityMeteor in project Galacticraft by micdoodle8.

the class GCPlayerHandler method throwMeteors.

protected void throwMeteors(EntityPlayerMP player) {
    World world = player.worldObj;
    if (world.provider instanceof IGalacticraftWorldProvider && !world.isRemote) {
        if (((IGalacticraftWorldProvider) world.provider).getMeteorFrequency() > 0 && ConfigManagerCore.meteorSpawnMod > 0.0) {
            final int f = (int) (((IGalacticraftWorldProvider) world.provider).getMeteorFrequency() * 750D * (1.0 / ConfigManagerCore.meteorSpawnMod));
            if (world.rand.nextInt(f) == 0) {
                final EntityPlayer closestPlayer = world.getClosestPlayerToEntity(player, 100);
                if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) {
                    int r = ((WorldServer) world).getMinecraftServer().getConfigurationManager().getViewDistance();
                    int x, z;
                    double motX, motZ;
                    x = world.rand.nextInt(20) + 160;
                    z = world.rand.nextInt(20) - 10;
                    motX = world.rand.nextDouble() * 2 - 2.5D;
                    motZ = world.rand.nextDouble() * 5 - 2.5D;
                    int px = MathHelper.floor_double(player.posX);
                    if ((x + px >> 4) - (px >> 4) >= r) {
                        x = ((px >> 4) + r << 4) - 1 - px;
                    }
                    final EntityMeteor meteor = new EntityMeteor(world, player.posX + x, 355D, player.posZ + z, motX, 0, motZ, 1);
                    if (!world.isRemote) {
                        world.spawnEntityInWorld(meteor);
                    }
                }
            }
            if (world.rand.nextInt(f * 3) == 0) {
                final EntityPlayer closestPlayer = world.getClosestPlayerToEntity(player, 100);
                if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) {
                    int r = ((WorldServer) world).getMinecraftServer().getConfigurationManager().getViewDistance();
                    int x, z;
                    double motX, motZ;
                    x = world.rand.nextInt(20) + 160;
                    z = world.rand.nextInt(20) - 10;
                    motX = world.rand.nextDouble() * 2 - 2.5D;
                    motZ = world.rand.nextDouble() * 5 - 2.5D;
                    int px = MathHelper.floor_double(player.posX);
                    if ((x + px >> 4) - (px >> 4) >= r) {
                        x = ((px >> 4) + r << 4) - 1 - px;
                    }
                    final EntityMeteor meteor = new EntityMeteor(world, player.posX + x, 355D, player.posZ + z, motX, 0, motZ, 6);
                    if (!world.isRemote) {
                        world.spawnEntityInWorld(meteor);
                    }
                }
            }
        }
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer) EntityMeteor(micdoodle8.mods.galacticraft.core.entities.EntityMeteor) World(net.minecraft.world.World) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint)

Aggregations

EntityMeteor (micdoodle8.mods.galacticraft.core.entities.EntityMeteor)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 WorldServer (net.minecraft.world.WorldServer)2 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)1 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)1 Entity (net.minecraft.entity.Entity)1 World (net.minecraft.world.World)1 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)1 IMeteorType (stevekung.mods.moreplanets.world.IMeteorType)1