aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/world
diff options
context:
space:
mode:
authorboubou19 <miisterunknown@gmail.com>2024-08-27 20:50:30 +0200
committerGitHub <noreply@github.com>2024-08-27 18:50:30 +0000
commit4908d5967c3dfeff5616c65144e701859b9e30a2 (patch)
tree3e58a4b8ebd8b70745e81c4c71c765980e4ec4f4 /src/main/java/gregtech/api/world
parent3c574facfb224029c0b69865e281023da6170ce0 (diff)
downloadGT5-Unofficial-4908d5967c3dfeff5616c65144e701859b9e30a2.tar.gz
GT5-Unofficial-4908d5967c3dfeff5616c65144e701859b9e30a2.tar.bz2
GT5-Unofficial-4908d5967c3dfeff5616c65144e701859b9e30a2.zip
Config/gregtech.cfg (#2939)
* first pass on config migration * second pass on config migration * removing bad configs * rename config classes and register them * move debug options to its own debug category * migrate pollution * finish migrating general config * removing useless config * finish GregTech.cfg port to GTNHLib * don't accidentally force panic mode in dev env * typo * defaults are now handled by the confg handler * remove dead config * force config save after defaults are being written * stop messing with the GregTech.cfg externally * removing comments * new underground fluid builder and porting default underground fluids to code * move config handlers of gregtech.cfg in their own package * process MachineStats.cfg * yeeted MaterialProperties.cfg * remove unused compat in GTNH * process OverpoweredStuff.cfg * process Other.cfg * ungregify some config variables * remove unused variables * fix Ids.cfg not being populated * delete duplicate printing of MTE IDs in GT5U clients * bump hodgepodge version to get mod phase timers * process Client.cfg * fix bad category naming * registering all the config handlers in gui * bump GTNHLib version * actually only registering client configs * use proper double arrays now * move GT ore mixes to patternbuilders * dead code * fix multifiles config not being handled properly * import class from NHCore * removing reflection * use enums for registration * yeet config for Asteroid dimensions * remove unused since 2015 enum entry * todo * rework oremix enums * imported dimension data in enums * convert old dirty predicate into proper one * hook gagreg onto the OreMixes enum * finally nuke worldgen.ore.mix config category! * hook gagreg small ores onto the SmallOres enum * imported dim values in enum * fix dirty work around in vm predicate * yeet unused classes * hook GT stones to GTStones enum * yeet all the remaining booleans in the worldgen category * port endasteroids category * port general category * deprecated * yeet unused bw compat * finish worldgen config migration * hardcode config into code * remove not generated config entry * remove Unification.cfg * fix build * migrate oreveins away from config * migrate small ores away from config * delete config parser * forgotten * fix EoH recipe crash in dev * fix GT NEI Ore Plugin config and csv paths * shade opencsv * rewrite csv generator * spotless apply
Diffstat (limited to 'src/main/java/gregtech/api/world')
-rw-r--r--src/main/java/gregtech/api/world/GT_Worldgen.java74
-rw-r--r--src/main/java/gregtech/api/world/GT_Worldgen_Ore.java34
-rw-r--r--src/main/java/gregtech/api/world/GT_Worldgen_Ore_SingleBlock.java52
-rw-r--r--src/main/java/gregtech/api/world/GT_Worldgen_Ore_SingleBlock_UnderLava.java54
4 files changed, 30 insertions, 184 deletions
diff --git a/src/main/java/gregtech/api/world/GT_Worldgen.java b/src/main/java/gregtech/api/world/GT_Worldgen.java
index bd85813e2b..1ce0c85523 100644
--- a/src/main/java/gregtech/api/world/GT_Worldgen.java
+++ b/src/main/java/gregtech/api/world/GT_Worldgen.java
@@ -1,6 +1,5 @@
package gregtech.api.world;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Random;
@@ -10,7 +9,8 @@ import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.common.DimensionManager;
-import gregtech.api.GregTech_API;
+import gregtech.common.GT_Worldgen_GT_Ore_Layer;
+import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces;
public abstract class GT_Worldgen {
@@ -21,7 +21,7 @@ public abstract class GT_Worldgen {
@SuppressWarnings({ "unchecked", "rawtypes" }) // The adding of "this" needs a List<this> which does not exist
public GT_Worldgen(String aName, List aList, boolean aDefault) {
mWorldGenName = aName;
- mEnabled = GregTech_API.sWorldgenFile.get("worldgen", mWorldGenName, aDefault);
+ mEnabled = aDefault;
if (mEnabled) aList.add(this);
}
@@ -45,32 +45,6 @@ public abstract class GT_Worldgen {
}
/**
- * @param aWorld The World Object
- * @param aRandom The Random Generator to use
- * @param aBiome The Name of the Biome (always != null)
- * @param aDimensionType The Type of Worldgeneration to add. -1 = Nether, 0 = Overworld, +1 = End
- * @param aChunkX xCoord of the Chunk
- * @param aChunkZ zCoord of the Chunk
- * @return if the Worldgeneration has been successfully completed
- */
- public boolean executeCavegen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX,
- int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
- return false;
- }
-
- /**
- *
- * @param aWorld The World Object
- * @param aDimensionType The Type of Worldgeneration to add. -1 = Nether, 0 = Overworld, +1 = End
- * @param aAllowedDimensionType The Type of allowed Worldgeneration
- * @return if generation for this world is allowed for MoronTech (tm) OreGen (ATM (2.0.3.1Dev) only End, Nether,
- * Overworld, Twilight Forest and Deep Dark)
- */
- public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) {
- return isGenerationAllowed(aWorld.provider.getDimensionName(), aDimensionType, aAllowedDimensionType);
- }
-
- /**
*
* @param aDimName The Dimension Name
* @param aDimensionType The Type of Worldgeneration to add. -1 = Nether, 0 = Overworld, +1 = End
@@ -79,17 +53,17 @@ public abstract class GT_Worldgen {
* Overworld, Twilight Forest and Deep Dark)
*/
public boolean isGenerationAllowed(String aDimName, int aDimensionType, int aAllowedDimensionType) {
+ if (aDimName.equalsIgnoreCase("Underdark")) {
+ return false;
+ }
if (!(aDimName.equalsIgnoreCase("Overworld") || aDimName.equalsIgnoreCase("Nether")
|| aDimName.equalsIgnoreCase("The End")
- || aDimName.equalsIgnoreCase("Twilight Forest")
- || aDimName.equalsIgnoreCase("Underdark"))) return false;
+ || aDimName.equalsIgnoreCase("Twilight Forest"))) return false;
Boolean tAllowed = mDimensionMap.get(aDimName);
if (tAllowed == null) {
- boolean tValue = GregTech_API.sWorldgenFile
- .get("worldgen." + mWorldGenName, aDimName, aDimensionType == aAllowedDimensionType);
- mDimensionMap.put(aDimName, tValue);
- return tValue;
+ mDimensionMap.put(aDimName, aDimensionType == aAllowedDimensionType);
+ return aDimensionType == aAllowedDimensionType;
}
return tAllowed;
}
@@ -112,20 +86,32 @@ public abstract class GT_Worldgen {
*/
public boolean isGenerationAllowed(World aWorld, Class... aAllowedDimensionTypes) {
String aDimName = aWorld.provider.getDimensionName();
+ if (aDimName.equalsIgnoreCase("Underdark")) {
+ return false;
+ }
if (!(aDimName.equalsIgnoreCase("Overworld") || aDimName.equalsIgnoreCase("Nether")
|| aDimName.equalsIgnoreCase("The End")
- || aDimName.equalsIgnoreCase("Twilight Forest")
- || aDimName.equalsIgnoreCase("Underdark"))) return false;
+ || aDimName.equalsIgnoreCase("Twilight Forest"))) return false;
Boolean tAllowed = mDimensionMap.get(aDimName);
if (tAllowed == null) {
- boolean tValue = GregTech_API.sWorldgenFile.get(
- "worldgen." + mWorldGenName,
- aDimName,
- Arrays.stream(aAllowedDimensionTypes)
- .anyMatch(worldProvider -> worldProvider.isInstance(aWorld.provider)));
- mDimensionMap.put(aDimName, tValue);
- return tValue;
+ boolean value = false;
+ for (int i = 0; i < aAllowedDimensionTypes.length; i++) {
+ if (aAllowedDimensionTypes[i].isInstance(aWorld.provider)) {
+ value = true;
+ }
+ }
+
+ // ugly, but idk how to do it better without hard depping on tf provider in ore constructors
+ if (this instanceof GT_Worldgen_GT_Ore_SmallPieces) {
+ value = ((GT_Worldgen_GT_Ore_SmallPieces) this).twilightForest && aWorld.provider.dimensionId == 7;
+ }
+ if (this instanceof GT_Worldgen_GT_Ore_Layer) {
+ value = ((GT_Worldgen_GT_Ore_Layer) this).twilightForest && aWorld.provider.dimensionId == 7;
+ }
+
+ mDimensionMap.put(aDimName, value);
+ return value;
}
return tAllowed;
}
diff --git a/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java b/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java
deleted file mode 100644
index 958adfad54..0000000000
--- a/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package gregtech.api.world;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import net.minecraft.block.Block;
-
-import gregtech.api.GregTech_API;
-
-public abstract class GT_Worldgen_Ore extends GT_Worldgen {
-
- public final int mBlockMeta, mAmount, mSize, mMinY, mMaxY, mProbability, mDimensionType;
- public final Block mBlock;
- public final Collection<String> mBiomeList;
- public final boolean mAllowToGenerateinVoid;
- private final String aTextWorldgen = "worldgen.";
-
- public GT_Worldgen_Ore(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType,
- int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList,
- boolean aAllowToGenerateinVoid) {
- super(aName, GregTech_API.sWorldgenList, aDefault);
- mDimensionType = aDimensionType;
- mBlock = aBlock;
- mBlockMeta = Math.min(Math.max(aBlockMeta, 0), 15);
- mProbability = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "Probability", aProbability);
- mAmount = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "Amount", aAmount);
- mSize = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "Size", aSize);
- mMinY = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "MinHeight", aMinY);
- mMaxY = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "MaxHeight", aMaxY);
- if (aBiomeList == null) mBiomeList = new ArrayList<>();
- else mBiomeList = aBiomeList;
- mAllowToGenerateinVoid = aAllowToGenerateinVoid;
- }
-}
diff --git a/src/main/java/gregtech/api/world/GT_Worldgen_Ore_SingleBlock.java b/src/main/java/gregtech/api/world/GT_Worldgen_Ore_SingleBlock.java
deleted file mode 100644
index f89d3ad8f8..0000000000
--- a/src/main/java/gregtech/api/world/GT_Worldgen_Ore_SingleBlock.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package gregtech.api.world;
-
-import java.util.Collection;
-import java.util.Random;
-
-import net.minecraft.block.Block;
-import net.minecraft.init.Blocks;
-import net.minecraft.world.World;
-import net.minecraft.world.chunk.IChunkProvider;
-
-public class GT_Worldgen_Ore_SingleBlock extends GT_Worldgen_Ore {
-
- public GT_Worldgen_Ore_SingleBlock(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType,
- int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList,
- boolean aAllowToGenerateinVoid) {
- super(
- aName,
- aDefault,
- aBlock,
- aBlockMeta,
- aDimensionType,
- aAmount,
- aSize,
- aProbability,
- aMinY,
- aMaxY,
- aBiomeList,
- aAllowToGenerateinVoid);
- }
-
- @Override
- public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX,
- int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
- if (isGenerationAllowed(aWorld, mDimensionType) && (mBiomeList.isEmpty() || mBiomeList.contains(aBiome))
- && (mProbability <= 1 || aRandom.nextInt(mProbability) == 0)) {
- for (int i = 0; i < mAmount; i++) {
- int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY),
- tZ = aChunkZ + aRandom.nextInt(16);
- Block tBlock = aWorld.getBlock(tX, tY, tZ);
- if (((mAllowToGenerateinVoid && aWorld.getBlock(tX, tY, tZ)
- .isAir(aWorld, tX, tY, tZ))
- || (tBlock != null && (tBlock.isReplaceableOreGen(aWorld, tX, tY, tZ, Blocks.stone)
- || tBlock.isReplaceableOreGen(aWorld, tX, tY, tZ, Blocks.end_stone)
- || tBlock.isReplaceableOreGen(aWorld, tX, tY, tZ, Blocks.netherrack))))) {
- aWorld.setBlock(tX, tY, tZ, mBlock, mBlockMeta, 0);
- }
- }
- return true;
- }
- return false;
- }
-}
diff --git a/src/main/java/gregtech/api/world/GT_Worldgen_Ore_SingleBlock_UnderLava.java b/src/main/java/gregtech/api/world/GT_Worldgen_Ore_SingleBlock_UnderLava.java
deleted file mode 100644
index 3993c65f2a..0000000000
--- a/src/main/java/gregtech/api/world/GT_Worldgen_Ore_SingleBlock_UnderLava.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package gregtech.api.world;
-
-import java.util.Collection;
-import java.util.Random;
-
-import net.minecraft.block.Block;
-import net.minecraft.init.Blocks;
-import net.minecraft.world.World;
-import net.minecraft.world.chunk.IChunkProvider;
-
-public class GT_Worldgen_Ore_SingleBlock_UnderLava extends GT_Worldgen_Ore {
-
- public GT_Worldgen_Ore_SingleBlock_UnderLava(String aName, boolean aDefault, Block aBlock, int aBlockMeta,
- int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY,
- Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) {
- super(
- aName,
- aDefault,
- aBlock,
- aBlockMeta,
- aDimensionType,
- aAmount,
- aSize,
- aProbability,
- aMinY,
- aMaxY,
- aBiomeList,
- aAllowToGenerateinVoid);
- }
-
- @Override
- public boolean executeCavegen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX,
- int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
- if (isGenerationAllowed(aWorld, mDimensionType) && (mBiomeList.isEmpty() || mBiomeList.contains(aBiome))
- && (mProbability <= 1 || aRandom.nextInt(mProbability) == 0)) {
- for (int i = 0; i < mAmount; i++) {
- int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY),
- tZ = aChunkZ + aRandom.nextInt(16);
- Block tBlock = aWorld.getBlock(tX, tY, tZ);
- if (((mAllowToGenerateinVoid && aWorld.getBlock(tX, tY, tZ)
- .isAir(aWorld, tX, tY, tZ))
- || (tBlock != null && (tBlock.isReplaceableOreGen(aWorld, tX, tY, tZ, Blocks.stone)
- || tBlock.isReplaceableOreGen(aWorld, tX, tY, tZ, Blocks.end_stone)
- || tBlock.isReplaceableOreGen(aWorld, tX, tY, tZ, Blocks.netherrack))))) {
- if (aWorld.getBlock(tX, tY + 1, tZ) == Blocks.lava
- || aWorld.getBlock(tX, tY, tZ) == Blocks.flowing_lava)
- aWorld.setBlock(tX, tY, tZ, mBlock, mBlockMeta, 0);
- }
- }
- return true;
- }
- return false;
- }
-}