From c7ae290572e761c8ee0c1a2191d6091f8dcf709d Mon Sep 17 00:00:00 2001 From: Spacebuilder2020 Date: Mon, 12 Aug 2024 10:14:55 -0600 Subject: 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 --- .../bartworks/system/oregen/BW_WordGenerator.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/main/java/com') diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java index 40c2302fb0..56e67ab9e5 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java @@ -18,6 +18,7 @@ import java.util.Random; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; +import net.minecraft.world.WorldProvider; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; @@ -40,7 +41,7 @@ public class BW_WordGenerator implements IWorldGenerator { new BW_WordGenerator.WorldGenContainer( aX * 16, aZ * 16, - aWorld.provider.dimensionId, + aWorld.provider, aWorld, aChunkGenerator, aChunkProvider).run(); @@ -49,18 +50,18 @@ public class BW_WordGenerator implements IWorldGenerator { public static class WorldGenContainer implements Runnable { public static HashSet mGenerated = new HashSet<>(2000); - public final int mDimensionType; + public final WorldProvider mWorldProvider; public final World mWorld; public final IChunkProvider mChunkGenerator; public final IChunkProvider mChunkProvider; public int mX; public int mZ; - public WorldGenContainer(int aX, int aZ, int aDimensionType, World aWorld, IChunkProvider aChunkGenerator, - IChunkProvider aChunkProvider) { + public WorldGenContainer(int aX, int aZ, WorldProvider aWorldProvider, World aWorld, + IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { this.mX = aX; this.mZ = aZ; - this.mDimensionType = aDimensionType; + this.mWorldProvider = aWorldProvider; this.mWorld = aWorld; this.mChunkGenerator = aChunkGenerator; this.mChunkProvider = aChunkProvider; @@ -102,8 +103,7 @@ public class BW_WordGenerator implements IWorldGenerator { for (int i = 0; i < 256 && temp; i++) { tRandomWeight = random.nextInt(BW_OreLayer.sWeight); for (BW_OreLayer tWorldGen : BW_OreLayer.sList) { - if (!tWorldGen.isGenerationAllowed(this.mWorld, this.mDimensionType, this.mDimensionType)) - continue; + if (!tWorldGen.isGenerationAllowed(this.mWorld, mWorldProvider.getClass())) continue; tRandomWeight -= tWorldGen.mWeight; if (tRandomWeight <= 0) { try { @@ -114,7 +114,7 @@ public class BW_WordGenerator implements IWorldGenerator { this.mWorld, random, "", - this.mDimensionType, + this.mWorldProvider.dimensionId, xCenter, zCenter, this.mChunkGenerator, -- cgit