Merge pull request #324 from Cisien/whitelist

Add config option to whitelist dimensions for meteorite gen
This commit is contained in:
Chris 2014-10-19 07:40:02 -07:00
commit ff77462ebb
4 changed files with 40 additions and 6 deletions

@ -1 +1 @@
Subproject commit d46140c55da19643cd3242591be3b16e45a8297e
Subproject commit bbe2ad8e709a366faf34e6efac9aef37cb3d8013

View file

@ -131,6 +131,7 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
public double meteoriteClusterChance = 0.1;
public double meteoriteSpawnChance = 0.3;
public int[] meteoriteDimensionWhitelist = new int[] { 0 };
public int craftingCalculationTimePerTick = 5;
@ -237,6 +238,8 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
minMeteoriteDistance = get( "worldGen", "minMeteoriteDistance", minMeteoriteDistance ).getInt( minMeteoriteDistance );
meteoriteClusterChance = get( "worldGen", "meteoriteClusterChance", meteoriteClusterChance ).getDouble( meteoriteClusterChance );
meteoriteSpawnChance = get( "worldGen", "meteoriteSpawnChance", meteoriteSpawnChance ).getDouble( meteoriteSpawnChance );
meteoriteDimensionWhitelist = get ("worldGen", "meteoriteDimensionWhitelist", meteoriteDimensionWhitelist).getIntList();
quartzOresPerCluster = get( "worldGen", "quartzOresPerCluster", quartzOresPerCluster ).getInt( quartzOresPerCluster );
quartzOresClusterAmount = get( "worldGen", "quartzOresClusterAmount", quartzOresClusterAmount ).getInt( quartzOresClusterAmount );

View file

@ -678,7 +678,9 @@ public class Registration
GameRegistry.registerWorldGenerator( new QuartzWorldGen(), 0 );
if ( AEConfig.instance.isFeatureEnabled( AEFeature.MeteoriteWorldGen ) )
{
GameRegistry.registerWorldGenerator( new MeteoriteWorldGen(), 0 );
}
IMovableRegistry mr = AEApi.instance().registries().movable();
@ -722,11 +724,17 @@ public class Registration
{
AEApi.instance().registries().worldgen().disableWorldGenForProviderID( type, StorageWorldProvider.class );
// end
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, 1 );
// nether
//nether
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, -1 );
//end
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, 1 );
}
//whitelist from config
for(int dimension : AEConfig.instance.meteoriteDimensionWhitelist)
{
AEApi.instance().registries().worldgen().enableWorldGenForDimension( WorldGenType.Meteorites, dimension );
}
/**

View file

@ -14,6 +14,7 @@ public class WorldGenRegistry implements IWorldGen
final HashSet<Class<? extends WorldProvider>> badProviders = new HashSet<Class<? extends WorldProvider>>();
final HashSet<Integer> badDimensions = new HashSet<Integer>();
final HashSet<Integer> enabledDimensions = new HashSet<Integer>();
}
@ -41,8 +42,19 @@ public class WorldGenRegistry implements IWorldGen
if ( w == null )
throw new IllegalArgumentException( "Bad Provider Passed" );
if ( types[type.ordinal()].badProviders.contains( w.provider.getClass() ) || types[type.ordinal()].badDimensions.contains( w.provider.dimensionId ) )
boolean isBadProvider = types[type.ordinal()].badProviders.contains( w.provider.getClass() );
boolean isBadDimension = types[type.ordinal()].badDimensions.contains( w.provider.dimensionId );
boolean isGoodDimension = types[type.ordinal()].enabledDimensions.contains( w.provider.dimensionId );
if ( isBadProvider || isBadDimension )
{
return false;
}
if ( !isGoodDimension && type == WorldGenType.Meteorites)
{
return false;
}
return true;
}
@ -63,9 +75,20 @@ public class WorldGenRegistry implements IWorldGen
public void disableWorldGenForDimension(WorldGenType type, int dimensionID)
{
if ( type == null )
{
throw new IllegalArgumentException( "Bad Type Passed" );
}
types[type.ordinal()].badDimensions.add( dimensionID );
}
@Override
public void enableWorldGenForDimension(WorldGenType type, int dimensionID)
{
if ( type == null )
throw new IllegalArgumentException( "Bad Type Passed" );
types[type.ordinal()].enabledDimensions.add( dimensionID );
}
}