diff options
author | Martin Robertz <dream-master@gmx.net> | 2019-11-02 17:20:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-02 17:20:22 +0100 |
commit | 9557527c7d92682438e7a0d48d6724d6253da001 (patch) | |
tree | 1d7063589ee1dbacd9aa885fec0037e6ddc1a3b1 | |
parent | 978129e4e0d5c9202baa3849824e236210d20ca2 (diff) | |
parent | 25644b38b3f1063d98abcb9fa1770b0223c0015e (diff) | |
download | GT5-Unofficial-9557527c7d92682438e7a0d48d6724d6253da001.tar.gz GT5-Unofficial-9557527c7d92682438e7a0d48d6724d6253da001.tar.bz2 GT5-Unofficial-9557527c7d92682438e7a0d48d6724d6253da001.zip |
Merge pull request #7 from GTNewHorizons/bartworksIntegration
Bartworks integration
-rw-r--r-- | .gitignore | 10 | ||||
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | build.properties | 2 | ||||
-rw-r--r-- | libs/bartworks[1.7.10]-0.5.2_pre25-dev.jar | bin | 0 -> 786290 bytes | |||
-rw-r--r-- | src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_Layer_Space.java | 49 | ||||
-rw-r--r-- | src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java | 87 | ||||
-rw-r--r-- | src/main/java/bloodasp/galacticgreg/GalacticGreg.java | 27 | ||||
-rw-r--r-- | src/main/java/bloodasp/galacticgreg/ModRegisterer.java | 10 | ||||
-rw-r--r-- | src/main/java/bloodasp/galacticgreg/bartworks/BW_Worldgen_Ore_Layer_Space.java | 107 | ||||
-rw-r--r-- | src/main/java/bloodasp/galacticgreg/bartworks/BW_Worldgen_Ore_SmallOre_Space.java | 101 | ||||
-rw-r--r-- | src/main/java/bloodasp/galacticgreg/dynconfig/DynamicOreMixWorldConfig.java | 8 |
11 files changed, 330 insertions, 73 deletions
diff --git a/.gitignore b/.gitignore index e0aa21c8c7..24e8b41c76 100644 --- a/.gitignore +++ b/.gitignore @@ -5,13 +5,11 @@ eclipse/ .settings/ gradlew.bat - Verknüpfung.lnk gradle/ -gradlew.bat .project out/ build.bat *.txt -GalacticGregU.iml -GalacticGregU.ipr -GalacticGregU.iws -*.bat -gradlew
\ No newline at end of file +*.iml +*.ipr +*.iws +*.bat
\ No newline at end of file diff --git a/build.gradle b/build.gradle index b764463078..f5446da7cd 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ group= "bloodasp.galactigreg" // http://maven.apache.org/guides/mini/guide-namin archivesBaseName = "GalacticGreg" minecraft { - version = "${config.forge.version}-${config.minecraft.version}" + version = "1.7.10-10.13.4.1614-1.7.10" runDir = "eclipse" replaceIn "src/main/java/bloodasp/galacticgreg/GalacticGreg.java" diff --git a/build.properties b/build.properties index bf3fcf651c..00d3bec7df 100644 --- a/build.properties +++ b/build.properties @@ -1,3 +1,3 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614 -galactigreg.version=1.7.10-0.9.9 +galactigreg.version=1.7.10-1.0.0 diff --git a/libs/bartworks[1.7.10]-0.5.2_pre25-dev.jar b/libs/bartworks[1.7.10]-0.5.2_pre25-dev.jar Binary files differnew file mode 100644 index 0000000000..9d8d4c46e9 --- /dev/null +++ b/libs/bartworks[1.7.10]-0.5.2_pre25-dev.jar 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 index 9c1f00985e..32b7c7c7e5 100644 --- 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 @@ -1,5 +1,7 @@ package bloodasp.galacticgreg; +import bloodasp.galacticgreg.bartworks.BW_Worldgen_Ore_Layer_Space; +import bloodasp.galacticgreg.bartworks.BW_Worldgen_Ore_SmallOre_Space; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.util.GT_Log; @@ -54,7 +56,7 @@ public class GT_Worldgen_GT_Ore_Layer_Space extends GT_Worldgen { GalacticGreg.Logger.trace("Initialized new OreLayer: %s", pName); if (mEnabled) - sWeight += this.mWeight; + GT_Worldgen_GT_Ore_Layer_Space.sWeight += this.mWeight; } @@ -105,8 +107,8 @@ public class GT_Worldgen_GT_Ore_Layer_Space extends GT_Worldgen { tVal = _mBufferedVeinCountList.get(pDimensionDef.getDimIdentifier()); else { - for (GT_Worldgen_GT_Ore_Layer_Space tWorldGen : GalacticGreg.oreVeinWorldgenList) - if (tWorldGen.isEnabledForDim(pDimensionDef)) + for (GT_Worldgen tWorldGen : GalacticGreg.oreVeinWorldgenList) + if (tWorldGen instanceof GT_Worldgen_GT_Ore_Layer_Space && ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).isEnabledForDim(pDimensionDef)) tVal++; _mBufferedVeinCountList.put(pDimensionDef.getDimIdentifier(), tVal); @@ -131,9 +133,11 @@ public class GT_Worldgen_GT_Ore_Layer_Space extends GT_Worldgen { else { tReturn = new ArrayList<String>(); - for (GT_Worldgen_GT_Ore_Layer_Space tWorldGen : GalacticGreg.oreVeinWorldgenList) - if (tWorldGen.isEnabledForDim(pDimensionDef)) + for (GT_Worldgen tWorldGen : GalacticGreg.oreVeinWorldgenList) + if (tWorldGen instanceof GT_Worldgen_GT_Ore_Layer_Space && ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).isEnabledForDim(pDimensionDef)) tReturn.add(tWorldGen.mWorldGenName); + else if (tWorldGen instanceof BW_Worldgen_Ore_Layer_Space && ((BW_Worldgen_Ore_Layer_Space) tWorldGen).isEnabledForDim(pDimensionDef)) + tReturn.add(tWorldGen.mWorldGenName); _mBufferedVeinList.put(pDimensionDef.getDimIdentifier(), tReturn); } @@ -144,9 +148,9 @@ public class GT_Worldgen_GT_Ore_Layer_Space extends GT_Worldgen { private static short getMaxWeightForDim(ModDimensionDef pDimensionDef) { short tVal = 0; - for (GT_Worldgen_GT_Ore_Layer_Space tWorldGen : GalacticGreg.oreVeinWorldgenList) - if (tWorldGen.isEnabledForDim(pDimensionDef) && tVal < tWorldGen.mWeight) - tVal = tWorldGen.mWeight; + for (GT_Worldgen tWorldGen : GalacticGreg.oreVeinWorldgenList) + if (tWorldGen instanceof GT_Worldgen_GT_Ore_Layer_Space && ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).isEnabledForDim(pDimensionDef) && tVal < ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mWeight) + tVal = ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mWeight; return tVal; } @@ -176,19 +180,19 @@ public class GT_Worldgen_GT_Ore_Layer_Space extends GT_Worldgen { // No lambda in Java 1.6 and 1.7 :( //GT_Worldgen_GT_Ore_Layer_Space tGen = GalacticGreg.oreVeinWorldgenList.stream().filter(p -> p.mWorldGenName == tVeinName).findFirst(); - GT_Worldgen_GT_Ore_Layer_Space tGen = null; - for (GT_Worldgen_GT_Ore_Layer_Space tWorldGen : GalacticGreg.oreVeinWorldgenList) - if (tWorldGen.mWorldGenName.equals(tVeinName)) + GT_Worldgen tGen = null; + for (GT_Worldgen tWorldGen : GalacticGreg.oreVeinWorldgenList) + if (tWorldGen instanceof GT_Worldgen_GT_Ore_Layer_Space && ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mWorldGenName.equals(tVeinName)) tGen = tWorldGen; if (tGen != null) { //GT_Worldgen_GT_Ore_Layer_Space tGen = GalacticGreg.oreVeinWorldgenList.get(tRndMix); GalacticGreg.Logger.trace("Using Oremix %s for asteroid", tGen.mWorldGenName); - primaryMeta = tGen.mPrimaryMeta; - secondaryMeta = tGen.mSecondaryMeta; - betweenMeta = tGen.mBetweenMeta; - sporadicMeta = tGen.mSporadicMeta; + primaryMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tGen).mPrimaryMeta; + secondaryMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tGen).mSecondaryMeta; + betweenMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tGen).mBetweenMeta; + sporadicMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tGen).mSporadicMeta; } } else @@ -201,20 +205,23 @@ public class GT_Worldgen_GT_Ore_Layer_Space extends GT_Worldgen { 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) + for (GT_Worldgen tWorldGen : GalacticGreg.oreVeinWorldgenList) { + if (!(tWorldGen instanceof GT_Worldgen_GT_Ore_Layer_Space)) + continue; + tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mWeight; if (tRandomWeight <= 0) { try { - if (tWorldGen.isEnabledForDim(pDimensionDef)) + if (((GT_Worldgen_GT_Ore_Layer_Space) 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; + primaryMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mPrimaryMeta; + secondaryMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mSecondaryMeta; + betweenMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mBetweenMeta; + sporadicMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mSporadicMeta; temp = false; break; diff --git a/src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java b/src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java index a413a6ff5a..c76cd1e425 100644 --- a/src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java +++ b/src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java @@ -1,12 +1,18 @@ package bloodasp.galacticgreg; +import bloodasp.galacticgreg.bartworks.BW_Worldgen_Ore_Layer_Space; +import bloodasp.galacticgreg.bartworks.BW_Worldgen_Ore_SmallOre_Space; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGeneratedOreTE; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_SmallOres; import gregtech.api.util.GT_Log; import java.util.Random; +import gregtech.api.world.GT_Worldgen; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.Vec3; import net.minecraft.util.WeightedRandomChestContent; @@ -360,7 +366,6 @@ public class GT_Worldgenerator_Space implements IWorldGenerator { * @param eX * @param eY * @param eZ - * @param tDoGenerateRegularBlock * @return */ private boolean doGenerateSpecialBlocks(ModDimensionDef pDimensionDef, Random pRandom, World pWorld, AsteroidConfig tAConf, int eX, int eY, int eZ, TargetBlockPosition pBlockPosition) @@ -429,38 +434,53 @@ public class GT_Worldgenerator_Space implements IWorldGenerator { int tRandomWeight; boolean continueSearch = true; int tFoundOreMeta = -1; + BW_Worldgen_Ore_SmallOre_Space bwOreGen = null; // First find a small ore... for (int i = 0; (i < 256) && (continueSearch); i++) { tRandomWeight = pRandom.nextInt(GT_Worldgen_GT_Ore_Layer_Space.sWeight); - for (GT_Worldgen_GT_Ore_SmallPieces_Space tWorldGen : GalacticGreg.smallOreWorldgenList) + for (GT_Worldgen tWorldGen : GalacticGreg.smallOreWorldgenList) { - // That is enabled for *this* dim... - if (!tWorldGen.isEnabledForDim(pDimDef)) - continue; - - // And in the correct y-level, of ObeyLimits is true... - if (pAConf.ObeyHeightLimits && !tWorldGen.isAllowedForHeight(pY)) - continue; - - // Care about weight - tRandomWeight -= tWorldGen.mAmount; - if (tRandomWeight <= 0) - { - // And return found ore meta - tFoundOreMeta = tWorldGen.mMeta; - continueSearch = false; + if (tWorldGen instanceof BW_Worldgen_Ore_SmallOre_Space) { + tRandomWeight = ((BW_Worldgen_Ore_SmallOre_Space) tWorldGen).mDensity; + if (tRandomWeight <= 0) { + tFoundOreMeta = ((BW_Worldgen_Ore_SmallOre_Space) tWorldGen).mPrimaryMeta; + continueSearch = false; + bwOreGen = ((BW_Worldgen_Ore_SmallOre_Space) tWorldGen); + } + } + else if (tWorldGen instanceof GT_Worldgen_GT_Ore_SmallPieces_Space) { + // That is enabled for *this* dim... + if (!((GT_Worldgen_GT_Ore_SmallPieces_Space)tWorldGen).isEnabledForDim(pDimDef)) + continue; + + // And in the correct y-level, of ObeyLimits is true... + if (pAConf.ObeyHeightLimits && !((GT_Worldgen_GT_Ore_SmallPieces_Space)tWorldGen).isAllowedForHeight(pY)) + continue; + + // Care about weight + tRandomWeight -= ((GT_Worldgen_GT_Ore_SmallPieces_Space)tWorldGen).mAmount; + if (tRandomWeight <= 0) { + // And return found ore meta + tFoundOreMeta = ((GT_Worldgen_GT_Ore_SmallPieces_Space)tWorldGen).mMeta; + continueSearch = false; + } } } } if (tFoundOreMeta > -1) { - // Make the oreID a small ore with correct type - int tCustomOffset = (GTOreTypes.SmallOres.getOffset() + pTargetBlockOffset); - - // Set the smallOre block - GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(pDimDef, pWorld, pX, pY, pZ, tFoundOreMeta, true, tCustomOffset); - tFlag = false; + if (bwOreGen == null) { + // Make the oreID a small ore with correct type + int tCustomOffset = (GTOreTypes.SmallOres.getOffset() + pTargetBlockOffset); + + // Set the smallOre block + GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(pDimDef, pWorld, pX, pY, pZ, tFoundOreMeta, true, tCustomOffset); + tFlag = false; + } + else { + bwOreGen.setOreBlock(pWorld, pX, pY, pZ,tFoundOreMeta,true); + } } } } @@ -492,21 +512,20 @@ public class GT_Worldgenerator_Space implements IWorldGenerator { 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 -= tWorldGen.mWeight; - if (tRandomWeight <= 0) - { - try - { - if (tWorldGen.executeWorldgen(pWorld, pRandom, pBiome, Integer.MIN_VALUE, pX, pZ, pChunkGenerator, pChunkProvider)) - { + for (GT_Worldgen tWorldGen : GalacticGreg.oreVeinWorldgenList) { + if (tWorldGen instanceof GT_Worldgen_GT_Ore_Layer_Space) + tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mWeight; + else if (tWorldGen instanceof BW_Worldgen_Ore_Layer_Space) + tRandomWeight -= ((BW_Worldgen_Ore_Layer_Space) tWorldGen).mWeight; + if (tRandomWeight <= 0) { + try { + if (tWorldGen.executeWorldgen(pWorld, pRandom, pBiome, Integer.MIN_VALUE, pX, pZ, pChunkGenerator, pChunkProvider)) { temp = false; } } catch (Throwable e) { e.printStackTrace(GT_Log.err); } - break; + break; } } } @@ -517,7 +536,7 @@ public class GT_Worldgenerator_Space implements IWorldGenerator { for (int tX = pX - 16; i < 3; tX += 16) { int j = 0; for (int tZ = pZ - 16; j < 3; tZ += 16) { - for (GT_Worldgen_GT_Ore_SmallPieces_Space tWorldGen : GalacticGreg.smallOreWorldgenList) { + for (GT_Worldgen tWorldGen : GalacticGreg.smallOreWorldgenList) { try { tWorldGen.executeWorldgen(pWorld, pRandom, "", Integer.MIN_VALUE, tX, tZ, pChunkGenerator, pChunkProvider); } catch (Throwable e) { diff --git a/src/main/java/bloodasp/galacticgreg/GalacticGreg.java b/src/main/java/bloodasp/galacticgreg/GalacticGreg.java index 9fdb07a91a..d51b9dcf6a 100644 --- a/src/main/java/bloodasp/galacticgreg/GalacticGreg.java +++ b/src/main/java/bloodasp/galacticgreg/GalacticGreg.java @@ -7,6 +7,8 @@ import java.util.Random; import bloodasp.galacticgreg.auxiliary.GalacticGregConfig; import bloodasp.galacticgreg.auxiliary.LogHelper; import bloodasp.galacticgreg.auxiliary.ProfilingStorage; +import bloodasp.galacticgreg.bartworks.BW_Worldgen_Ore_Layer_Space; +import bloodasp.galacticgreg.bartworks.BW_Worldgen_Ore_SmallOre_Space; import bloodasp.galacticgreg.command.AEStorageCommand; import bloodasp.galacticgreg.command.ProfilingCommand; import bloodasp.galacticgreg.registry.GalacticGregRegistry; @@ -14,14 +16,17 @@ import bloodasp.galacticgreg.schematics.SpaceSchematicHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; +import gregtech.api.GregTech_API; +import gregtech.api.world.GT_Worldgen; @Mod(modid = GalacticGreg.MODID, version = GalacticGreg.VERSION, dependencies = "required-after:GalacticraftCore; required-after:gregtech@5.09.32.30;", acceptableRemoteVersions="*") public class GalacticGreg { - public static final List<GT_Worldgen_GT_Ore_SmallPieces_Space> smallOreWorldgenList = new ArrayList(); - public static final List<GT_Worldgen_GT_Ore_Layer_Space> oreVeinWorldgenList = new ArrayList(); + public static final List<GT_Worldgen> smallOreWorldgenList = new ArrayList(); + public static final List<GT_Worldgen> oreVeinWorldgenList = new ArrayList(); public static final String NICE_MODID = "GalacticGreg"; public static final String MODID = "galacticgreg"; @@ -53,7 +58,12 @@ public class GalacticGreg { Logger.trace("Leaving PRELOAD"); } - + +// @EventHandler +// public void onLoad(FMLInitializationEvent event){ +// GalacticGregRegistry.registerModContainer(ModRegisterer.Setup_GalactiCraftCore()); +// } + /** * Postload phase. Mods can add their custom definition to our api in their own PreLoad or Init-phase * Once GalacticGregRegistry.InitRegistry() is called, no changes are accepted. @@ -68,7 +78,16 @@ public class GalacticGreg { throw new RuntimeException("GalacticGreg registry has been finalized from a 3rd-party mod, this is forbidden!"); //new WorldGenGaGT().run(); DO NOT UNCOMMENT, was moved to gregtech.loaders.postload.GT_Worldgenloader - + + if (Loader.isModLoaded("bartworks")) { + for (int f = 0, j = GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks", "AmountOfCustomLargeVeinSlots", 0); f < j; f++) { + new BW_Worldgen_Ore_Layer_Space("mix.custom." + (f < 10 ? "0" : "") + f, GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + "mix.custom." + (f < 10 ? "0" : "") + f, "Enabled", false)); + } + + for (int f = 0, j = GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks", "AmountOfCustomSmallSlots", 0); f < j; f++) { + new BW_Worldgen_Ore_SmallOre_Space("small.custom." + (f < 10 ? "0" : "") + f, GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + "small.custom." + (f < 10 ? "0" : "") + f, "Enabled", false)); + } + } GalacticConfig.serverPostInit(); Logger.trace("Leaving POSTLOAD"); diff --git a/src/main/java/bloodasp/galacticgreg/ModRegisterer.java b/src/main/java/bloodasp/galacticgreg/ModRegisterer.java index d599c7a210..afc0df4eec 100644 --- a/src/main/java/bloodasp/galacticgreg/ModRegisterer.java +++ b/src/main/java/bloodasp/galacticgreg/ModRegisterer.java @@ -25,7 +25,7 @@ public class ModRegisterer * @param pDef * @return */ - private List<ModDBMDef> singleToList(ModDBMDef pDef) + private static List<ModDBMDef> singleToList(ModDBMDef pDef) { List<ModDBMDef> tLst = new ArrayList<ModDBMDef>(); tLst.add(pDef); @@ -119,14 +119,14 @@ public class ModRegisterer * Mod GalactiCraft * Just another setup based on existing classes, due the fact that we're working with GalactiCraft */ - private ModContainer Setup_GalactiCraftCore() + public static ModContainer Setup_GalactiCraftCore() { ModContainer modGCraftCore = new ModContainer("GalacticraftCore"); - ModDBMDef DBMMoon = new ModDBMDef(GCBlocks.blockMoon, 4); + ModDBMDef DBMMoon = new ModDBMDef("tile.moonBlock", 4); - ModDimensionDef tMoonDim = new ModDimensionDef("Moon", ChunkProviderMoon.class, DimensionType.Planet, singleToList(DBMMoon)); + ModDimensionDef tMoonDim = new ModDimensionDef("Moon", "micdoodle8.mods.galacticraft.core.world.gen.ChunkProviderMoon", Enums.DimensionType.Planet, singleToList(DBMMoon)); modGCraftCore.addDimensionDef(tMoonDim); - + return modGCraftCore; } diff --git a/src/main/java/bloodasp/galacticgreg/bartworks/BW_Worldgen_Ore_Layer_Space.java b/src/main/java/bloodasp/galacticgreg/bartworks/BW_Worldgen_Ore_Layer_Space.java new file mode 100644 index 0000000000..9eeba10987 --- /dev/null +++ b/src/main/java/bloodasp/galacticgreg/bartworks/BW_Worldgen_Ore_Layer_Space.java @@ -0,0 +1,107 @@ +package bloodasp.galacticgreg.bartworks; + +import bloodasp.galacticgreg.GT_TileEntity_Ores_Space; +import bloodasp.galacticgreg.api.Enums; +import bloodasp.galacticgreg.api.ModDBMDef; +import bloodasp.galacticgreg.api.ModDimensionDef; +import bloodasp.galacticgreg.dynconfig.DynamicOreMixWorldConfig; +import bloodasp.galacticgreg.registry.GalacticGregRegistry; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGeneratedOreTE; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_SmallOres; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_OreLayer; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.common.blocks.GT_TileEntity_Ores; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import java.util.Random; + +import static bloodasp.galacticgreg.GalacticGreg.oreVeinWorldgenList; + +public class BW_Worldgen_Ore_Layer_Space extends BW_OreLayer { + + private ModDimensionDef pDimensionDef; + + private DynamicOreMixWorldConfig _mDynWorldConfig; + + public BW_Worldgen_Ore_Layer_Space(String aName, boolean pDefault, int pMinY, int pMaxY, int pWeight, int pDensity, int pSize, int pPrimary, int pSecondary, int pBetween, int pSporadic, boolean primaryBW, boolean secondaryBW, boolean betweenBW, boolean sporadicBW) { + super(aName, pDefault, 0, 0, 0, 0, 0, primaryBW ? Werkstoff.default_null_Werkstoff : Materials._NULL, secondaryBW ? Werkstoff.default_null_Werkstoff : Materials._NULL, betweenBW ? Werkstoff.default_null_Werkstoff : Materials._NULL, sporadicBW ? Werkstoff.default_null_Werkstoff : Materials._NULL); + mMinY = ((short) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "MinHeight", pMinY)); + mMaxY = ((short) Math.max(this.mMinY + 5, GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "MaxHeight", pMaxY))); + mWeight = ((short) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "RandomWeight", pWeight)); + mDensity = ((short) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "Density", pDensity)); + mSize = ((short) Math.max(1, GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "Size", pSize))); + mPrimaryMeta = ((short) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "OrePrimaryLayer", pPrimary)); + mSecondaryMeta = ((short) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "OreSecondaryLayer", pSecondary)); + mBetweenMeta = ((short) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "OreSporadiclyInbetween", pBetween)); + mSporadicMeta = ((short) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "OreSporaticlyAround", pSporadic)); + bwOres = ((byte) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "BWGTlogic", bwOres)); + if (mEnabled) { + sWeight += this.mWeight; + oreVeinWorldgenList.add(this); + } + _mDynWorldConfig = new DynamicOreMixWorldConfig(mWorldGenName,true); + _mDynWorldConfig.InitDynamicConfig(); + + } + + public BW_Worldgen_Ore_Layer_Space(String aName, boolean enabled){ + this(aName,enabled,0,0,0,0,0,0,0,0,0,true,true,true,true); + } + + public boolean isEnabledForDim(ModDimensionDef pDimensionDef) + { + return _mDynWorldConfig.isEnabledInDim(pDimensionDef); + } + + @Override + public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + ModDimensionDef tMDD = GalacticGregRegistry.getDimensionTypeByChunkGenerator(aChunkGenerator); + if (tMDD == null) + return false; + pDimensionDef = tMDD; + return super.executeWorldgen(aWorld, aRandom, aBiome, aDimensionType, aChunkX, aChunkZ, aChunkGenerator, aChunkProvider); + } + + public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) { + TileEntity te = aWorld.getTileEntity(aX, aY, aZ); + if (!(te instanceof BW_MetaGeneratedOreTE) && !(te instanceof GT_TileEntity_Ores)) { + if (aMetaData == this.mSporadicMeta && (this.bwOres & 1) != 0 || aMetaData == this.mBetweenMeta && (this.bwOres & 2) != 0 || aMetaData == this.mPrimaryMeta && (this.bwOres & 8) != 0 || aMetaData == this.mSecondaryMeta && (this.bwOres & 4) != 0) { + boolean wasSet; + for (ModDBMDef e : pDimensionDef.getReplaceableBlocks()) { + wasSet = isSmallOre ? BW_MetaGenerated_SmallOres.setOreBlock(aWorld, aX, aY, aZ, aMetaData, pDimensionDef.getAirSetting() == Enums.AirReplaceRule.AllowReplaceAir, (Block) Block.blockRegistry.getObject(e.getBlockName()), new int[]{e.getMeta()}) : BW_MetaGenerated_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, pDimensionDef.getAirSetting() == Enums.AirReplaceRule.AllowReplaceAir, (Block) Block.blockRegistry.getObject(e.getBlockName()), new int[]{e.getMeta()}); + if (wasSet) + return true; + } + return false; + } else { + return GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(pDimensionDef, aWorld, aX, aY, aZ, aMetaData,pDimensionDef.getAirSetting() == Enums.AirReplaceRule.AllowReplaceAir); + } + } else { + return true; + } + } + + @Override + public Block getDefaultBlockToReplace() { + return null; + } + + @Override + public int[] getDefaultDamageToReplace() { + return null; + } + + @Override + public String getDimName() { + return pDimensionDef.getDimensionName(); + } + + + +} diff --git a/src/main/java/bloodasp/galacticgreg/bartworks/BW_Worldgen_Ore_SmallOre_Space.java b/src/main/java/bloodasp/galacticgreg/bartworks/BW_Worldgen_Ore_SmallOre_Space.java new file mode 100644 index 0000000000..449f60f57a --- /dev/null +++ b/src/main/java/bloodasp/galacticgreg/bartworks/BW_Worldgen_Ore_SmallOre_Space.java @@ -0,0 +1,101 @@ +package bloodasp.galacticgreg.bartworks; + +import bloodasp.galacticgreg.GT_TileEntity_Ores_Space; +import bloodasp.galacticgreg.api.Enums; +import bloodasp.galacticgreg.api.ModDBMDef; +import bloodasp.galacticgreg.api.ModDimensionDef; +import bloodasp.galacticgreg.dynconfig.DynamicOreMixWorldConfig; +import bloodasp.galacticgreg.registry.GalacticGregRegistry; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGeneratedOreTE; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_SmallOres; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_OreLayer; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.common.blocks.GT_TileEntity_Ores; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import java.util.Random; + +import static bloodasp.galacticgreg.GalacticGreg.smallOreWorldgenList; + +public class BW_Worldgen_Ore_SmallOre_Space extends BW_OreLayer { + + private ModDimensionDef pDimensionDef; + private DynamicOreMixWorldConfig _mDynWorldConfig; + public BW_Worldgen_Ore_SmallOre_Space(String aName, boolean pDefault, int pMinY, int pMaxY, int pDensity, int pPrimary, ISubTagContainer primaryBW) { + super(aName, pDefault, 0, 0, 0, 0, 0, primaryBW, Materials._NULL, Materials._NULL, Materials._NULL); + mMinY = ((short) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "MinHeight", pMinY)); + mMaxY = ((short) Math.max(this.mMinY + 1, GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "MaxHeight", pMaxY))); + mDensity = ((short) Math.max(1, GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "Amount", pDensity))); + mPrimaryMeta = ((short) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "Meta", pPrimary)); + bwOres = ((byte) GregTech_API.sWorldgenFile.get("worldgen.GaGregBartworks." + this.mWorldGenName, "BWGTlogic", bwOres)); + _mDynWorldConfig = new DynamicOreMixWorldConfig(mWorldGenName,true); + _mDynWorldConfig.InitDynamicConfig(); + if (mEnabled) { + smallOreWorldgenList.add(this); + } + } + + public BW_Worldgen_Ore_SmallOre_Space(String aName, boolean enabled){ + this(aName,enabled,0,0,0,0,enabled ? Werkstoff.default_null_Werkstoff : Materials._NULL); + } + + public boolean isEnabledForDim(ModDimensionDef pDimensionDef) + { + return _mDynWorldConfig.isEnabledInDim(pDimensionDef); + } + + @Override + public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + ModDimensionDef tMDD = GalacticGregRegistry.getDimensionTypeByChunkGenerator(aChunkGenerator); + if (tMDD == null) + return false; + pDimensionDef = tMDD; + if (this.mPrimaryMeta > 0) + for (int i = 0, j = Math.max(1, this.mDensity / 2 + aRandom.nextInt(this.mDensity) / 2); i < j; i++) { + this.setOreBlock(aWorld, aChunkX + aRandom.nextInt(16), this.mMinY + aRandom.nextInt(Math.max(1, this.mMaxY - this.mMinY)), aChunkZ + aRandom.nextInt(16), this.mPrimaryMeta, true); + } + return true; + } + + @Override + public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) { + TileEntity te = aWorld.getTileEntity(aX, aY, aZ); + if (!(te instanceof BW_MetaGeneratedOreTE) && !(te instanceof GT_TileEntity_Ores)) { + if (aMetaData == this.mSporadicMeta && (this.bwOres & 1) != 0 || aMetaData == this.mBetweenMeta && (this.bwOres & 2) != 0 || aMetaData == this.mPrimaryMeta && (this.bwOres & 8) != 0 || aMetaData == this.mSecondaryMeta && (this.bwOres & 4) != 0) { + boolean wasSet; + for (ModDBMDef e : pDimensionDef.getReplaceableBlocks()) { + wasSet = isSmallOre ? BW_MetaGenerated_SmallOres.setOreBlock(aWorld, aX, aY, aZ, aMetaData, pDimensionDef.getAirSetting() == Enums.AirReplaceRule.AllowReplaceAir, (Block) Block.blockRegistry.getObject(e.getBlockName()), new int[]{e.getMeta()}) : BW_MetaGenerated_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, pDimensionDef.getAirSetting() == Enums.AirReplaceRule.AllowReplaceAir, (Block) Block.blockRegistry.getObject(e.getBlockName()), new int[]{e.getMeta()}); + if (wasSet) + return true; + } + return false; + } else { + return GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(pDimensionDef, aWorld, aX, aY, aZ, aMetaData,pDimensionDef.getAirSetting() == Enums.AirReplaceRule.AllowReplaceAir); + } + } else { + return true; + } + } + + @Override + public Block getDefaultBlockToReplace() { + return null; + } + + @Override + public int[] getDefaultDamageToReplace() { + return new int[0]; + } + + @Override + public String getDimName() { + return null; + } +} diff --git a/src/main/java/bloodasp/galacticgreg/dynconfig/DynamicOreMixWorldConfig.java b/src/main/java/bloodasp/galacticgreg/dynconfig/DynamicOreMixWorldConfig.java index 846cb5616a..ff6336cf1e 100644 --- a/src/main/java/bloodasp/galacticgreg/dynconfig/DynamicOreMixWorldConfig.java +++ b/src/main/java/bloodasp/galacticgreg/dynconfig/DynamicOreMixWorldConfig.java @@ -43,7 +43,13 @@ public class DynamicOreMixWorldConfig { _mDynWorldConfigMap = new HashMap<String, Boolean>(); _mConfigName = String.format("worldgen.%s", _mWorldGenName); } - + + public DynamicOreMixWorldConfig(String pWorldGenName, boolean bw){ + _mWorldGenName = pWorldGenName; + _mDynWorldConfigMap = new HashMap<String, Boolean>(); + _mConfigName = String.format("worldgen.gagregbartworks.%s", _mWorldGenName); + } + /** * Check if this OreGen is enabled for a given Dimension, represented by pMDD * @param pMDD The dimension in question |