Basic reformat, hit once, hope never again
This commit is contained in:
@@ -37,18 +37,19 @@ import appeng.hooks.TickHandler;
|
||||
import appeng.util.Platform;
|
||||
import appeng.worldgen.meteorite.ChunkOnly;
|
||||
|
||||
|
||||
final public class MeteoriteWorldGen implements IWorldGenerator
|
||||
{
|
||||
@Override
|
||||
public void generate(Random r, int chunkX, int chunkZ, World w, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
|
||||
public void generate( Random r, int chunkX, int chunkZ, World w, IChunkProvider chunkGenerator, IChunkProvider chunkProvider )
|
||||
{
|
||||
if ( WorldGenRegistry.INSTANCE.isWorldGenEnabled( WorldGenType.Meteorites, w ) )
|
||||
if( WorldGenRegistry.INSTANCE.isWorldGenEnabled( WorldGenType.Meteorites, w ) )
|
||||
{
|
||||
// add new meteorites?
|
||||
if ( r.nextFloat() < AEConfig.instance.meteoriteSpawnChance )
|
||||
if( r.nextFloat() < AEConfig.instance.meteoriteSpawnChance )
|
||||
{
|
||||
int x = r.nextInt( 16 ) + (chunkX << 4);
|
||||
int z = r.nextInt( 16 ) + (chunkZ << 4);
|
||||
int x = r.nextInt( 16 ) + ( chunkX << 4 );
|
||||
int z = r.nextInt( 16 ) + ( chunkZ << 4 );
|
||||
|
||||
int depth = 180 + r.nextInt( 20 );
|
||||
TickHandler.INSTANCE.addCallable( w, new MeteoriteSpawn( x, depth, z, w ) );
|
||||
@@ -60,6 +61,49 @@ final public class MeteoriteWorldGen implements IWorldGenerator
|
||||
WorldSettings.getInstance().getCompass().updateArea( w, chunkX, chunkZ );
|
||||
}
|
||||
|
||||
private boolean tryMeteorite( World w, int depth, int x, int z )
|
||||
{
|
||||
for( int tries = 0; tries < 20; tries++ )
|
||||
{
|
||||
MeteoritePlacer mp = new MeteoritePlacer();
|
||||
|
||||
if( mp.spawnMeteorite( new ChunkOnly( w, x >> 4, z >> 4 ), x, depth, z ) )
|
||||
{
|
||||
int px = x >> 4;
|
||||
int pz = z >> 4;
|
||||
|
||||
for( int cx = px - 6; cx < px + 6; cx++ )
|
||||
for( int cz = pz - 6; cz < pz + 6; cz++ )
|
||||
{
|
||||
if( w.getChunkProvider().chunkExists( cx, cz ) )
|
||||
{
|
||||
if( px == cx && pz == cz )
|
||||
continue;
|
||||
|
||||
if( WorldSettings.getInstance().hasGenerated( w.provider.dimensionId, cx, cz ) )
|
||||
{
|
||||
MeteoritePlacer mp2 = new MeteoritePlacer();
|
||||
mp2.spawnMeteorite( new ChunkOnly( w, cx, cz ), mp.getSettings() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
depth -= 15;
|
||||
if( depth < 40 )
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Collection<NBTTagCompound> getNearByMeteorites( World w, int chunkX, int chunkZ )
|
||||
{
|
||||
return WorldSettings.getInstance().getNearByMeteorites( w.provider.dimensionId, chunkX, chunkZ );
|
||||
}
|
||||
|
||||
class MeteoriteSpawn implements Callable
|
||||
{
|
||||
|
||||
@@ -68,7 +112,8 @@ final public class MeteoriteWorldGen implements IWorldGenerator
|
||||
final World w;
|
||||
final int depth;
|
||||
|
||||
public MeteoriteSpawn(int x, int depth, int z, World w) {
|
||||
public MeteoriteSpawn( int x, int depth, int z, World w )
|
||||
{
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
@@ -84,7 +129,7 @@ final public class MeteoriteWorldGen implements IWorldGenerator
|
||||
double minSqDist = Double.MAX_VALUE;
|
||||
|
||||
// near by meteorites!
|
||||
for (NBTTagCompound data : MeteoriteWorldGen.this.getNearByMeteorites( this.w, chunkX, chunkZ ))
|
||||
for( NBTTagCompound data : MeteoriteWorldGen.this.getNearByMeteorites( this.w, chunkX, chunkZ ) )
|
||||
{
|
||||
MeteoritePlacer mp = new MeteoritePlacer();
|
||||
mp.spawnMeteorite( new ChunkOnly( this.w, chunkX, chunkZ ), data );
|
||||
@@ -92,9 +137,9 @@ final public class MeteoriteWorldGen implements IWorldGenerator
|
||||
minSqDist = Math.min( minSqDist, mp.getSqDistance( this.x, this.z ) );
|
||||
}
|
||||
|
||||
boolean isCluster = (minSqDist < 30 * 30) && Platform.getRandomFloat() < AEConfig.instance.meteoriteClusterChance;
|
||||
boolean isCluster = ( minSqDist < 30 * 30 ) && Platform.getRandomFloat() < AEConfig.instance.meteoriteClusterChance;
|
||||
|
||||
if ( minSqDist > AEConfig.instance.minMeteoriteDistanceSq || isCluster )
|
||||
if( minSqDist > AEConfig.instance.minMeteoriteDistanceSq || isCluster )
|
||||
MeteoriteWorldGen.this.tryMeteorite( this.w, this.depth, this.x, this.z );
|
||||
|
||||
WorldSettings.getInstance().setGenerated( this.w.provider.dimensionId, chunkX, chunkZ );
|
||||
@@ -103,48 +148,4 @@ final public class MeteoriteWorldGen implements IWorldGenerator
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean tryMeteorite(World w, int depth, int x, int z)
|
||||
{
|
||||
for (int tries = 0; tries < 20; tries++)
|
||||
{
|
||||
MeteoritePlacer mp = new MeteoritePlacer();
|
||||
|
||||
if ( mp.spawnMeteorite( new ChunkOnly( w, x >> 4, z >> 4 ), x, depth, z ) )
|
||||
{
|
||||
int px = x >> 4;
|
||||
int pz = z >> 4;
|
||||
|
||||
for (int cx = px - 6; cx < px + 6; cx++)
|
||||
for (int cz = pz - 6; cz < pz + 6; cz++)
|
||||
{
|
||||
if ( w.getChunkProvider().chunkExists( cx, cz ) )
|
||||
{
|
||||
if ( px == cx && pz == cz )
|
||||
continue;
|
||||
|
||||
if ( WorldSettings.getInstance().hasGenerated( w.provider.dimensionId, cx, cz ) )
|
||||
{
|
||||
MeteoritePlacer mp2 = new MeteoritePlacer();
|
||||
mp2.spawnMeteorite( new ChunkOnly( w, cx, cz ), mp.getSettings() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
depth -= 15;
|
||||
if ( depth < 40 )
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Collection<NBTTagCompound> getNearByMeteorites(World w, int chunkX, int chunkZ)
|
||||
{
|
||||
return WorldSettings.getInstance().getNearByMeteorites( w.provider.dimensionId, chunkX, chunkZ );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user