aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorSpacebuilder2020 <spacebuilder2020@users.noreply.github.com>2024-11-13 23:17:59 -0700
committerGitHub <noreply@github.com>2024-11-14 07:17:59 +0100
commit82ae85b87631c23f01df61905359c222e2524cb4 (patch)
treeaf545984cef883a0f50a4de827d8e32eeeb57f08 /src/main
parentdf50073f364f4db88aadb70022ae7d30367f33cd (diff)
downloadGT5-Unofficial-82ae85b87631c23f01df61905359c222e2524cb4.tar.gz
GT5-Unofficial-82ae85b87631c23f01df61905359c222e2524cb4.tar.bz2
GT5-Unofficial-82ae85b87631c23f01df61905359c222e2524cb4.zip
Adds a blacklist to prevent certain dims like Twilight Forest from generating overworld ores (#3438)
Co-authored-by: Martin Robertz <dream-master@gmx.net> Co-authored-by: chochem <40274384+chochem@users.noreply.github.com> Co-authored-by: Alexdoru <57050655+Alexdoru@users.noreply.github.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/world/GTWorldgen.java37
-rw-r--r--src/main/java/gregtech/common/WorldgenGTOreLayer.java17
-rw-r--r--src/main/java/gregtech/common/WorldgenGTOreSmallPieces.java15
3 files changed, 52 insertions, 17 deletions
diff --git a/src/main/java/gregtech/api/world/GTWorldgen.java b/src/main/java/gregtech/api/world/GTWorldgen.java
index 19c3c24245..07c76e0e3a 100644
--- a/src/main/java/gregtech/api/world/GTWorldgen.java
+++ b/src/main/java/gregtech/api/world/GTWorldgen.java
@@ -9,9 +9,6 @@ import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.common.DimensionManager;
-import gregtech.common.WorldgenGTOreLayer;
-import gregtech.common.WorldgenGTOreSmallPieces;
-
public abstract class GTWorldgen {
public final String mWorldGenName;
@@ -85,6 +82,18 @@ public abstract class GTWorldgen {
* Overworld, Twilight Forest and Deep Dark)
*/
public boolean isGenerationAllowed(World aWorld, Class... aAllowedDimensionTypes) {
+ return isGenerationAllowed(aWorld, null, aAllowedDimensionTypes);
+ }
+
+ /**
+ *
+ * @param aWorld The World Object
+ * @param blackListedProviders List of blacklisted Worldgeneration classes
+ * @param aAllowedDimensionTypes The Types 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, String[] blackListedProviders, Class... aAllowedDimensionTypes) {
String aDimName = aWorld.provider.getDimensionName();
if (aDimName.equalsIgnoreCase("Underdark")) {
return false;
@@ -95,6 +104,15 @@ public abstract class GTWorldgen {
Boolean tAllowed = mDimensionMap.get(aDimName);
if (tAllowed == null) {
+ if (blackListedProviders != null) {
+ for (String dimClass : blackListedProviders) {
+ if (dimClass.equals(
+ aWorld.provider.getClass()
+ .getName())) {
+ return false;
+ }
+ }
+ }
boolean value = false;
for (Class aAllowedDimensionType : aAllowedDimensionTypes) {
if (aAllowedDimensionType.isInstance(aWorld.provider)) {
@@ -103,19 +121,6 @@ public abstract class GTWorldgen {
}
}
- // ugly, but idk how to do it better without hard depping on tf provider in ore constructors
- if (this instanceof WorldgenGTOreSmallPieces ore) {
- if (ore.twilightForest && aWorld.provider.dimensionId == 7) {
- value = true;
- }
- }
-
- if (this instanceof WorldgenGTOreLayer ore) {
- if (ore.twilightForest && aWorld.provider.dimensionId == 7) {
- value = true;
- }
- }
-
mDimensionMap.put(aDimName, value);
return value;
}
diff --git a/src/main/java/gregtech/common/WorldgenGTOreLayer.java b/src/main/java/gregtech/common/WorldgenGTOreLayer.java
index 2a31395a69..0e7c69b867 100644
--- a/src/main/java/gregtech/common/WorldgenGTOreLayer.java
+++ b/src/main/java/gregtech/common/WorldgenGTOreLayer.java
@@ -51,6 +51,14 @@ public class WorldgenGTOreLayer extends GTWorldgen {
public final String aTextWorldgen = "worldgen.";
public Class[] mAllowedProviders;
+ public String[] blackListedProviders;
+ public static Class tfProviderClass;
+
+ static {
+ try {
+ tfProviderClass = Class.forName("twilightforest.world.WorldProviderTwilightForest");
+ } catch (ClassNotFoundException ignored) {}
+ }
public WorldgenGTOreLayer(OreMixBuilder mix) {
super(mix.oreMixName, sList, mix.enabledByDefault);
@@ -87,6 +95,13 @@ public class WorldgenGTOreLayer extends GTWorldgen {
if (this.mOverworld) {
allowedProviders.add(WorldProviderSurface.class);
+ if (!this.twilightForest) {
+ blackListedProviders = new String[] { "twilightforest.world.WorldProviderTwilightForest" };
+ }
+ }
+
+ if (tfProviderClass != null && this.twilightForest) {
+ allowedProviders.add(tfProviderClass);
}
if (this.mEnd) {
@@ -104,7 +119,7 @@ public class WorldgenGTOreLayer extends GTWorldgen {
return ORE_PLACED;
}
- if (!isGenerationAllowed(aWorld, mAllowedProviders)) {
+ if (!isGenerationAllowed(aWorld, blackListedProviders, mAllowedProviders)) {
// The following code can be used for debugging, but it spams in logs
// if (debugOrevein) { GTLog.out.println( "Wrong dimension" ); }
return WRONG_DIMENSION;
diff --git a/src/main/java/gregtech/common/WorldgenGTOreSmallPieces.java b/src/main/java/gregtech/common/WorldgenGTOreSmallPieces.java
index 4eb4eb4cce..e3be59a628 100644
--- a/src/main/java/gregtech/common/WorldgenGTOreSmallPieces.java
+++ b/src/main/java/gregtech/common/WorldgenGTOreSmallPieces.java
@@ -31,6 +31,14 @@ public class WorldgenGTOreSmallPieces extends GTWorldgen {
public static ArrayList<WorldgenGTOreSmallPieces> sList = new ArrayList<>();
public Class[] mAllowedProviders;
+ public String[] blackListedProviders;
+ public static Class tfProviderClass;
+
+ static {
+ try {
+ tfProviderClass = Class.forName("twilightforest.world.WorldProviderTwilightForest");
+ } catch (ClassNotFoundException ignored) {}
+ }
public WorldgenGTOreSmallPieces(SmallOreBuilder ore) {
super(ore.smallOreName, GregTechAPI.sWorldgenList, ore.enabledByDefault);
@@ -54,6 +62,13 @@ public class WorldgenGTOreSmallPieces extends GTWorldgen {
if (this.mOverworld) {
allowedProviders.add(WorldProviderSurface.class);
+ if (!this.twilightForest) {
+ blackListedProviders = new String[] { "twilightforest.world.WorldProviderTwilightForest" };
+ }
+ }
+
+ if (tfProviderClass != null && this.twilightForest) {
+ allowedProviders.add(tfProviderClass);
}
if (this.mEnd) {