Added Feature: #0654 - API support for disabling AE2 world gen in specific dimensions
This commit is contained in:
parent
7ce587a235
commit
61d79a804f
5 changed files with 111 additions and 8 deletions
|
@ -19,6 +19,7 @@ import appeng.api.definitions.Materials;
|
||||||
import appeng.api.definitions.Parts;
|
import appeng.api.definitions.Parts;
|
||||||
import appeng.api.features.IRecipeHandlerRegistry;
|
import appeng.api.features.IRecipeHandlerRegistry;
|
||||||
import appeng.api.features.IWirelessTermHandler;
|
import appeng.api.features.IWirelessTermHandler;
|
||||||
|
import appeng.api.features.IWorldGen.WorldGenType;
|
||||||
import appeng.api.movable.IMovableRegistry;
|
import appeng.api.movable.IMovableRegistry;
|
||||||
import appeng.api.networking.IGridCacheRegistry;
|
import appeng.api.networking.IGridCacheRegistry;
|
||||||
import appeng.api.networking.crafting.ICraftingGrid;
|
import appeng.api.networking.crafting.ICraftingGrid;
|
||||||
|
@ -703,6 +704,20 @@ public class Registration
|
||||||
*/
|
*/
|
||||||
mr.whiteListTileEntity( AEBaseTile.class );
|
mr.whiteListTileEntity( AEBaseTile.class );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* world gen
|
||||||
|
*/
|
||||||
|
for (WorldGenType type : WorldGenType.values())
|
||||||
|
{
|
||||||
|
AEApi.instance().registries().worldgen().disableWorldGenForProviderID( type, StorageWorldProvider.class );
|
||||||
|
|
||||||
|
// end
|
||||||
|
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, 1 );
|
||||||
|
|
||||||
|
// nether
|
||||||
|
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, -1 );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initial recipe bake, if ore dictionary changes after this it re-bakes.
|
* initial recipe bake, if ore dictionary changes after this it re-bakes.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,6 +9,7 @@ import appeng.api.features.IRecipeHandlerRegistry;
|
||||||
import appeng.api.features.IRegistryContainer;
|
import appeng.api.features.IRegistryContainer;
|
||||||
import appeng.api.features.ISpecialComparisonRegistry;
|
import appeng.api.features.ISpecialComparisonRegistry;
|
||||||
import appeng.api.features.IWirelessTermRegistery;
|
import appeng.api.features.IWirelessTermRegistery;
|
||||||
|
import appeng.api.features.IWorldGen;
|
||||||
import appeng.api.movable.IMovableRegistry;
|
import appeng.api.movable.IMovableRegistry;
|
||||||
import appeng.api.networking.IGridCacheRegistry;
|
import appeng.api.networking.IGridCacheRegistry;
|
||||||
import appeng.api.storage.ICellRegistry;
|
import appeng.api.storage.ICellRegistry;
|
||||||
|
@ -28,7 +29,7 @@ public class RegistryContainer implements IRegistryContainer
|
||||||
private MovableTileRegistry MoveableReg = new MovableTileRegistry();
|
private MovableTileRegistry MoveableReg = new MovableTileRegistry();
|
||||||
private MatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry();
|
private MatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry();
|
||||||
private PlayerRegistry playerreg = new PlayerRegistry();
|
private PlayerRegistry playerreg = new PlayerRegistry();
|
||||||
private IRecipeHandlerRegistry recipeReg = new RecipeHandlerRegistry();
|
private IRecipeHandlerRegistry recipeReg = new RecipeHandlerRegistry();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IWirelessTermRegistery wireless()
|
public IWirelessTermRegistery wireless()
|
||||||
|
@ -97,8 +98,15 @@ private IRecipeHandlerRegistry recipeReg = new RecipeHandlerRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRecipeHandlerRegistry recipes() {
|
public IRecipeHandlerRegistry recipes()
|
||||||
|
{
|
||||||
return recipeReg;
|
return recipeReg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IWorldGen worldgen()
|
||||||
|
{
|
||||||
|
return WorldGenRegistry.instance;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
71
core/features/registries/WorldGenRegistry.java
Normal file
71
core/features/registries/WorldGenRegistry.java
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
package appeng.core.features.registries;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldProvider;
|
||||||
|
import appeng.api.features.IWorldGen;
|
||||||
|
|
||||||
|
public class WorldGenRegistry implements IWorldGen
|
||||||
|
{
|
||||||
|
|
||||||
|
private class TypeSet
|
||||||
|
{
|
||||||
|
|
||||||
|
HashSet<Class<? extends WorldProvider>> badProviders = new HashSet();
|
||||||
|
HashSet<Integer> badDimentions = new HashSet();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
TypeSet[] types;
|
||||||
|
|
||||||
|
static final public WorldGenRegistry instance = new WorldGenRegistry();
|
||||||
|
|
||||||
|
private WorldGenRegistry() {
|
||||||
|
|
||||||
|
types = new TypeSet[WorldGenType.values().length];
|
||||||
|
|
||||||
|
for (WorldGenType type : WorldGenType.values())
|
||||||
|
{
|
||||||
|
types[type.ordinal()] = new TypeSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWorldGenEnabled(WorldGenType type, World w)
|
||||||
|
{
|
||||||
|
if ( type == null )
|
||||||
|
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||||
|
|
||||||
|
if ( w == null )
|
||||||
|
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||||
|
|
||||||
|
if ( types[type.ordinal()].badProviders.contains( w.provider.getClass() ) || types[type.ordinal()].badDimentions.contains( w.provider.dimensionId ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disableWorldGenForProviderID(WorldGenType type, Class<? extends WorldProvider> provider)
|
||||||
|
{
|
||||||
|
if ( type == null )
|
||||||
|
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||||
|
|
||||||
|
if ( provider == null )
|
||||||
|
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||||
|
|
||||||
|
types[type.ordinal()].badProviders.add( provider );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disableWorldGenForDimension(WorldGenType type, int dimid)
|
||||||
|
{
|
||||||
|
if ( type == null )
|
||||||
|
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||||
|
|
||||||
|
types[type.ordinal()].badDimentions.add( dimid );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,10 +5,12 @@ import java.util.concurrent.Future;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.IChunkProvider;
|
import net.minecraft.world.chunk.IChunkProvider;
|
||||||
|
import appeng.api.features.IWorldGen.WorldGenType;
|
||||||
import appeng.api.util.DimensionalCoord;
|
import appeng.api.util.DimensionalCoord;
|
||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.core.WorldSettings;
|
import appeng.core.WorldSettings;
|
||||||
|
import appeng.core.features.registries.WorldGenRegistry;
|
||||||
import appeng.helpers.MeteoritePlacer;
|
import appeng.helpers.MeteoritePlacer;
|
||||||
import appeng.services.helpers.ICompassCallback;
|
import appeng.services.helpers.ICompassCallback;
|
||||||
import cpw.mods.fml.common.IWorldGenerator;
|
import cpw.mods.fml.common.IWorldGenerator;
|
||||||
|
@ -35,7 +37,7 @@ final public class MeteoriteWorldGen implements IWorldGenerator
|
||||||
@Override
|
@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 ( r.nextFloat() > 0.9 )
|
if ( WorldGenRegistry.instance.isWorldGenEnabled( WorldGenType.Metorites, w ) && r.nextFloat() > 0.9 )
|
||||||
{
|
{
|
||||||
int x = r.nextInt( 16 ) + (chunkX << 4);
|
int x = r.nextInt( 16 ) + (chunkX << 4);
|
||||||
int z = r.nextInt( 16 ) + (chunkZ << 4);
|
int z = r.nextInt( 16 ) + (chunkZ << 4);
|
||||||
|
|
|
@ -8,7 +8,9 @@ import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.IChunkProvider;
|
import net.minecraft.world.chunk.IChunkProvider;
|
||||||
import net.minecraft.world.gen.feature.WorldGenMinable;
|
import net.minecraft.world.gen.feature.WorldGenMinable;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
|
import appeng.api.features.IWorldGen.WorldGenType;
|
||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
|
import appeng.core.features.registries.WorldGenRegistry;
|
||||||
import cpw.mods.fml.common.IWorldGenerator;
|
import cpw.mods.fml.common.IWorldGenerator;
|
||||||
|
|
||||||
final public class QuartzWorldGen implements IWorldGenerator
|
final public class QuartzWorldGen implements IWorldGenerator
|
||||||
|
@ -43,11 +45,16 @@ final public class QuartzWorldGen implements IWorldGenerator
|
||||||
|
|
||||||
for (int x = 0; x < (r.nextBoolean() ? scale * 2 : scale) / 2; ++x)
|
for (int x = 0; x < (r.nextBoolean() ? scale * 2 : scale) / 2; ++x)
|
||||||
{
|
{
|
||||||
WorldGenMinable whichOre = r.nextFloat() > AEConfig.instance.spawnChargedChance ? oreCharged : oreNormal;
|
boolean isCharged = r.nextFloat() > AEConfig.instance.spawnChargedChance;
|
||||||
int a = chunkX * 16 + r.nextInt( 22 );
|
WorldGenMinable whichOre = isCharged ? oreCharged : oreNormal;
|
||||||
int b = r.nextInt( 40 * sealevel / 64 ) + r.nextInt( 22 * sealevel / 64 ) + 12 * sealevel / 64;
|
|
||||||
int c = chunkZ * 16 + r.nextInt( 22 );
|
if ( WorldGenRegistry.instance.isWorldGenEnabled( isCharged ? WorldGenType.ChargedCertusQuartz : WorldGenType.CertusQuartz, w ) )
|
||||||
whichOre.generate( w, r, a, b, c );
|
{
|
||||||
|
int cx = chunkX * 16 + r.nextInt( 22 );
|
||||||
|
int cy = r.nextInt( 40 * sealevel / 64 ) + r.nextInt( 22 * sealevel / 64 ) + 12 * sealevel / 64;
|
||||||
|
int cz = chunkZ * 16 + r.nextInt( 22 );
|
||||||
|
whichOre.generate( w, r, cx, cy, cz );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue