Refactored AEConfig (#2633)

Added a singleton getter instead the public field.
Reduced all fields to private.
Replaced field access with getters.
Added setters where necessary (Dimension/Biome Registration)
Added config options to disable more features.
Splitted Enum name from the config key.
Changed FacadeConfig and Networkhandler similar to AEConfig.init().
This commit is contained in:
yueh
2016-11-26 14:07:34 +01:00
committed by GitHub
parent 6554e295d5
commit a665200c31
105 changed files with 1022 additions and 645 deletions
@@ -218,7 +218,7 @@ public final class MeteoritePlacer
// spawn meteor
this.skyStoneDefinition.maybeBlock().ifPresent( block -> placeMeteoriteSkyStone( w, x, y, z, block ) );
if( AEConfig.instance.isFeatureEnabled( AEFeature.SpawnPressesInMeteorites ) )
if( AEConfig.instance().isFeatureEnabled( AEFeature.SPAWN_PRESSES_IN_METEORITES ) )
{
this.skyChestDefinition.maybeBlock().ifPresent( block -> this.putter.put( w, x, y, z, block ) );
@@ -44,19 +44,11 @@ public final class MeteoriteWorldGen implements IWorldGenerator
{
if( WorldGenRegistry.INSTANCE.isWorldGenEnabled( WorldGenType.METEORITES, w ) )
{
// add new meteorites?
if( r.nextFloat() < AEConfig.instance.meteoriteSpawnChance )
{
final int x = r.nextInt( 16 ) + ( chunkX << 4 );
final int z = r.nextInt( 16 ) + ( chunkZ << 4 );
final int x = r.nextInt( 16 ) + ( chunkX << 4 );
final int z = r.nextInt( 16 ) + ( chunkZ << 4 );
final int depth = AEConfig.instance().getMeteoriteMaximumSpawnHeight() + r.nextInt( 20 );
final int depth = 180 + r.nextInt( 20 );
TickHandler.INSTANCE.addCallable( w, new MeteoriteSpawn( x, depth, z ) );
}
else
{
TickHandler.INSTANCE.addCallable( w, new MeteoriteSpawn( chunkX << 4, 128, chunkZ << 4 ) );
}
TickHandler.INSTANCE.addCallable( w, new MeteoriteSpawn( x, depth, z ) );
}
else
{
@@ -79,7 +71,7 @@ public final class MeteoriteWorldGen implements IWorldGenerator
{
for( int cz = pz - 6; cz < pz + 6; cz++ )
{
if( w.getChunkProvider().getLoadedChunk( cx, cz ) != null)
if( w.getChunkProvider().getLoadedChunk( cx, cz ) != null )
{
if( px == cx && pz == cz )
{
@@ -144,9 +136,9 @@ public final class MeteoriteWorldGen implements IWorldGenerator
minSqDist = Math.min( minSqDist, mp.getSqDistance( this.x, this.z ) );
}
final boolean isCluster = ( minSqDist < 30 * 30 ) && Platform.getRandomFloat() < AEConfig.instance.meteoriteClusterChance;
final boolean isCluster = ( minSqDist < 30 * 30 ) && Platform.getRandomFloat() < AEConfig.instance().getMeteoriteClusterChance();
if( minSqDist > AEConfig.instance.minMeteoriteDistanceSq || isCluster )
if( minSqDist > AEConfig.instance().getMinMeteoriteDistanceSq() || isCluster )
{
MeteoriteWorldGen.this.tryMeteorite( world, this.depth, this.x, this.z );
}
@@ -51,8 +51,8 @@ public final class QuartzWorldGen implements IWorldGenerator
final Block ore = oreDefinition.maybeBlock().orElse( null );
final Block charged = chargedDefinition.maybeBlock().orElse( null );
this.oreNormal = new WorldGenMinable( ore.getDefaultState(), AEConfig.instance.quartzOresPerCluster );
this.oreCharged = new WorldGenMinable( charged.getDefaultState(), AEConfig.instance.quartzOresPerCluster );
this.oreNormal = new WorldGenMinable( ore.getDefaultState(), AEConfig.instance().getQuartzOresPerCluster() );
this.oreCharged = new WorldGenMinable( charged.getDefaultState(), AEConfig.instance().getQuartzOresPerCluster() );
}
@Override
@@ -72,12 +72,12 @@ public final class QuartzWorldGen implements IWorldGenerator
return;
}
final double oreDepthMultiplier = AEConfig.instance.quartzOresClusterAmount * seaLevel / 64;
final double oreDepthMultiplier = AEConfig.instance().getQuartzOresClusterAmount() * seaLevel / 64;
final int scale = (int) Math.round( r.nextGaussian() * Math.sqrt( oreDepthMultiplier ) + oreDepthMultiplier );
for( int x = 0; x < ( r.nextBoolean() ? scale * 2 : scale ) / 2; ++x )
{
final boolean isCharged = r.nextFloat() > AEConfig.instance.spawnChargedChance;
final boolean isCharged = r.nextFloat() > AEConfig.instance().getSpawnChargedChance();
final WorldGenMinable whichOre = isCharged ? this.oreCharged : this.oreNormal;
if( WorldGenRegistry.INSTANCE.isWorldGenEnabled( isCharged ? WorldGenType.CHARGED_CERTUS_QUARTZ : WorldGenType.CERTUS_QUARTZ, w ) )