aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
authorSpacebuilder2020 <spacebuilder2020@users.noreply.github.com>2024-08-12 10:14:55 -0600
committerGitHub <noreply@github.com>2024-08-12 23:14:55 +0700
commitc7ae290572e761c8ee0c1a2191d6091f8dcf709d (patch)
tree662e430957c9ec013244d5000ef7a6ed613977ba /src/main/java/gregtech/common
parent0ac5ccb1384d5e6c56bafe7ae7dd96b653d0df9c (diff)
downloadGT5-Unofficial-c7ae290572e761c8ee0c1a2191d6091f8dcf709d.tar.gz
GT5-Unofficial-c7ae290572e761c8ee0c1a2191d6091f8dcf709d.tar.bz2
GT5-Unofficial-c7ae290572e761c8ee0c1a2191d6091f8dcf709d.zip
Implement dim num agnostic isGenerationAllowed function (#2854)
* Implement dim num agnostic isGenerationAllowed function Replaces references to old function in as many places as possible Only reference that can't be changed right now is `E:\MinecraftProjects\GT5-Unofficial\src\main\java\com\github\bartimaeusnek\crossmod\galacticgreg\VoidMinerUtility.java:189` * Account for unloaded world or null provider by instead doing a dim number check This route should be avoided when possible. * Apply Spotless
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java27
-rw-r--r--src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java40
-rw-r--r--src/main/java/gregtech/common/GT_Worldgen_Stone.java2
3 files changed, 58 insertions, 11 deletions
diff --git a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java
index fd260d73a4..23bf149b9c 100644
--- a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java
+++ b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java
@@ -5,12 +5,16 @@ import static gregtech.api.enums.GT_Values.oreveinPlacerOres;
import static gregtech.api.enums.GT_Values.oreveinPlacerOresMultiplier;
import java.util.ArrayList;
+import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+import net.minecraft.world.WorldProviderEnd;
+import net.minecraft.world.WorldProviderHell;
+import net.minecraft.world.WorldProviderSurface;
import net.minecraft.world.chunk.IChunkProvider;
import gregtech.api.GregTech_API;
@@ -48,6 +52,8 @@ public class GT_Worldgen_GT_Ore_Layer extends GT_Worldgen {
public final boolean mMoon = false, mMars = false, mAsteroid = false;
public final String aTextWorldgen = "worldgen.";
+ public Class[] mAllowedProviders;
+
@Deprecated
public GT_Worldgen_GT_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity,
int aSize, boolean aOverworld, boolean aNether, boolean aEnd, boolean GC_UNUSED1, boolean GC_UNUSED2,
@@ -104,6 +110,20 @@ public class GT_Worldgen_GT_Ore_Layer extends GT_Worldgen {
if (this.mEnabled) {
sWeight += this.mWeight;
}
+
+ List<Class> allowedProviders = new ArrayList<>();
+ if (this.mNether) {
+ allowedProviders.add(WorldProviderHell.class);
+ }
+
+ if (this.mOverworld) {
+ allowedProviders.add(WorldProviderSurface.class);
+ }
+
+ if (this.mEnd) {
+ allowedProviders.add(WorldProviderEnd.class);
+ }
+ mAllowedProviders = allowedProviders.toArray(new Class[allowedProviders.size()]);
}
@Override
@@ -114,11 +134,8 @@ public class GT_Worldgen_GT_Ore_Layer extends GT_Worldgen {
// Return a special empty orevein
return ORE_PLACED;
}
- if (!isGenerationAllowed(
- aWorld,
- aDimensionType,
- ((aDimensionType == -1) && (this.mNether)) || ((aDimensionType == 0) && (this.mOverworld))
- || ((aDimensionType == 1) && (this.mEnd)) ? aDimensionType : ~aDimensionType)) {
+
+ if (!isGenerationAllowed(aWorld, mAllowedProviders)) {
// The following code can be used for debugging, but it spams in logs
// if (debugOrevein) { GT_Log.out.println( "Wrong dimension" ); }
return WRONG_DIMENSION;
diff --git a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java
index c8219e8361..f1e0c92703 100644
--- a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java
+++ b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java
@@ -3,9 +3,13 @@ package gregtech.common;
import static gregtech.api.enums.GT_Values.debugSmallOres;
import java.util.ArrayList;
+import java.util.List;
import java.util.Random;
import net.minecraft.world.World;
+import net.minecraft.world.WorldProviderEnd;
+import net.minecraft.world.WorldProviderHell;
+import net.minecraft.world.WorldProviderSurface;
import net.minecraft.world.chunk.IChunkProvider;
import gregtech.api.GregTech_API;
@@ -28,6 +32,8 @@ public class GT_Worldgen_GT_Ore_SmallPieces extends GT_Worldgen {
public final String aTextWorldgen = "worldgen.";
public static ArrayList<GT_Worldgen_GT_Ore_SmallPieces> sList = new ArrayList<>();
+ public Class[] mAllowedProviders;
+
// TODO CHECK IF INSTANTIATION IS CORRECT
public GT_Worldgen_GT_Ore_SmallPieces(String aName, boolean aDefault, int aMinY, int aMaxY, int aAmount,
boolean aOverworld, boolean aNether, boolean aEnd, Materials aPrimary) {
@@ -45,6 +51,20 @@ public class GT_Worldgen_GT_Ore_SmallPieces extends GT_Worldgen {
.get(aTextWorldgen + this.mWorldGenName, "Ore", aPrimary.mMetaItemSubID));
this.mBiome = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "BiomeName", "None");
sList.add(this);
+
+ List<Class> allowedProviders = new ArrayList<>();
+ if (this.mNether) {
+ allowedProviders.add(WorldProviderHell.class);
+ }
+
+ if (this.mOverworld) {
+ allowedProviders.add(WorldProviderSurface.class);
+ }
+
+ if (this.mEnd) {
+ allowedProviders.add(WorldProviderEnd.class);
+ }
+ mAllowedProviders = allowedProviders.toArray(new Class[allowedProviders.size()]);
}
public GT_Worldgen_GT_Ore_SmallPieces(String aName, boolean aDefault, int aMinY, int aMaxY, int aAmount,
@@ -64,6 +84,20 @@ public class GT_Worldgen_GT_Ore_SmallPieces extends GT_Worldgen {
.get(aTextWorldgen + this.mWorldGenName, "Ore", aPrimary.mMetaItemSubID));
this.mBiome = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "BiomeName", "None");
sList.add(this);
+
+ List<Class> allowedProviders = new ArrayList<>();
+ if (this.mNether) {
+ allowedProviders.add(WorldProviderHell.class);
+ }
+
+ if (this.mOverworld) {
+ allowedProviders.add(WorldProviderSurface.class);
+ }
+
+ if (this.mEnd) {
+ allowedProviders.add(WorldProviderEnd.class);
+ }
+ mAllowedProviders = allowedProviders.toArray(new Class[allowedProviders.size()]);
}
@Override
@@ -72,11 +106,7 @@ public class GT_Worldgen_GT_Ore_SmallPieces extends GT_Worldgen {
if (!this.mBiome.equals("None") && !(this.mBiome.equals(aBiome))) {
return false; // Not the correct biome for ore mix
}
- if (!isGenerationAllowed(
- aWorld,
- aDimensionType,
- ((aDimensionType == -1) && (this.mNether)) || ((aDimensionType == 0) && (this.mOverworld))
- || ((aDimensionType == 1) && (this.mEnd)) ? aDimensionType : ~aDimensionType)) {
+ if (!isGenerationAllowed(aWorld, mAllowedProviders)) {
return false;
}
int count = 0;
diff --git a/src/main/java/gregtech/common/GT_Worldgen_Stone.java b/src/main/java/gregtech/common/GT_Worldgen_Stone.java
index 835f9d5c67..a9001d3f26 100644
--- a/src/main/java/gregtech/common/GT_Worldgen_Stone.java
+++ b/src/main/java/gregtech/common/GT_Worldgen_Stone.java
@@ -82,7 +82,7 @@ public class GT_Worldgen_Stone extends GT_Worldgen_Ore {
XSTR stoneRNG = new XSTR();
ArrayList<ValidSeeds> stones = new ArrayList<>();
- if (!isGenerationAllowed(aWorld, aDimensionType, this.mDimensionType)) {
+ if (!isGenerationAllowed(aWorld, mDimensionType)) {
return false;
}
if (!(this.mBiomeList.isEmpty() || this.mBiomeList.contains(aBiome))) {