diff --git a/core/Registration.java b/core/Registration.java index 677c3296..23d602d2 100644 --- a/core/Registration.java +++ b/core/Registration.java @@ -19,6 +19,7 @@ import appeng.api.definitions.Materials; import appeng.api.definitions.Parts; import appeng.api.features.IRecipeHandlerRegistry; import appeng.api.features.IWirelessTermHandler; +import appeng.api.features.IWorldGen.WorldGenType; import appeng.api.movable.IMovableRegistry; import appeng.api.networking.IGridCacheRegistry; import appeng.api.networking.crafting.ICraftingGrid; @@ -703,6 +704,20 @@ public class Registration */ 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. */ diff --git a/core/features/registries/RegistryContainer.java b/core/features/registries/RegistryContainer.java index 068c584a..0f68c124 100644 --- a/core/features/registries/RegistryContainer.java +++ b/core/features/registries/RegistryContainer.java @@ -9,6 +9,7 @@ import appeng.api.features.IRecipeHandlerRegistry; import appeng.api.features.IRegistryContainer; import appeng.api.features.ISpecialComparisonRegistry; import appeng.api.features.IWirelessTermRegistery; +import appeng.api.features.IWorldGen; import appeng.api.movable.IMovableRegistry; import appeng.api.networking.IGridCacheRegistry; import appeng.api.storage.ICellRegistry; @@ -28,7 +29,7 @@ public class RegistryContainer implements IRegistryContainer private MovableTileRegistry MoveableReg = new MovableTileRegistry(); private MatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry(); private PlayerRegistry playerreg = new PlayerRegistry(); -private IRecipeHandlerRegistry recipeReg = new RecipeHandlerRegistry(); + private IRecipeHandlerRegistry recipeReg = new RecipeHandlerRegistry(); @Override public IWirelessTermRegistery wireless() @@ -97,8 +98,15 @@ private IRecipeHandlerRegistry recipeReg = new RecipeHandlerRegistry(); } @Override - public IRecipeHandlerRegistry recipes() { + public IRecipeHandlerRegistry recipes() + { return recipeReg; } + @Override + public IWorldGen worldgen() + { + return WorldGenRegistry.instance; + } + } diff --git a/core/features/registries/WorldGenRegistry.java b/core/features/registries/WorldGenRegistry.java new file mode 100644 index 00000000..1d664a60 --- /dev/null +++ b/core/features/registries/WorldGenRegistry.java @@ -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> badProviders = new HashSet(); + HashSet 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 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 ); + } + +} diff --git a/hooks/MeteoriteWorldGen.java b/hooks/MeteoriteWorldGen.java index 978d26eb..ddb83d9c 100644 --- a/hooks/MeteoriteWorldGen.java +++ b/hooks/MeteoriteWorldGen.java @@ -5,10 +5,12 @@ import java.util.concurrent.Future; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; +import appeng.api.features.IWorldGen.WorldGenType; import appeng.api.util.DimensionalCoord; import appeng.core.AEConfig; import appeng.core.AELog; import appeng.core.WorldSettings; +import appeng.core.features.registries.WorldGenRegistry; import appeng.helpers.MeteoritePlacer; import appeng.services.helpers.ICompassCallback; import cpw.mods.fml.common.IWorldGenerator; @@ -35,7 +37,7 @@ final public class MeteoriteWorldGen implements IWorldGenerator @Override 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 z = r.nextInt( 16 ) + (chunkZ << 4); diff --git a/hooks/QuartzWorldGen.java b/hooks/QuartzWorldGen.java index 93e08fbe..cbac601f 100644 --- a/hooks/QuartzWorldGen.java +++ b/hooks/QuartzWorldGen.java @@ -8,7 +8,9 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import appeng.api.AEApi; +import appeng.api.features.IWorldGen.WorldGenType; import appeng.core.AEConfig; +import appeng.core.features.registries.WorldGenRegistry; import cpw.mods.fml.common.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) { - WorldGenMinable whichOre = r.nextFloat() > AEConfig.instance.spawnChargedChance ? oreCharged : oreNormal; - int a = chunkX * 16 + r.nextInt( 22 ); - int b = r.nextInt( 40 * sealevel / 64 ) + r.nextInt( 22 * sealevel / 64 ) + 12 * sealevel / 64; - int c = chunkZ * 16 + r.nextInt( 22 ); - whichOre.generate( w, r, a, b, c ); + boolean isCharged = r.nextFloat() > AEConfig.instance.spawnChargedChance; + WorldGenMinable whichOre = isCharged ? oreCharged : oreNormal; + + if ( WorldGenRegistry.instance.isWorldGenEnabled( isCharged ? WorldGenType.ChargedCertusQuartz : WorldGenType.CertusQuartz, w ) ) + { + 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 ); + } } }