diff options
41 files changed, 4610 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..588c403d06 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/bin/ +eclipse/ +.gradle/ +.classpath +.settings/ +gradlew.bat - Verknüpfung.lnk +gradle/ +gradlew.bat +.project diff --git a/GGregLogo.xcf b/GGregLogo.xcf Binary files differnew file mode 100644 index 0000000000..4888998c8a --- /dev/null +++ b/GGregLogo.xcf diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000000..289de1ecfa --- /dev/null +++ b/build.gradle @@ -0,0 +1,84 @@ +buildscript { + repositories { + mavenCentral() + maven { + name = "forge" + url = "http://files.minecraftforge.net/maven" + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } + } + dependencies { + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + } +} + +apply plugin: 'forge' + +// Never remove the MC version or you will break autobuild! +// New 3-segment versioning. 0.9 MUST remain static, as this indicates "GT5" mode of this mod +version = "1.7.10-0.9.1RC1" +group= "bloodasp.galactigreg" // http://maven.apache.org/guides/mini/guide-naming-conventions.html +archivesBaseName = "GalacticGreg" + +minecraft { + version = "1.7.10-10.13.2.1291" + runDir = "eclipse" + + replaceIn "src/main/java/bloodasp/galacticgreg/GalacticGreg.java" + replace "GRADLETOKEN_VERSION", project.version.split('-')[1] +} + +dependencies { + // you may put jars on which you depend on in ./libs + // or you may define them like so.. + //compile "some.group:artifact:version:classifier" + //compile "some.group:artifact:version" + + // real examples + //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env + //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env + + // for more info... + // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html + // http://www.gradle.org/docs/current/userguide/dependency_management.html + +} + +processResources +{ + def cleanVersion = project.version.split('-')[1] + // this will ensure that this task is redone when the versions change. + inputs.property "version", cleanVersion + inputs.property "mcversion", project.minecraft.version + + // replace stuff in mcmod.info, nothing else + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + + // replace version and mcversion + expand 'version':cleanVersion, 'mcversion':project.minecraft.version + } + + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } +} + +task deobfJar(type: Jar) { + from sourceSets.main.output + classifier = 'deobf' +} + +task sourceJar(type: Jar, dependsOn:classes) { + classifier = 'sources' + from sourceSets.main.allJava +} + +artifacts { + archives deobfJar + archives sourceJar +} diff --git a/libs/GalacticraftCore-1.7-3.0.12.341.jar b/libs/GalacticraftCore-1.7-3.0.12.341.jar Binary files differnew file mode 100644 index 0000000000..d1550638c1 --- /dev/null +++ b/libs/GalacticraftCore-1.7-3.0.12.341.jar diff --git a/libs/appliedenergistics2-rv2-stable-7-dev.jar b/libs/appliedenergistics2-rv2-stable-7-dev.jar Binary files differnew file mode 100644 index 0000000000..01e07ffa31 --- /dev/null +++ b/libs/appliedenergistics2-rv2-stable-7-dev.jar diff --git a/libs/gregtech_1.7.10-5.08.18-test.jar b/libs/gregtech_1.7.10-5.08.18-test.jar Binary files differnew file mode 100644 index 0000000000..e8adfd50d3 --- /dev/null +++ b/libs/gregtech_1.7.10-5.08.18-test.jar diff --git a/src/main/java/bloodasp/galacticgreg/GT_TileEntity_Ores_Space.java b/src/main/java/bloodasp/galacticgreg/GT_TileEntity_Ores_Space.java new file mode 100644 index 0000000000..5bd3a8cbb9 --- /dev/null +++ b/src/main/java/bloodasp/galacticgreg/GT_TileEntity_Ores_Space.java @@ -0,0 +1,132 @@ +package bloodasp.galacticgreg; + +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_Log; +import gregtech.common.blocks.GT_TileEntity_Ores; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import bloodasp.galacticgreg.api.Enums.ReplaceState; +import bloodasp.galacticgreg.api.ModDimensionDef; +import bloodasp.galacticgreg.registry.GalacticGregRegistry; + +public class GT_TileEntity_Ores_Space { + + // Renamed function to prevent function shadowing with base GT-code + public static boolean setOuterSpaceOreBlock(ModDimensionDef pDimensionDef, World pWorld, int pX, int pY, int pZ, int pMetaData) { + return setOuterSpaceOreBlock(pDimensionDef, pWorld, pX, pY, pZ, pMetaData, false, -1); + } + + public static boolean setOuterSpaceOreBlock(ModDimensionDef pDimensionDef, World pWorld, int pX, int pY, int pZ, int pMetaData, boolean pAir) { + return setOuterSpaceOreBlock(pDimensionDef, pWorld, pX, pY, pZ, pMetaData, pAir, -1); + } + + /** + * Check if the block at given position may be replaced by an ore + * @param pWorld the world in question + * @param pX X-Cord + * @param pY Y-Cord + * @param pZ Z-Cord + * @return + */ + private static ReplaceState CheckForReplaceableBlock(World pWorld, int pX, int pY, int pZ, ModDimensionDef pDimDef) + { + try + { + ReplaceState tFlag = ReplaceState.Unknown; + + Block targetBlock = pWorld.getBlock(pX, pY, pZ); + int targetBlockMeta = pWorld.getBlockMetadata(pX, pY, pZ); + + if (targetBlock == Blocks.air) + tFlag = ReplaceState.Airblock; + else + tFlag = pDimDef.getReplaceStateForBlock(targetBlock, targetBlockMeta); + + return tFlag; + } + catch(Exception e) + { + e.printStackTrace(GT_Log.err); + GalacticGreg.Logger.error("Error while processing CheckForReplaceableBlock(), defaulting to UNKNOWN"); + return ReplaceState.Unknown; + } + } + + /** + * Actually set the OreBlock + * @param pWorld the world in question + * @param pX + * @param pY + * @param pZ + * @param pMetaData GT-Ore metadata + * @param pAir + * @return + */ + public static boolean setOuterSpaceOreBlock(ModDimensionDef pDimensionDef, World pWorld, int pX, int pY, int pZ, int pMetaData, boolean pAir, int pCustomGTOreOffset) + { + if (!pAir) + pY = Math.min(pWorld.getActualHeight(), Math.max(pY, 1)); + + if (pDimensionDef == null) + { + GalacticGreg.Logger.warn("Unknown DimensionID: %d. Will not set anything here", pWorld.provider.dimensionId); + return false; + } + + Block tBlock = pWorld.getBlock(pX, pY, pZ); + // If the meta is non-zero, and the target block is either non-air or the air-override is active + if ((pMetaData > 0) && ((tBlock != Blocks.air) || pAir)) + { + // make sure we're either going with normal ore-metas, or small ores. + // Probably should do another check for <= 1700 + if (pMetaData < 1000 || pMetaData >= 16000) + { + ReplaceState tRS = CheckForReplaceableBlock(pWorld, pX, pY, pZ, pDimensionDef); + + // Unable to lookup replacement state. Means: The block is unknown, and shall not be replaced + if (tRS == ReplaceState.Unknown) + { + GalacticGreg.Logger.trace("Not placing ore Meta %d, as target block is unknown", pMetaData); + return false; + } + else if(tRS == ReplaceState.Airblock && !pAir) + { + GalacticGreg.Logger.trace("Not placing ore Meta %d in midair, as AIR is FALSE", pMetaData); + return false; + } + if (tRS == ReplaceState.CannotReplace) + { + // wrong metaData ID for target block + GalacticGreg.Logger.trace("Not placing ore Meta %d, as the state is CANNOTREPLACE", pMetaData); + return false; + } + + if (pCustomGTOreOffset == -1) + pMetaData += pDimensionDef.getStoneType().getOffset(); + else + pMetaData += pCustomGTOreOffset; + + pWorld.setBlock(pX, pY, pZ, GregTech_API.sBlockOres1, GT_TileEntity_Ores.getHarvestData((short) pMetaData), 0); + TileEntity tTileEntity = pWorld.getTileEntity(pX, pY, pZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + ((GT_TileEntity_Ores) tTileEntity).mMetaData = ((short) pMetaData); + ((GT_TileEntity_Ores) tTileEntity).mNatural = true; + } + else + { + // This is somehow triggered randomly, and most times the target block is air, which should never happen as we check for air... + // That's why I put this behind a debug config option. If you ever find the reason for it, please tell me what caused this + if (GalacticGreg.GalacticConfig.ReportOreGenFailures) + GalacticGreg.Logger.warn("Something went wrong while placing GT OreTileEntity. Meta: %d X [%d] Y [%d] Z [%d]", pMetaData, pX, pY, pZ); + } + + return true; + } + else + GalacticGreg.Logger.warn("Not replacing block at pos %d %d %d due unexpected metaData for OreBlock: %d", pX, pY, pZ, pMetaData); + } + return false; + } +} diff --git a/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_Layer_Space.java b/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_Layer_Space.java new file mode 100644 index 0000000000..fb3f9a13ea --- /dev/null +++ b/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_Layer_Space.java @@ -0,0 +1,193 @@ +package bloodasp.galacticgreg; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Log; +import gregtech.api.world.GT_Worldgen; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import bloodasp.galacticgreg.api.ModDimensionDef; +import bloodasp.galacticgreg.auxiliary.GTOreGroup; +import bloodasp.galacticgreg.dynconfig.DynamicOreMixWorldConfig; +import bloodasp.galacticgreg.registry.GalacticGregRegistry; + +public class GT_Worldgen_GT_Ore_Layer_Space extends GT_Worldgen { + public static int sWeight = 0; + public final short mMinY; + public final short mMaxY; + public final short mWeight; + public final short mDensity; + public final short mSize; + public final short mPrimaryMeta; + public final short mSecondaryMeta; + public final short mBetweenMeta; + public final short mSporadicMeta; + + private long mProfilingStart; + private long mProfilingEnd; + + private DynamicOreMixWorldConfig _mDynWorldConfig = null; + + public GT_Worldgen_GT_Ore_Layer_Space(String pName, boolean pDefault, int pMinY, int pMaxY, int pWeight, int pDensity, int pSize, Materials pPrimary, Materials pSecondary, Materials pBetween, Materials pSporadic) + { + super(pName, GalacticGreg.oreVeinWorldgenList, pDefault); + mMinY = ((short) GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "MinHeight", pMinY)); + mMaxY = ((short) Math.max(this.mMinY + 5, GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "MaxHeight", pMaxY))); + mWeight = ((short) GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "RandomWeight", pWeight)); + mDensity = ((short) GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "Density", pDensity)); + mSize = ((short) Math.max(1, GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "Size", pSize))); + mPrimaryMeta = ((short) GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "OrePrimaryLayer", pPrimary.mMetaItemSubID)); + mSecondaryMeta = ((short) GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "OreSecondaryLayer", pSecondary.mMetaItemSubID)); + mBetweenMeta = ((short) GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "OreSporadiclyInbetween", pBetween.mMetaItemSubID)); + mSporadicMeta = ((short) GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "OreSporaticlyAround", pSporadic.mMetaItemSubID)); + + _mDynWorldConfig = new DynamicOreMixWorldConfig(mWorldGenName); + _mDynWorldConfig.InitDynamicConfig(); + + GalacticGreg.Logger.trace("Initialized new OreLayer: %s", pName); + + if (mEnabled) + sWeight += this.mWeight; + + } + + /** + * Check if *this* orelayer is enabled for pDimensionDef + * @param pDimensionDef the ChunkProvider in question + * @return + */ + public boolean isEnabledForDim(ModDimensionDef pDimensionDef) + { + return _mDynWorldConfig.isEnabledInDim(pDimensionDef); + } + + /** + * Select a random ore-vein from the list + * + * @param pDimensionDef + * @param pRandom + * @return + */ + public static GTOreGroup getRandomOreGroup(ModDimensionDef pDimensionDef, Random pRandom) + { + short primaryMeta = 0; + short secondaryMeta = 0; + short betweenMeta = 0; + short sporadicMeta = 0; + if ((GT_Worldgen_GT_Ore_Layer_Space.sWeight > 0) && (GalacticGreg.oreVeinWorldgenList.size() > 0)) + { + GalacticGreg.Logger.trace("About to select oremix"); + boolean temp = true; + int tRandomWeight; + for (int i = 0; (i < 256) && (temp); i++) + { + tRandomWeight = pRandom.nextInt(GT_Worldgen_GT_Ore_Layer_Space.sWeight); + for (GT_Worldgen_GT_Ore_Layer_Space tWorldGen : GalacticGreg.oreVeinWorldgenList) + { + tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mWeight; + if (tRandomWeight <= 0) + { + + try + { + if (tWorldGen.isEnabledForDim(pDimensionDef)) + { + GalacticGreg.Logger.trace("Using Oremix %s for asteroid", tWorldGen.mWorldGenName); + primaryMeta = tWorldGen.mPrimaryMeta; + secondaryMeta = tWorldGen.mSecondaryMeta; + betweenMeta = tWorldGen.mBetweenMeta; + sporadicMeta = tWorldGen.mSporadicMeta; + + temp = false; + break; + } + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + } + } + } + } + if (primaryMeta != 0 || secondaryMeta != 0 || betweenMeta != 0 || sporadicMeta != 0) + return new GTOreGroup(primaryMeta, secondaryMeta, betweenMeta, sporadicMeta); + else + return null; + } + + @Override + public boolean executeWorldgen(World pWorld, Random pRandom, String pBiome, int pDimensionType, int pChunkX, int pChunkZ, IChunkProvider pChunkGenerator, IChunkProvider pChunkProvider) + { + GalacticGreg.Logger.trace("Entering executeWorldgen for [%s]", mWorldGenName); + ModDimensionDef tMDD = GalacticGregRegistry.getDimensionTypeByChunkGenerator(pChunkProvider); + if (tMDD == null) + { + GalacticGreg.Logger.trace("Can't find dimension definition for ChunkProvider %s, skipping", pChunkProvider.toString()); + return false; + } + + if (!_mDynWorldConfig.isEnabledInDim(tMDD)) + { + GalacticGreg.Logger.trace("OreGen for %s is disallowed in dimension %s, skipping", mWorldGenName, tMDD.getDimensionName()); + return false; + } + + if (GalacticGreg.GalacticConfig.ProfileOreGen) + mProfilingStart = System.currentTimeMillis(); + // --------------------------- + int tMinY = this.mMinY + pRandom.nextInt(this.mMaxY - this.mMinY - 5); + + int cX = pChunkX - pRandom.nextInt(this.mSize); + int eX = pChunkX + 16 + pRandom.nextInt(this.mSize); + for (int tX = cX; tX <= eX; tX++) { + int cZ = pChunkZ - pRandom.nextInt(this.mSize); + int eZ = pChunkZ + 16 + pRandom.nextInt(this.mSize); + for (int tZ = cZ; tZ <= eZ; tZ++) { + if (this.mSecondaryMeta > 0) { + for (int i = tMinY - 1; i < tMinY + 2; i++) { + if ((pRandom.nextInt(Math.max(1, Math.max(Math.abs(cZ - tZ), Math.abs(eZ - tZ)) / this.mDensity)) == 0) + || (pRandom.nextInt(Math.max(1, Math.max(Math.abs(cX - tX), Math.abs(eX - tX)) / this.mDensity)) == 0)) { + GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(tMDD, pWorld, tX, i, tZ, this.mSecondaryMeta); + } + } + } + if ((this.mBetweenMeta > 0) + && ((pRandom.nextInt(Math.max(1, Math.max(Math.abs(cZ - tZ), Math.abs(eZ - tZ)) / this.mDensity)) == 0) || (pRandom.nextInt(Math.max(1, + Math.max(Math.abs(cX - tX), Math.abs(eX - tX)) / this.mDensity)) == 0))) { + GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(tMDD, pWorld, tX, tMinY + 2 + pRandom.nextInt(2), tZ, this.mBetweenMeta); + } + if (this.mPrimaryMeta > 0) { + for (int i = tMinY + 3; i < tMinY + 6; i++) { + if ((pRandom.nextInt(Math.max(1, Math.max(Math.abs(cZ - tZ), Math.abs(eZ - tZ)) / this.mDensity)) == 0) + || (pRandom.nextInt(Math.max(1, Math.max(Math.abs(cX - tX), Math.abs(eX - tX)) / this.mDensity)) == 0)) { + + GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(tMDD, pWorld, tX, i, tZ, this.mPrimaryMeta); + } + } + } + if ((this.mSporadicMeta > 0) + && ((pRandom.nextInt(Math.max(1, Math.max(Math.abs(cZ - tZ), Math.abs(eZ - tZ)) / this.mDensity)) == 0) || (pRandom.nextInt(Math.max(1, + Math.max(Math.abs(cX - tX), Math.abs(eX - tX)) / this.mDensity)) == 0))) { + GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(tMDD, pWorld, tX, tMinY - 1 + pRandom.nextInt(7), tZ, this.mSporadicMeta); + } + } + } + // --------------------------- + if (GalacticGreg.GalacticConfig.ProfileOreGen) + { + try { + mProfilingEnd = System.currentTimeMillis(); + long tTotalTime = mProfilingEnd - mProfilingStart; + GalacticGreg.Profiler.AddTimeToList(tMDD, tTotalTime); + GalacticGreg.Logger.debug("Done with OreLayer-Worldgen in DimensionType %s. Generation took %d ms", tMDD.getDimensionName(), tTotalTime); + } catch (Exception e) { } // Silently ignore errors + } + + + GalacticGreg.Logger.trace("Leaving executeWorldgen"); + return true; + } +} diff --git a/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_SmallPieces_Space.java b/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_SmallPieces_Space.java new file mode 100644 index 0000000000..eaf07907ed --- /dev/null +++ b/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_SmallPieces_Space.java @@ -0,0 +1,95 @@ +package bloodasp.galacticgreg; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.world.GT_Worldgen; + +import java.util.Random; + +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import bloodasp.galacticgreg.api.ModDimensionDef; +import bloodasp.galacticgreg.dynconfig.DynamicOreMixWorldConfig; +import bloodasp.galacticgreg.registry.GalacticGregRegistry; + +public class GT_Worldgen_GT_Ore_SmallPieces_Space extends GT_Worldgen { + public final short mMinY; + public final short mMaxY; + public final short mAmount; + public final short mMeta; + + private long mProfilingStart; + private long mProfilingEnd; + private DynamicOreMixWorldConfig _mDynWorldConfig = null; + + public GT_Worldgen_GT_Ore_SmallPieces_Space(String pName, boolean pDefault, int pMinY, int pMaxY, int pAmount, Materials pPrimary) + { + super(pName, GalacticGreg.smallOreWorldgenList, pDefault); + + mMinY = ((short) GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "MinHeight", pMinY)); + mMaxY = ((short) Math.max(this.mMinY + 1, GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "MaxHeight", pMaxY))); + mAmount = ((short) Math.max(1, GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "Amount", pAmount))); + mMeta = ((short) GregTech_API.sWorldgenFile.get("worldgen." + this.mWorldGenName, "Ore", pPrimary.mMetaItemSubID)); + + _mDynWorldConfig = new DynamicOreMixWorldConfig(mWorldGenName); + _mDynWorldConfig.InitDynamicConfig(); + + GalacticGreg.Logger.trace("Initialized new OreLayer: %s", pName); + } + + /** + * Check if *this* orelayer is enabled for pDimensionDef + * @param pDimensionDef the ChunkProvider in question + * @return + */ + public boolean isEnabledForDim(ModDimensionDef pDimensionDef) + { + return _mDynWorldConfig.isEnabledInDim(pDimensionDef); + } + + @Override + public boolean executeWorldgen(World pWorld, Random pRandom, String pBiome, int pDimensionType, int pChunkX, int pChunkZ, IChunkProvider pChunkGenerator, IChunkProvider pChunkProvider) + { + GalacticGreg.Logger.trace("Entering executeWorldgen for [%s]", mWorldGenName); + ModDimensionDef tMDD = GalacticGregRegistry.getDimensionTypeByChunkGenerator(pChunkProvider); + if (tMDD == null) + { + GalacticGreg.Logger.trace("Can't find dimension definition for ChunkProvider %s, skipping", pChunkProvider.toString()); + return false; + } + + if (!_mDynWorldConfig.isEnabledInDim(tMDD)) + { + GalacticGreg.Logger.trace("OreGen for %s is disallowed in dimension %s, skipping", mWorldGenName, tMDD.getDimensionName()); + return false; + } + + if (GalacticGreg.GalacticConfig.ProfileOreGen) + mProfilingStart = System.currentTimeMillis(); + // --------------------------- + + if (this.mMeta > 0) { + int i = 0; + for (int j = Math.max(1, this.mAmount / 2 + pRandom.nextInt(this.mAmount) / 2); i < j; i++) { + GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(tMDD, pWorld, pChunkX + pRandom.nextInt(16), this.mMinY + pRandom.nextInt(Math.max(1, this.mMaxY - this.mMinY)), pChunkZ + pRandom.nextInt(16), this.mMeta + 16000); + } + } + // --------------------------- + if (GalacticGreg.GalacticConfig.ProfileOreGen) + { + try { + mProfilingEnd = System.currentTimeMillis(); + long tTotalTime = mProfilingEnd - mProfilingStart; + GalacticGreg.Profiler.AddTimeToList(tMDD, tTotalTime); + GalacticGreg.Logger.debug("Done with SmallOre-Worldgen in DimensionType %s. Generation took %d ms", tMDD.getDimensionName(), tTotalTime); + } catch (Exception e) { } // Silently ignore errors + } + + GalacticGreg.Logger.trace("Leaving executeWorldgen"); + return true; + } + + public boolean isAllowedForHeight(int pTargetHeight) { + return (pTargetHeight >= mMinY && pTargetHeight <= mMaxY); + } +} diff --git a/src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java b/src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java new file mode 100644 index 0000000000..0666350267 --- /dev/null +++ b/src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java @@ -0,0 +1,518 @@ +package bloodasp.galacticgreg; + +import gregtech.api.util.GT_Log; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.Vec3; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraftforge.common.ChestGenHooks; +import bloodasp.galacticgreg.api.AsteroidBlockComb; +import bloodasp.galacticgreg.api.BlockMetaComb; +import bloodasp.galacticgreg.api.Enums.DimensionType; +import bloodasp.galacticgreg.api.Enums.SpaceObjectType; +import bloodasp.galacticgreg.api.Enums.TargetBlockPosition; +import bloodasp.galacticgreg.api.GTOreTypes; +import bloodasp.galacticgreg.api.ISpaceObjectGenerator; +import bloodasp.galacticgreg.api.ModDimensionDef; +import bloodasp.galacticgreg.api.SpecialBlockComb; +import bloodasp.galacticgreg.api.StructureInformation; +import bloodasp.galacticgreg.auxiliary.GTOreGroup; +import bloodasp.galacticgreg.dynconfig.DynamicDimensionConfig; +import bloodasp.galacticgreg.dynconfig.DynamicDimensionConfig.AsteroidConfig; +import bloodasp.galacticgreg.registry.GalacticGregRegistry; +import cpw.mods.fml.common.IWorldGenerator; +import cpw.mods.fml.common.eventhandler.EventBus; +import cpw.mods.fml.common.registry.GameRegistry; + +public class GT_Worldgenerator_Space implements IWorldGenerator { + public static boolean sAsteroids = true; + private final EventBus eventBus = new EventBus(); + private World worldObj; + + private int chunkX; + private int chunkZ; + private int mSize = 100; + + private long mProfilingStart; + private long mProfilingEnd; + + public GT_Worldgenerator_Space() { + GameRegistry.registerWorldGenerator(this, Integer.MAX_VALUE); + } + + public void generate(Random pRandom, int pX, int pZ, World pWorld, IChunkProvider pChunkGenerator, IChunkProvider pChunkProvider) + { + pX *= 16; + pZ *= 16; + + String tBiome = pWorld.getBiomeGenForCoords(pX + 8, pZ + 8).biomeName; + pRandom = new Random(pRandom.nextInt()); + if (tBiome == null) { + tBiome = BiomeGenBase.plains.biomeName; + } + GalacticGreg.Logger.trace("Triggered generate: [ChunkGenerator %s] [Biome %s]", pChunkGenerator.toString(), tBiome); + + ModDimensionDef tDimDef = GalacticGregRegistry.getDimensionTypeByChunkGenerator(pChunkGenerator); + + if (tDimDef == null) + { + GalacticGreg.Logger.trace("Ignoring ChunkGenerator type %s as there is no definition for it in the registry", pChunkGenerator.toString()); + return; + } + else + { + GalacticGreg.Logger.trace("Selected DimDef: [%s]", tDimDef.getDimIdentifier()); + } + + + /* In some later addons maybe, not for now. Ignoring Biome-based worldgen + String tBiome = pWorld.getBiomeGenForCoords(pX + 8, pZ + 8).biomeName; + pRandom = new Random(pRandom.nextInt()); + if (tBiome == null) { + tBiome = BiomeGenBase.plains.biomeName; + }*/ + + if (tDimDef.getDimensionType() == DimensionType.Asteroid || tDimDef.getDimensionType() == DimensionType.AsteroidAndPlanet) + { + if (tDimDef.getRandomAsteroidMaterial() == null) + GalacticGreg.Logger.error("Dimension [%s] is set to Asteroids, but no asteroid material is specified! Nothing will generate", tDimDef.getDimensionName()); + else + Generate_Asteroids(tDimDef, pRandom, pWorld, pX, pZ); + } + else if (tDimDef.getDimensionType() == DimensionType.Planet || tDimDef.getDimensionType() == DimensionType.AsteroidAndPlanet) + { + Generate_OreVeins(tDimDef, pRandom, pWorld, pX, pZ, "", pChunkGenerator, pChunkProvider); + } + + Chunk tChunk = pWorld.getChunkFromBlockCoords(pX, pZ); + if (tChunk != null) { + tChunk.isModified = true; + } + } + + private void Generate_Asteroids(ModDimensionDef pDimensionDef, Random pRandom, World pWorld, int pX, int pZ) + { + GalacticGreg.Logger.trace("Running asteroid-gen in Dim %s", pDimensionDef.getDimIdentifier()); + + AsteroidConfig tAConf = DynamicDimensionConfig.getAsteroidConfig(pDimensionDef); + if (tAConf == null) + { + |
