aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/bloodasp/galacticgreg/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/bloodasp/galacticgreg/api')
-rw-r--r--src/main/java/bloodasp/galacticgreg/api/AsteroidBlockComb.java77
-rw-r--r--src/main/java/bloodasp/galacticgreg/api/BlockMetaComb.java50
-rw-r--r--src/main/java/bloodasp/galacticgreg/api/Enums.java57
-rw-r--r--src/main/java/bloodasp/galacticgreg/api/GTOreTypes.java66
-rw-r--r--src/main/java/bloodasp/galacticgreg/api/ISpaceObjectGenerator.java58
-rw-r--r--src/main/java/bloodasp/galacticgreg/api/ModContainer.java85
-rw-r--r--src/main/java/bloodasp/galacticgreg/api/ModDBMDef.java165
-rw-r--r--src/main/java/bloodasp/galacticgreg/api/ModDimensionDef.java470
-rw-r--r--src/main/java/bloodasp/galacticgreg/api/SpecialBlockComb.java71
-rw-r--r--src/main/java/bloodasp/galacticgreg/api/StructureInformation.java59
10 files changed, 1158 insertions, 0 deletions
diff --git a/src/main/java/bloodasp/galacticgreg/api/AsteroidBlockComb.java b/src/main/java/bloodasp/galacticgreg/api/AsteroidBlockComb.java
new file mode 100644
index 0000000000..7976eadc0a
--- /dev/null
+++ b/src/main/java/bloodasp/galacticgreg/api/AsteroidBlockComb.java
@@ -0,0 +1,77 @@
+package bloodasp.galacticgreg.api;
+
+import net.minecraft.block.Block;
+
+/**
+ * Class for a bit more advanced combinations for Asteroids, which supports Custom Blocks as base material and Values
+ * required to generate Gregtech ores
+ */
+public class AsteroidBlockComb extends BlockMetaComb {
+
+ private final GTOreTypes _mGTOreMaterial;
+
+ /**
+ * Create an advanced definition which uses the GregTech-OreType values for ores, and your own definition of Block
+ * for the asteroid material
+ *
+ * @param pOreType The GregTech oreType
+ * @param pBlock Your block
+ */
+ public AsteroidBlockComb(GTOreTypes pOreType, Block pBlock) {
+ super(pBlock, 0);
+ _mGTOreMaterial = pOreType;
+ }
+
+ /**
+ * Create an advanced definition which uses the GregTech-OreType values for ores, and your own definition of Block
+ * for the asteroid material
+ *
+ * @param pOreType The GregTech oreType
+ * @param pBlock Your block
+ * @param pMeta The metavalue for your block (If required)
+ */
+ public AsteroidBlockComb(GTOreTypes pOreType, Block pBlock, int pMeta) {
+ super(pBlock, pMeta);
+ _mGTOreMaterial = pOreType;
+ }
+
+ /**
+ * Create a simple definition which uses the GregTech-OreType values for both asteroidStone and ores
+ *
+ * @param pOreType The GregTech oreType
+ */
+ public AsteroidBlockComb(GTOreTypes pOreType) {
+ super(pOreType.getBlock(), pOreType.getMeta());
+ _mGTOreMaterial = pOreType;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The GT Material for the oregen
+ */
+ public GTOreTypes getOreMaterial() {
+ return _mGTOreMaterial;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) return false;
+ if (other == this) return true;
+ if (!(other instanceof AsteroidBlockComb)) return false;
+ AsteroidBlockComb otherObj = (AsteroidBlockComb) other;
+
+ boolean tFlag = true;
+ String otherName = Block.blockRegistry.getNameForObject(otherObj.getBlock());
+ String thisName = Block.blockRegistry.getNameForObject(this.getBlock());
+ if (otherName != null && thisName != null) {
+ if (!otherName.equals(thisName)) tFlag = false;
+
+ if (!(otherObj.getMeta() == this.getMeta())) tFlag = false;
+
+ if (!(otherObj.getOreMaterial() == this.getOreMaterial())) tFlag = false;
+ } else tFlag = false;
+
+ return tFlag;
+ }
+}
diff --git a/src/main/java/bloodasp/galacticgreg/api/BlockMetaComb.java b/src/main/java/bloodasp/galacticgreg/api/BlockMetaComb.java
new file mode 100644
index 0000000000..7bf504d144
--- /dev/null
+++ b/src/main/java/bloodasp/galacticgreg/api/BlockMetaComb.java
@@ -0,0 +1,50 @@
+package bloodasp.galacticgreg.api;
+
+import net.minecraft.block.Block;
+
+/**
+ * Class used for Simple Block - Meta constructs
+ */
+public class BlockMetaComb {
+
+ private int mMeta;
+ private Block mBlock;
+
+ /**
+ * Creates a simple instance for a block that has no meta value
+ *
+ * @param pBlock The Block in question. 0 is used as meta
+ */
+ public BlockMetaComb(Block pBlock) {
+ this(pBlock, 0);
+ }
+
+ /**
+ * Creates a simple instance for a block with a meta value
+ *
+ * @param pBlock The Block in question
+ * @param pMeta The MetaValue in question ([block]:[meta])
+ */
+ public BlockMetaComb(Block pBlock, int pMeta) {
+ mMeta = pMeta;
+ mBlock = pBlock;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The metadata for this block
+ */
+ public int getMeta() {
+ return mMeta;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The block
+ */
+ public Block getBlock() {
+ return mBlock;
+ }
+}
diff --git a/src/main/java/bloodasp/galacticgreg/api/Enums.java b/src/main/java/bloodasp/galacticgreg/api/Enums.java
new file mode 100644
index 0000000000..0c8afaf243
--- /dev/null
+++ b/src/main/java/bloodasp/galacticgreg/api/Enums.java
@@ -0,0 +1,57 @@
+package bloodasp.galacticgreg.api;
+
+public class Enums {
+
+ public enum SpaceObjectType {
+ OreAsteroid,
+ NonOreSchematic
+ }
+
+ public enum TargetBlockPosition {
+ Invalid,
+ AsteroidInnerCore,
+ AsteroidCore,
+ AsteroidShell,
+ StructureBlock
+ }
+
+ public enum AllowedBlockPosition {
+ AsteroidInnerCore,
+ AsteroidCore,
+ AsteroidShell,
+ AsteroidCoreAndShell
+ }
+
+ public enum AirReplaceRule {
+ NeverReplaceAir,
+ AllowReplaceAir,
+ OnlyReplaceAir
+ }
+
+ public enum ReplaceState {
+ Unknown,
+ Airblock,
+ CanReplace,
+ CannotReplace
+ }
+
+ public enum DimensionType {
+ /**
+ * The Dimension is a void dimension and asteroids shall be generated. They will randomly spawn bewteen 0 and
+ * 250 Additional config values will be generated in worldconfig
+ */
+ Asteroid,
+
+ /**
+ * The Dimension is a planet, and only ores shall be generated in the ground
+ */
+ Planet,
+
+ /**
+ * The Dimension is a special dim where Asteroids *and* ores shall spawn. Additional config values will be
+ * generated in worldconfig
+ */
+ AsteroidAndPlanet
+ }
+
+}
diff --git a/src/main/java/bloodasp/galacticgreg/api/GTOreTypes.java b/src/main/java/bloodasp/galacticgreg/api/GTOreTypes.java
new file mode 100644
index 0000000000..dedbc8f5cc
--- /dev/null
+++ b/src/main/java/bloodasp/galacticgreg/api/GTOreTypes.java
@@ -0,0 +1,66 @@
+package bloodasp.galacticgreg.api;
+
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
+
+import gregtech.api.GregTech_API;
+
+/**
+ * Representation of the various GregTech ores, with their counterpart in VanillaBlocks, and the OreOffset that is
+ * required to generate the proper ores
+ */
+public enum GTOreTypes {
+
+ /**
+ * The Definition for Gregtech's RedGranite
+ **/
+ RedGranite(4000, GregTech_API.sBlockGranites, 8, 3),
+ /**
+ * The Definition for Gregtech's BlackGranite
+ */
+ BlackGranite(3000, GregTech_API.sBlockGranites, 0, 3),
+ /**
+ * The Definition for EndStone
+ */
+ EndStone(2000, Blocks.end_stone, 0, 0),
+ /**
+ * The Definition for Netherrack
+ */
+ Netherrack(1000, Blocks.netherrack, 0, 0), // Unsure about blockupdate value!
+ /**
+ * The Definition for SmallOres (And BlockType Stone)
+ */
+ SmallOres(16000, Blocks.stone, 0, 0), // Unsure about blockupdate value!
+ /**
+ * The Definition for Ores (And BlockType Stone)
+ */
+ NormalOres(0, Blocks.stone, 0, 0); // Unsure about blockupdate value!
+
+ private int _mOffset;
+ private Block _mStoneBlock;
+ private int _mBlockMeta;
+ private int _mUpdateMode;
+
+ GTOreTypes(int pOffset, Block pBlock, int pMeta, int pUpdateMode) {
+ _mOffset = pOffset;
+ _mStoneBlock = pBlock;
+ _mBlockMeta = pMeta;
+ _mUpdateMode = pUpdateMode;
+ }
+
+ public Block getBlock() {
+ return _mStoneBlock;
+ }
+
+ public int getMeta() {
+ return _mBlockMeta;
+ }
+
+ public int getOffset() {
+ return _mOffset;
+ }
+
+ public int getUpdateMode() {
+ return _mUpdateMode;
+ }
+}
diff --git a/src/main/java/bloodasp/galacticgreg/api/ISpaceObjectGenerator.java b/src/main/java/bloodasp/galacticgreg/api/ISpaceObjectGenerator.java
new file mode 100644
index 0000000000..881efa08eb
--- /dev/null
+++ b/src/main/java/bloodasp/galacticgreg/api/ISpaceObjectGenerator.java
@@ -0,0 +1,58 @@
+package bloodasp.galacticgreg.api;
+
+import java.util.List;
+
+import net.minecraft.util.Vec3;
+
+import bloodasp.galacticgreg.api.Enums.SpaceObjectType;
+
+public interface ISpaceObjectGenerator {
+
+ Vec3 getCenterPoint();
+
+ /**
+ * Set the center-point of the object to generate, by providing X, Y and Z directly
+ *
+ * @param pX
+ * @param pY
+ * @param pZ
+ */
+ void setCenterPoint(int pX, int pY, int pZ);
+
+ /**
+ * Set the center-point of the object to generate, by providing a Vec3 instance
+ *
+ * @param pCenter
+ */
+ void setCenterPoint(Vec3 pCenter);
+
+ List<StructureInformation> getStructure();
+
+ /**
+ * Calculate the structure Called after randomize()
+ */
+ void calculate();
+
+ /**
+ * Randomize the structure. Called before calculate()
+ *
+ * @param pSizeMin The minimum size for the structure. It is up to you how you handle this value. it's what the user
+ * sets in his config file
+ * @param pSizeMax The maximum size for the structure. It is up to you how you handle this value. it's what the user
+ * sets in his config file
+ */
+ void randomize(int pSizeMin, int pSizeMax);
+
+ /**
+ * Define the type of the generator. OreAsteroid will be used to spawn ores at given coordinates, where
+ * NonOreSchematic will use the Blocks provided in the structural information to generate your structure
+ *
+ * @return
+ */
+ SpaceObjectType getType();
+
+ /**
+ * This function is called every time the generator shall be reset in order to generate a blank, new structure
+ */
+ void reset();
+}
diff --git a/src/main/java/bloodasp/galacticgreg/api/ModContainer.java b/src/main/java/bloodasp/galacticgreg/api/ModContainer.java
new file mode 100644
index 0000000000..b5416b164f
--- /dev/null
+++ b/src/main/java/bloodasp/galacticgreg/api/ModContainer.java
@@ -0,0 +1,85 @@
+package bloodasp.galacticgreg.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Defines a Mod where this Generator shall be active. Note: This will only work (obviously) for Dimensions where
+ * either: - Gregtech has a hook in the OreGen or - For mods which are addons to GalactiCraft
+ *
+ */
+public class ModContainer {
+
+ private String _mModName;
+ private List<ModDimensionDef> _mDimensionLookup;
+ private boolean _mEnabled = false;
+
+ /**
+ * Internal function
+ *
+ * @return The state if the Registry could find the mod or not
+ */
+ public boolean getEnabled() {
+ return _mEnabled;
+ }
+
+ /**
+ * Internal function
+ *
+ * Never set this to true. This is an internal marker which is set by the registry if the mod could be found or not
+ *
+ * @param pEnabled
+ */
+ public void setEnabled(boolean pEnabled) {
+ _mEnabled = pEnabled;
+ }
+
+ /**
+ * Define a new Mod where GT OreGen shall be enabled
+ *
+ * @param pModName The modID. Make sure to use the proper mod-id, or it won't load correctly
+ */
+ public ModContainer(String pModName) {
+ _mModName = pModName;
+ _mDimensionLookup = new ArrayList<>();
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The mods name
+ */
+ public String getModName() {
+ return _mModName;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The list of attached dimensions for this mod
+ */
+ public List<ModDimensionDef> getDimensionList() {
+ return _mDimensionLookup;
+ }
+
+ /**
+ * Adds a new dimension to this modcontainer. Make sure you've added all blocks there first
+ *
+ * @param pDimDef The dimension definition to be added
+ * @return true if it could be added, false if not
+ */
+ public boolean addDimensionDef(ModDimensionDef pDimDef) {
+ for (ModDimensionDef mdd : _mDimensionLookup) {
+ if (mdd.getChunkProviderName()
+ .equals(pDimDef.getChunkProviderName())) {
+ // Cannot add DimensionDefinition; The Given chunk-provider name is already taken!
+ return false;
+ }
+ }
+
+ // Set the parent modName of this dimension. This will finalize it
+ pDimDef.setParentModName(_mModName);
+ _mDimensionLookup.add(pDimDef);
+ return true;
+ }
+}
diff --git a/src/main/java/bloodasp/galacticgreg/api/ModDBMDef.java b/src/main/java/bloodasp/galacticgreg/api/ModDBMDef.java
new file mode 100644
index 0000000000..bd0df8652b
--- /dev/null
+++ b/src/main/java/bloodasp/galacticgreg/api/ModDBMDef.java
@@ -0,0 +1,165 @@
+package bloodasp.galacticgreg.api;
+
+import net.minecraft.block.Block;
+
+import bloodasp.galacticgreg.api.Enums.ReplaceState;
+
+/**
+ * Mod "Dimension Block Meta Definition" Defines the Block-Meta combination for Blocks that can be replaced by the
+ * oregen.
+ *
+ */
+public class ModDBMDef {
+
+ private String _targetBlockName;
+ private int _targetMeta;
+ private boolean _canAlwaysReplace;
+
+ public String getBlockName() {
+ return _targetBlockName;
+ }
+
+ public int getMeta() {
+ return _targetMeta;
+ }
+
+ public boolean getCanAlwaysReplace() {
+ return _canAlwaysReplace;
+ }
+
+ /**
+ * Internal function
+ *
+ * Check if the given Block is equal to the block in this instance
+ *
+ * @param pBlock the Block in question
+ * @return
+ */
+ public ReplaceState blockEquals(Block pBlock) {
+ if (pBlock == null) return ReplaceState.Unknown;
+
+ if (Block.blockRegistry.getNameForObject(pBlock)
+ .equals(_targetBlockName)) return ReplaceState.CanReplace;
+ else return ReplaceState.CannotReplace;
+ }
+
+ /**
+ * Internal function
+ *
+ * Check if the given Block is equal to the block in this instance and matches the metadata
+ *
+ * @param pBlock the block in question
+ * @param pMeta the metadata in question
+ * @return
+ */
+ public ReplaceState blockEquals(Block pBlock, int pMeta) {
+ ReplaceState tFlag = ReplaceState.Unknown;
+ if (blockEquals(pBlock) == ReplaceState.CanReplace) {
+ if (pMeta == _targetMeta || _canAlwaysReplace) tFlag = ReplaceState.CanReplace;
+ else tFlag = ReplaceState.CannotReplace;
+ }
+
+ return tFlag;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) return false;
+ if (other == this) return true;
+ if (!(other instanceof ModDBMDef)) return false;
+ ModDBMDef otherModDBMDef = (ModDBMDef) other;
+ return (otherModDBMDef._targetBlockName.equals(_targetBlockName) && otherModDBMDef._targetMeta == _targetMeta);
+ }
+
+ /**
+ * Create a new "Block that can be replaced by ores" definition. Meta defaults to 0 here
+ *
+ * @param pTargetBlockName The unlocalizedName of the block
+ */
+ public ModDBMDef(String pTargetBlockName) {
+ this(pTargetBlockName, 0, false);
+ }
+
+ /**
+ * Create a new "Block that can be replaced by ores" definition
+ *
+ * @param pTargetBlockName The unlocalizedName of the block
+ * @param pMetaData The blocks metadata
+ */
+ public ModDBMDef(String pTargetBlockName, int pMetaData) {
+ this(pTargetBlockName, pMetaData, false);
+ }
+
+ /**
+ * Create a new "Block that can be replaced by ores" definition
+ *
+ * @param pTargetBlock The instance of the block that can be replaced
+ * @param pMetaData The blocks metadata
+ */
+ public ModDBMDef(Block pTargetBlock, int pMetaData) {
+ this(Block.blockRegistry.getNameForObject(pTargetBlock), pMetaData, false);
+ }
+
+ /**
+ * Create a new "Block that can be replaced by ores" definition. Meta defaults to 0 here
+ *
+ * @param pTargetBlock The instance of the block that can be replaced
+ */
+ public ModDBMDef(Block pTargetBlock) {
+ this(Block.blockRegistry.getNameForObject(pTargetBlock), 0, false);
+ }
+
+ /**
+ * Create a new "Block that can be replaced by ores" definition
+ *
+ * @param pTargetBlock
+ * @param pCanAlwaysReplace set to true if this block can always be replaced, regardless of it's metavalue. Like:
+ * [block]:*
+ */
+ public ModDBMDef(Block pTargetBlock, boolean pCanAlwaysReplace) {
+ this(Block.blockRegistry.getNameForObject(pTargetBlock), -1, pCanAlwaysReplace);
+ }
+
+ /**
+ * Create a new "Block that can be replaced by ores" definition
+ *
+ * @param pTargetBlockName The unlocalizedName of the block
+ * @param pCanAlwaysReplace set to true if this block can always be replaced, regardless of it's metavalue. Like:
+ * [block]:*
+ */
+ public ModDBMDef(String pTargetBlockName, boolean pCanAlwaysReplace) {
+ this(pTargetBlockName, -1, false);
+ }
+
+ /**
+ * Create a new "Block that can be replaced by ores" definition
+ *
+ * @param pTargetBlockName The unlocalizedName of the block
+ * @param pMetaData The blocks metadata
+ * @param pCanAlwaysReplace set to true if this block can always be replaced, regardless of it's metavalue. Like:
+ * [block]:*
+ */
+ public ModDBMDef(String pTargetBlockName, int pMetaData, boolean pCanAlwaysReplace) {
+ _targetBlockName = pTargetBlockName;
+ _targetMeta = pMetaData;
+ _canAlwaysReplace = pCanAlwaysReplace;
+ }
+
+ /**
+ * Internal function Never run this function. It is used to update the blocks name when GalacticGreg is initializing
+ * its internal structures
+ *
+ * @param pParentModName The modname to be attached to the block-name
+ */
+ public void updateBlockName(String pParentModName) {
+ // Do we already have a FQBN? then do nothing
+ if (_targetBlockName.contains(":")) {
+ // GalacticGreg.Logger.trace("Not updating blockname, as it already contains a mods name: %s",
+ // _targetBlockName);
+ return;
+ }
+ // GalacticGreg.Logger.trace("Updating blockname: Old: %s new: %s:%s", _targetBlockName, pParentModName,
+ // _targetBlockName);
+ _targetBlockName = String.format("%s:%s", pParentModName, _targetBlockName);
+ }
+}
diff --git a/src/main/java/bloodasp/galacticgreg/api/ModDimensionDef.java b/src/main/java/bloodasp/galacticgreg/api/ModDimensionDef.java
new file mode 100644
index 0000000000..4b634173f1
--- /dev/null
+++ b/src/main/java/bloodasp/galacticgreg/api/ModDimensionDef.java
@@ -0,0 +1,470 @@
+package bloodasp.galacticgreg.api;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import net.minecraft.block.Block;
+import net.minecraft.world.chunk.IChunkProvider;
+
+import bloodasp.galacticgreg.api.Enums.AirReplaceRule;
+import bloodasp.galacticgreg.api.Enums.DimensionType;
+import bloodasp.galacticgreg.api.Enums.ReplaceState;
+import bloodasp.galacticgreg.api.Enums.SpaceObjectType;
+
+// import bloodasp.galacticgreg.GalacticGreg;
+
+/**
+ * Class to define a Dimension. Supposed to be added to a ModContainer
+ */
+public class ModDimensionDef {
+
+ private static final String STR_NOTDEFINED = "iiznotdefined";
+ private String _mDimensionName;
+ private String _mInternalDimIdentifier;
+ private String _mChunkProvider;
+ private AirReplaceRule _mDimAirSetting;
+ private ArrayList<ModDBMDef> _mReplaceableBlocks;
+ private DimensionType _mDimensionType;
+
+ private List<ISpaceObjectGenerator> _mSpaceObjectsGenerators;
+ private List<ISpaceObjectGenerator> _mSpaceStructureGenerators;
+
+ // Special Planets config settings
+ private int _mGroundOreMaxY = 64;
+ private int _mFloatingAsteroidsMinY = 128;
+ // ------
+
+ // Override for stonetype
+ private GTOreTypes _mStoneType;
+
+ // Asteroid stuff
+ private List<AsteroidBlockComb> _mValidAsteroidMaterials;
+ private List<SpecialBlockComb> _mSpecialBlocksForAsteroids;
+
+ private Random _mRandom = new Random(System.currentTimeMillis());
+
+ /**
+ * Internal function
+ *
+ * @return A list of possible asteroid-mixes that shall be generated
+ */
+ public List<AsteroidBlockComb> getValidAsteroidMaterials() {
+ return _mValidAsteroidMaterials;
+ }
+
+ // =================================================
+ /**
+ * Internal function The only purpose of this functions is to get a default config value for this dim, that can be
+ * altered by the mod author which adds the dimension definition to his mod, but also provide the
+ * modpack-author/serveradmin to change these values aswell
+ */
+ public int getPreConfiguratedGroundOreMaxY() {
+ return _mGroundOreMaxY;
+ }
+
+ /**
+ * Internal function The only purpose of this functions is to get a default config value for this dim, that can be
+ * altered by the mod author which adds the dimension definition to his mod, but also provide the
+ * modpack-author/serveradmin to change these values aswell
+ */
+ public int getPreConfiguratedFloatingAsteroidMinY() {
+ return _mFloatingAsteroidsMinY;
+ }
+
+ /**
+ * Register new generator for objects in space. You can register as many as you want. If you don't register
+ * anything, no structures will generate and the default Asteroid-Generator will be used
+ *
+ * @param pSpaceObjectGenerator An instance of your own object generator
+ */
+ public void registerSpaceObjectGenerator(ISpaceObjectGenerator pSpaceObjectGenerator) {
+ SpaceObjectType tType = pSpaceObjectGenerator.getType();
+ switch (tType) {
+ case NonOreSchematic:
+ _mSpaceStructureGenerators.add(pSpaceObjectGenerator);
+ break;
+ case OreAsteroid:
+ _mSpaceObjectsGenerators.add(pSpaceObjectGenerator);
+ break;
+ default:
+ // GalacticGreg.Logger.error("registerSpaceObjectGenerator() found unhandled generator type %s. Please
+ // report asap, the author was lazy!", tType.toString());
+ break;
+
+ }
+ }
+
+ /**
+ * Internal function Return a random generator for space objects
+ */
+ public ISpaceObjectGenerator getRandomSOGenerator(SpaceObjectType pTargetType) {
+ ISpaceObjectGenerator tGen = null;
+ List<ISpaceObjectGenerator> tLst = null;
+ try {
+ switch (pTargetType) {
+ case NonOreSchematic:
+ tLst = _mSpaceStructureGenerators;
+ break;
+ case OreAsteroid:
+ tLst = _mSpaceObjectsGenerators;
+ break;
+ default:
+ break;
+ }
+
+ if (tLst != null) {
+ if (tLst.size() == 1) tGen = tLst.get(0);
+ else if (tLst.size() > 1) tGen = tLst.get(_mRandom.nextInt(tLst.size()));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return tGen;
+ }
+
+ /**
+ * Define the default values for the floating asteroids and the oregen here. As both generators run in the same
+ * dimension, and you probably don't want to have asteroids stuck in the ground, both generators are separated from
+ * each other. Basically, you can go with the default values. If you want to change them, make sure that pOregenMaxY
+ * is lower than pAsteroidMinY
+ *
+ * @param pOregenMaxY The maximum Y-height where ores will be allowed to spawn. Default: 64
+ * @param pAsteroidMinY The minimum Y-height that has to be reached before asteroids will spawn. Default: 128
+ * @throws IllegalArgumentException if the limits are invalid
+ *
+ */
+ public void setAsteroidAndPlanetLimits(int pOregenMaxY, int pAsteroidMinY) {
+ if (pOregenMaxY >= pAsteroidMinY)
+ throw new IllegalArgumentException("pOregenMaxY must be LOWER than pAsteroidMinY!");
+
+ _mFloatingAsteroidsMinY = pAsteroidMinY;
+ _mGroundOreMaxY = pOregenMaxY;
+ }
+ // =================================================
+
+ /**
+ * Internal function
+ *
+ * @return A list of all special blocks that shall be used to generate the asteroids.
+ */
+ public List<SpecialBlockComb> getSpecialBlocksForAsteroids() {
+ return _mSpecialBlocksForAsteroids;
+ }
+
+ public List<ISpaceObjectGenerator> getSpaceObjectGenerators() {
+ return _mSpaceObjectsGenerators;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The type for this dimension
+ */
+ public DimensionType getDimensionType() {
+ return _mDimensionType;
+ }
+
+ /**
+ * Set whether this DimensionDefinition defines an void-dimension that shall spawn asteroids instead of ores in
+ * stone
+ *
+ * @param pType The dimensiontype to be used
+ */
+ public void setDimensionType(DimensionType pType) {
+ _mDimensionType = pType;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The configuration for AirBlocks
+ */
+ public AirReplaceRule getAirSetting() {
+ return _mDimAirSetting;
+ }
+
+ /**
+ * Define how the oregen shall handle air-blocks. These settings should be pretty self-explandatory, but anyways:
+ * NeverReplaceAir: No matter what, if there is an Air-Block found, it will not replace it. AllowReplaceAir: This
+ * will generate Ores in Stones (defined by addBlockDefinition()) and air if found OnlyReplaceAir : This will not
+ * generate Ores in solid blocks, but only in air
+ *
+ * Note that "OnlyReplaceAir" is a special setting if you have a dimension that is not defined as "Asteroids" but
+ * you still need/want to generate ores in midair.
+ *
+ * @param pSetting
+ */
+ public void setAirSetting(AirReplaceRule pSetting) {
+ _mDimAirSetting = pSetting;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The dimension identifier that is used internally to identify the dimension
+ */
+ public String getDimIdentifier() {
+ return _mInternalDimIdentifier;
+ }
+
+ /**
+ * Set a manual override for ores that shall be generated. This setting is ignored if getIsAsteroidDimension()
+ * returns true
+ *
+ * For example, on GalactiCraft Mars, this value is set to GTOreTypes.RedGranite, because it matches the color
+ * better. If you don't set anything here, it will generate regular stone-ores.
+ *
+ * @param pStoneType
+ */
+ public void setStoneType(GTOreTypes pStoneType) {
+ _mStoneType = pStoneType;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The stone override for gregtech ores
+ */
+ public GTOreTypes getStoneType() {
+ return _mStoneType;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The attached chunk-provider for this dimension
+ */
+ public String getChunkProviderName() {
+ return _mChunkProvider;
+ }
+
+ /**
+ * Adds a new blockdefinition to this dimension. This block will then later be replaced by ores. You can add as many
+ * blocks as you want. Just don't add Blocks.Air, as there is another setting for allowing Air-Replacement
+ *
+ * @param pBlockDef
+ * @return
+ */
+ public boolean addBlockDefinition(ModDBMDef pBlockDef) {
+ if (_mReplaceableBlocks.contains(pBlockDef)) {
+ // GalacticGreg.Logger.error("Cannot add Block %s:%d, as it is already existing!", pBlockDef.getBlockName(),
+ // pBlockDef.getMeta());
+ return false;
+ } else {
+ _mReplaceableBlocks.add(pBlockDef);
+ return true;
+ }
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The DimensionName in a Human-readable format
+ */
+ public String getDimensionName() {
+ return _mDimensionName;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return A list of all defined Blocks that can be replaced while generating ores
+ */
+ public ArrayList<ModDBMDef> getReplaceableBlocks() {
+ return _mReplaceableBlocks;
+ }
+
+ /**
+ * Define a new dimension
+ *
+ * @param pDimensionName The human-readable. Spaces will be removed
+ * @param pChunkProvider The chunkprovider class that shall be observed for the oregen
+ */
+ public ModDimensionDef(String pDimensionName, Class<? extends IChunkProvider> pChunkProvider,
+ DimensionType pDimType) {
+ this(
+ pDimensionName,
+ pChunkProvider.toString()
+ .substring(6),
+ pDimType,
+ null);
+ }
+
+ /**
+ * Define a new dimension
+ *
+ * @param pDimensionName The human-readable. Spaces will be removed
+ * @param pChunkProvider The chunkprovider class that shall be observed for the oregen
+ * @param pBlockDefinitions The list of predefined blocks to be replaced by ores
+ */
+ public ModDimensionDef(String pDimensionName, Class<? extends IChunkProvider> pChunkProvider,
+ DimensionType pDimType, List<ModDBMDef> pBlockDefinitions) {
+ this(
+ pDimensionName,
+ pChunkProvider.toString()
+ .substring(6),
+ pDimType,
+ pBlockDefinitions);
+ }
+
+ /**
+ * Define a new dimension
+ *
+ * @param pDimensionName The human-readable DimensionName. Spaces will be removed
+ * @param pChunkProviderName The human-readable, full-qualified classname for the chunkprovider
+ */
+ public ModDimensionDef(String pDimensionName, String pChunkProviderName, DimensionType pDimType) {
+ this(pDimensionName, pChunkProviderName, pDimType, null);
+ }
+
+ /**
+ * Define a new dimension
+ *
+ * @param pDimensionName The human-readable DimensionName. Spaces will be removed
+ * @param pChunkProviderName The human-readable, full-qualified classname for the chunkprovider
+ * @param pBlockDefinitions The list of predefined blocks to be replaced by ores
+ */
+ public ModDimensionDef(String pDimensionName, String pChunkProviderName, DimensionType pDimType,
+ List<ModDBMDef> pBlockDefinitions) {
+ _mInternalDimIdentifier = STR_NOTDEFINED;
+ _mDimensionName = pDimensionName;
+ _mChunkProvider = pChunkProviderName;
+ _mDimensionType = pDimType;
+
+ _mReplaceableBlocks = new ArrayList<>();
+ if (pBlockDefinitions != null) _mReplaceableBlocks.addAll(pBlockDefinitions);
+
+ _mValidAsteroidMaterials = new ArrayList<>();
+ _mSpecialBlocksForAsteroids = new ArrayList<>();
+ _mSpaceObjectsGenerators = new ArrayList<>();
+ _mSpaceStructureGenerators = new ArrayList<>();
+ }
+
+ /**
+ * Internal function
+ *
+ * Do not call this function by yourself. Ever. It will cause explosions, water to blood, death of firstborn,...
+ * Seriously, don't do it.
+ */
+ protected void setParentModName(String pModName) {
+ if (_mInternalDimIdentifier.equals(STR_NOTDEFINED)) {
+ _mInternalDimIdentifier = String.format("%s_%s", pModName, _mDimensionName);
+ // GalacticGreg.Logger.debug("Set Internal Identifier for Dimension %s to %s", _mDimensionName,
+ // _mInternalDimIdentifier);
+ }
+
+ // Else Don't update, we're already set
+
+ }
+
+ /**
+ * Internal function
+ *
+ * Check if pBlock can be replaced by an ore
+ *
+ * @param pBlock
+ * @param pMeta
+ * @return
+ */
+ public ReplaceState getReplaceStateForBlock(Block pBlock, int pMeta) {
+ ReplaceState tFlag = ReplaceState.Unknown;
+
+ for (ModDBMDef pDef : _mReplaceableBlocks) {
+ ReplaceState tResult = pDef.blockEquals(pBlock, pMeta);
+ if (tResult == ReplaceState.Unknown) continue;
+
+ if (tResult == ReplaceState.CanReplace) {
+ // GalacticGreg.Logger.trace("Targetblock found and metadata match. Replacement allowed");
+ tFlag = ReplaceState.CanReplace;
+ } else if (tResult == ReplaceState.CannotReplace) {
+ // GalacticGreg.Logger.trace("Targetblock found but metadata mismatch. Replacement denied");
+ tFlag = ReplaceState.CannotReplace;
+ }
+ break;
+ }
+
+ return tFlag;
+ }
+
+ /**
+ * Internal function
+ *
+ * Randomly select one material out of all defined materials
+ *
+ * @return
+ */
+ public AsteroidBlockComb getRandomAsteroidMaterial() {
+ if (_mValidAsteroidMaterials.size() == 0) return null;
+
+ if (_mValidAsteroidMaterials.size() == 1) return _mValidAsteroidMaterials.get(0);
+ else {
+ return _mValidAsteroidMaterials.get(_mRandom.nextInt(_mValidAsteroidMaterials.size()));
+ }
+ }
+
+ /**
+ * Internal function
+ *
+ * Randomly select one special block to be placed in the asteroids
+ *
+ * @return
+ */
+ public SpecialBlockComb getRandomSpecialAsteroidBlock() {
+ if (_mSpecialBlocksForAsteroids.size() == 0) return null;
+
+ if (_mSpecialBlocksForAsteroids.size() == 1) return _mSpecialBlocksForAsteroids.get(0);
+ else {
+ return _mSpecialBlocksForAsteroids.get(_mRandom.nextInt(_mSpecialBlocksForAsteroids.size()));
+ }
+ }
+
+ /**
+ * Define the material the asteroid shall be made of. Limited to GT-Based Ores and their stones
+ *
+ * @param pMaterial
+ */
+ public void addAsteroidMaterial(GTOreTypes pMaterial) {
+ addAsteroidMaterial(new AsteroidBlockComb(pMaterial));
+ }
+
+ /**
+ * Define the material the asteroid shall be made of, more advanced option to specify your own blocks
+ *
+ * @param pBlockComb
+ */
+ public void addAsteroidMaterial(AsteroidBlockComb pBlockComb) {
+ if (!_mValidAsteroidMaterials.contains(pBlockComb)) {
+ _mValidAsteroidMaterials.add(pBlockComb);
+ }
+ }
+
+ /**
+ * Adds a new material for asteroid generation. These will spawn randomly in asteroids if enabled. You can basically
+ * add every block you can imagine. Be warned though, if you use Liquids (Water / Lava / ..), it can affect
+ * performance if the liquid is flowing down to the void. So make sure you define "AsteroidCore" as position
+ *
+ * @param pBlock Block-Meta Combination that shall be used
+ */
+ public void addSpecialAsteroidBlock(SpecialBlockComb pBlock) {
+ if (!_mSpecialBlocksForAsteroids.contains(pBlock)) {
+ _mSpecialBlocksForAsteroids.add(pBlock);
+ }
+ }
+
+ /**
+ * Internal function Called when GalacticGreg will finalize all its internal structures. You should never call this
+ * yourself
+ */
+ public void finalizeReplaceableBlocks(String pParentModName) {
+ for (ModDBMDef rpb : _mReplaceableBlocks) {
+ try {
+ rpb.updateBlockName(pParentModName);
+ if (_mStoneType == null) _mStoneType = GTOreTypes.NormalOres;
+ } catch (Exception e) {
+ // GalacticGreg.Logger.error("Unable to finalize replaceable block with modname for block %s. Dimension
+ // %s will probably have problems generating ores", rpb.getBlockName(), _mDimensionName);
+ }
+ }
+ }
+}
diff --git a/src/main/java/bloodasp/galacticgreg/api/SpecialBlockComb.java b/src/main/java/bloodasp/galacticgreg/api/SpecialBlockComb.java
new file mode 100644
index 0000000000..d5f6feb1ca
--- /dev/null
+++ b/src/main/java/bloodasp/galacticgreg/api/SpecialBlockComb.java
@@ -0,0 +1,71 @@
+package bloodasp.galacticgreg.api;
+
+import net.minecraft.block.Block;
+
+import bloodasp.galacticgreg.api.Enums.AllowedBlockPosition;
+
+public class SpecialBlockComb extends BlockMetaComb {
+
+ private AllowedBlockPosition _mBlockPosition;
+
+ /**
+ * Creates a simple instance for a block that has a meta value and a block position it is allowed to spawn
+ *
+ * @param pBlock The Block in question
+ * @param pMeta The meta value of the block
+ * @param pBlockPosition The position this block is allowed to generate
+ */
+ public SpecialBlockComb(Block pBlock, int pMeta, AllowedBlockPosition pBlockPosition) {
+ super(pBlock, pMeta);
+ _mBlockPosition = pBlockPosition;
+ }
+
+ /**
+ * Creates a simple instance for a block that has no meta value but a position it is allowed to spawn
+ *
+ * @param pBlock The Block in question. 0 is used as meta
+ * @param pBlockPosition The position this block is allowed to generate
+ */
+ public SpecialBlockComb(Block pBlock, AllowedBlockPosition pBlockPosition) {
+ super(pBlock, 0);
+ _mBlockPosition = pBlockPosition;
+ }
+
+ /**
+ * Creates a simple instance for a block that has no meta value and is allowed to spawn everywhere
+ *
+ * @param pBlock The Block in question. 0 is used as meta, and "CoreAndShell" is used as position
+ */
+ public SpecialBlockComb(Block pBlock) {
+ super(pBlock, 0);
+ _mBlockPosition = AllowedBlockPosition.AsteroidCoreAndShell;
+ }
+
+ /**
+ * Internal function
+ *
+ * @return The position the block is supposed to spawn at
+ */
+ public AllowedBlockPosition getBlockPosition() {
+ return _mBlockPosition;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) return false;
+ if (other == this) return true;
+ if (!(other instanceof SpecialBlockComb)) return false;
+ SpecialBlockComb otherObj = (SpecialBlockComb) other;
+
+ boolean tFlag = true;
+ String otherName = Block.blockRegistry.getNameForObject(otherObj.getBlock());
+ String thisName = Block.blockRegistry.getNameForObject(this.getBlock());
+ if (!otherName.equals(thisName)) tFlag = false;
+
+ if (!(otherObj.getMeta() == this.getMeta())) tFlag = false;
+
+ if (!(otherObj.getBlockPosition() == this.getBlockPosition())) tFlag = false;
+
+ return tFlag;
+ }
+}
diff --git a/src/main/java/bloodasp/galacticgreg/api/StructureInformation.java b/src/main/java/bloodasp/galacticgreg/api/StructureInformation.java
new file mode 100644
index 0000000000..db205e3ef7
--- /dev/null
+++ b/src/main/java/bloodasp/galacticgreg/api/StructureInformation.java
@@ -0,0 +1,59 @@
+package bloodasp.galacticgreg.api;
+
+import net.minecraft.util.Vec3;
+
+import bloodasp.galacticgreg.api.Enums.TargetBlockPosition;
+
+/**
+ * Structural information container. Holds X/Y/Z and block/meta information
+ */
+public class StructureInformation {
+
+ private Vec3 _mCoordinates;
+ private TargetBlockPosition _mBlockPosition;
+ private BlockMetaComb _mBlockMetaComb;
+
+ public TargetBlockPosition getBlockPosition() {
+ return _mBlockPosition;
+ }
+
+ public int getX() {
+ return (int) Math.round(_mCoordinates.xCoord);
+ }
+
+ public int getY() {
+ return (int) Math.round(_mCoordinates.yCoord);
+ }
+
+ public int getZ() {
+ return (int) Math.round(_mCoordinates.zCoord);
+ }
+
+ public BlockMetaComb getBlock() {
+ return _mBlockMetaComb;
+ }
+
+ /**
+ * Init StructureInfo only with Coords and block position
+ *
+ * @param pCoordinates The coords in question
+ * @param pPosition The position-enum value
+ */
+ public StructureInformation(Vec3 pCoordinates, TargetBlockPosition pPosition) {
+ this(pCoordinates, pPosition, null);
+ }
+
+ /**
+ * Init StructureInfo with Coords, block position and a populated block/meta info
+ *
+ * @param pCoordinates The coords in question
+ * @param pPosition The position-enum value
+ * @param pTargetBlock The target block in question
+ */
+ public StructureInformation(Vec3 pCoordinates, TargetBlockPosition pPosition, BlockMetaComb pTargetBlock) {
+ _mCoordinates = pCoordinates;
+ _mBlockPosition = pPosition;
+ _mBlockMetaComb = pTargetBlock;
+ }
+
+}