diff options
Diffstat (limited to 'src/main/java/gregtech/common')
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))) { |