aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/bartworks/system/worldgen
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/bartworks/system/worldgen')
-rw-r--r--src/main/java/bartworks/system/worldgen/BWWorldGenUtil.java142
-rw-r--r--src/main/java/bartworks/system/worldgen/MapGenRuins.java16
2 files changed, 137 insertions, 21 deletions
diff --git a/src/main/java/bartworks/system/worldgen/BWWorldGenUtil.java b/src/main/java/bartworks/system/worldgen/BWWorldGenUtil.java
index db32462ca4..3dd8cfffca 100644
--- a/src/main/java/bartworks/system/worldgen/BWWorldGenUtil.java
+++ b/src/main/java/bartworks/system/worldgen/BWWorldGenUtil.java
@@ -17,7 +17,7 @@ import java.util.Random;
import net.minecraft.block.Block;
-import bartworks.common.configs.ConfigHandler;
+import bartworks.common.configs.Configuration;
import gregtech.api.GregTechAPI;
public class BWWorldGenUtil {
@@ -26,23 +26,139 @@ public class BWWorldGenUtil {
public static final Block GT_TILES = GregTechAPI.sBlockMachines;
- public static short getGenerator(Random rand, int tier) {
- int meta = ConfigHandler.metasForTiers[0][tier][rand.nextInt(ConfigHandler.metasForTiers[0][tier].length)];
- return GregTechAPI.METATILEENTITIES[meta] != null ? (short) meta : BWWorldGenUtil.getGenerator(rand, tier);
+ public static int getGenerator(Random rand, int tier) {
+ int meta, randomIndex;
+ switch (tier) {
+ case 0 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.highPressureSteam.generators.length);
+ meta = Configuration.rossRuinMetas.highPressureSteam.generators[randomIndex];
+ }
+ case 1 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.lv.generators.length);
+ meta = Configuration.rossRuinMetas.lv.generators[randomIndex];
+ }
+ case 2 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.mv.generators.length);
+ meta = Configuration.rossRuinMetas.mv.generators[randomIndex];
+ }
+ case 3 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.hv.generators.length);
+ meta = Configuration.rossRuinMetas.hv.generators[randomIndex];
+ }
+ case 4 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.ev.generators.length);
+ meta = Configuration.rossRuinMetas.ev.generators[randomIndex];
+ }
+ default -> {
+ throw new IllegalStateException("tier " + tier + " is not allowed for Ross Ruins.");
+ }
+ }
+ if (GregTechAPI.METATILEENTITIES[meta] == null) {
+ throw new IllegalStateException("MetaID " + meta + " is null, please remove it from the Ross Ruin config");
+ }
+
+ return meta;
}
- public static short getBuffer(Random rand, int tier) {
- int meta = ConfigHandler.metasForTiers[1][tier][rand.nextInt(ConfigHandler.metasForTiers[1][tier].length)];
- return GregTechAPI.METATILEENTITIES[meta] != null ? (short) meta : BWWorldGenUtil.getBuffer(rand, tier);
+ public static int getBuffer(Random rand, int tier) {
+ int meta, randomIndex;
+ switch (tier) {
+ case 0 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.highPressureSteam.buffers.length);
+ meta = Configuration.rossRuinMetas.highPressureSteam.buffers[randomIndex];
+ }
+ case 1 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.lv.buffers.length);
+ meta = Configuration.rossRuinMetas.lv.buffers[randomIndex];
+ }
+ case 2 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.mv.buffers.length);
+ meta = Configuration.rossRuinMetas.mv.buffers[randomIndex];
+ }
+ case 3 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.hv.buffers.length);
+ meta = Configuration.rossRuinMetas.hv.buffers[randomIndex];
+ }
+ case 4 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.ev.buffers.length);
+ meta = Configuration.rossRuinMetas.ev.buffers[randomIndex];
+ }
+ default -> {
+ throw new IllegalStateException("tier " + tier + " is not allowed for Ross Ruins.");
+ }
+ }
+ if (GregTechAPI.METATILEENTITIES[meta] == null) {
+ throw new IllegalStateException("MetaID " + meta + " is null, please remove it from the Ross Ruin config");
+ }
+
+ return meta;
}
- public static short getCable(Random rand, int tier) {
- int meta = ConfigHandler.metasForTiers[2][tier][rand.nextInt(ConfigHandler.metasForTiers[2][tier].length)];
- return GregTechAPI.METATILEENTITIES[meta] != null ? (short) meta : BWWorldGenUtil.getCable(rand, tier);
+ public static int getCable(Random rand, int tier) {
+ int meta, randomIndex;
+ switch (tier) {
+ case 0 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.highPressureSteam.cables.length);
+ meta = Configuration.rossRuinMetas.highPressureSteam.cables[randomIndex];
+ }
+ case 1 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.lv.cables.length);
+ meta = Configuration.rossRuinMetas.lv.cables[randomIndex];
+ }
+ case 2 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.mv.cables.length);
+ meta = Configuration.rossRuinMetas.mv.cables[randomIndex];
+ }
+ case 3 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.hv.cables.length);
+ meta = Configuration.rossRuinMetas.hv.cables[randomIndex];
+ }
+ case 4 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.ev.cables.length);
+ meta = Configuration.rossRuinMetas.ev.cables[randomIndex];
+ }
+ default -> {
+ throw new IllegalStateException("tier " + tier + " is not allowed for Ross Ruins.");
+ }
+ }
+ if (GregTechAPI.METATILEENTITIES[meta] == null) {
+ throw new IllegalStateException("MetaID " + meta + " is null, please remove it from the Ross Ruin config");
+ }
+
+ return meta;
}
- public static short getMachine(Random rand, int tier) {
- int meta = ConfigHandler.metasForTiers[3][tier][rand.nextInt(ConfigHandler.metasForTiers[3][tier].length)];
- return GregTechAPI.METATILEENTITIES[meta] != null ? (short) meta : BWWorldGenUtil.getMachine(rand, tier);
+ public static int getMachine(Random rand, int tier) {
+ int meta, randomIndex;
+ switch (tier) {
+ case 0 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.highPressureSteam.machines.length);
+ meta = Configuration.rossRuinMetas.highPressureSteam.machines[randomIndex];
+ }
+ case 1 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.lv.machines.length);
+ meta = Configuration.rossRuinMetas.lv.machines[randomIndex];
+ }
+ case 2 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.mv.machines.length);
+ meta = Configuration.rossRuinMetas.mv.machines[randomIndex];
+ }
+ case 3 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.hv.machines.length);
+ meta = Configuration.rossRuinMetas.hv.machines[randomIndex];
+ }
+ case 4 -> {
+ randomIndex = rand.nextInt(Configuration.rossRuinMetas.ev.machines.length);
+ meta = Configuration.rossRuinMetas.ev.machines[randomIndex];
+ }
+ default -> {
+ throw new IllegalStateException("tier " + tier + " is not allowed for Ross Ruins.");
+ }
+ }
+ if (GregTechAPI.METATILEENTITIES[meta] == null) {
+ throw new IllegalStateException("MetaID " + meta + " is null, please remove it from the Ross Ruin config");
+ }
+
+ return meta;
}
}
diff --git a/src/main/java/bartworks/system/worldgen/MapGenRuins.java b/src/main/java/bartworks/system/worldgen/MapGenRuins.java
index a5668fb7ed..b8489ccce4 100644
--- a/src/main/java/bartworks/system/worldgen/MapGenRuins.java
+++ b/src/main/java/bartworks/system/worldgen/MapGenRuins.java
@@ -13,7 +13,6 @@
package bartworks.system.worldgen;
-import static bartworks.common.configs.ConfigHandler.maxTierRoss;
import static net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST;
import java.security.SecureRandom;
@@ -29,6 +28,7 @@ import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.util.ForgeDirection;
+import bartworks.common.configs.Configuration;
import bartworks.util.Pair;
import gregtech.api.GregTechAPI;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -225,11 +225,11 @@ public abstract class MapGenRuins extends WorldGenerator {
this.setMiscBlocks(new int[] { 1 }, Blocks.log);
this.statBlocks = new int[] { rand.nextInt(this.ToBuildWith[0].length) };
int colored = rand.nextInt(15);
- int tier = secureRandom.nextInt(maxTierRoss);
+ int tier = secureRandom.nextInt(Configuration.RossRuinMetas.maxTierRoss);
boolean useColor = rand.nextBoolean();
byte set = 0;
- byte toSet = (byte) (rand.nextInt(maxTierRoss - tier) + 1);
- short cablemeta = BWWorldGenUtil.getCable(secureRandom, tier);
+ byte toSet = (byte) (rand.nextInt(Configuration.RossRuinMetas.maxTierRoss - tier) + 1);
+ int cablemeta = BWWorldGenUtil.getCable(secureRandom, tier);
byte treeinaRow = 0;
boolean lastset = rand.nextBoolean();
for (int dx = -6; dx <= 6; dx++) {
@@ -316,7 +316,7 @@ public abstract class MapGenRuins extends WorldGenerator {
}
if (dx == 4 && dz == 4) {
- short meta = BWWorldGenUtil.getGenerator(secureRandom, tier);
+ int meta = BWWorldGenUtil.getGenerator(secureRandom, tier);
this.setGTMachine(
worldObj,
x + dx,
@@ -327,7 +327,7 @@ public abstract class MapGenRuins extends WorldGenerator {
tier > 0 ? ForgeDirection.WEST : ForgeDirection.UP);
} else if (dx == 3 && dz == 4) {
if (tier > 0) {
- short meta = BWWorldGenUtil.getBuffer(secureRandom, tier);
+ int meta = BWWorldGenUtil.getBuffer(secureRandom, tier);
this.setGTMachine(
worldObj,
x + dx,
@@ -343,7 +343,7 @@ public abstract class MapGenRuins extends WorldGenerator {
this.setGTCablekWChance(worldObj, x + dx, y + dy, z + dz, rand, 33, cablemeta);
} else if (dx < 3 && dx > -5 && dz == 3 && set < toSet) {
if (!lastset || treeinaRow > 2) {
- short meta = BWWorldGenUtil.getMachine(secureRandom, tier);
+ int meta = BWWorldGenUtil.getMachine(secureRandom, tier);
this.setGTMachine(
worldObj,
x + dx,
@@ -481,7 +481,7 @@ public abstract class MapGenRuins extends WorldGenerator {
break tosetloop;
}
if (!lastset || treeinaRow > 2 && worldObj.getTileEntity(x + dx, y + dy, z + dz) == null) {
- short meta = BWWorldGenUtil.getMachine(secureRandom, tier);
+ int meta = BWWorldGenUtil.getMachine(secureRandom, tier);
this.setGTMachine(worldObj, x + dx, y + dy, z + dz, meta, owner, ForgeDirection.UP);
set++;