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