diff options
author | boubou19 <miisterunknown@gmail.com> | 2024-09-14 22:35:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-14 20:35:51 +0000 |
commit | 9c18caf7fc642a21efad6673e59db85f5b66ab88 (patch) | |
tree | dbd10650e51b45b94eb47734c76ca43ea6226e7a /src/main/java/bartworks/system | |
parent | 0d2de2fef9148b2284d700810aad18a6139f1130 (diff) | |
download | GT5-Unofficial-9c18caf7fc642a21efad6673e59db85f5b66ab88.tar.gz GT5-Unofficial-9c18caf7fc642a21efad6673e59db85f5b66ab88.tar.bz2 GT5-Unofficial-9c18caf7fc642a21efad6673e59db85f5b66ab88.zip |
Port BW config to GTNHLib (#3169)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/bartworks/system')
7 files changed, 146 insertions, 78 deletions
diff --git a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java index c81f62e2ab..8e04f770f8 100644 --- a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java +++ b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -35,7 +35,6 @@ import com.google.common.collect.HashBiMap; import bartworks.API.recipe.BWNBTDependantCraftingRecipe; import bartworks.API.recipe.BartWorksRecipeMaps; import bartworks.ASM.BWCoreStaticReplacementMethodes; -import bartworks.common.configs.ConfigHandler; import bartworks.system.material.WerkstoffLoader; import bartworks.util.BWUtil; import bartworks.util.Pair; @@ -43,6 +42,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; import gregtech.api.recipe.RecipeMaps; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTOreDictUnificator; @@ -113,7 +113,7 @@ public class CircuitImprintLoader { GTRecipe newRecipe = CircuitImprintLoader.reBuildRecipe(circuitRecipe); if (newRecipe != null) BartWorksRecipeMaps.circuitAssemblyLineRecipes.addRecipe(newRecipe); addCutoffRecipeToSets(toRem, toAdd, circuitRecipe); - } else if (circuitRecipe.mEUt > BWUtil.getTierVoltage(ConfigHandler.cutoffTier)) toRem.add(circuitRecipe); + } else if (circuitRecipe.mEUt > TierEU.IV) toRem.add(circuitRecipe); } } @@ -133,7 +133,7 @@ public class CircuitImprintLoader { private static void addCutoffRecipeToSets(HashSet<GTRecipe> toRem, HashSet<GTRecipe> toAdd, GTRecipe circuitRecipe) { - if (circuitRecipe.mEUt > BWUtil.getTierVoltage(ConfigHandler.cutoffTier)) { + if (circuitRecipe.mEUt > TierEU.IV) { toRem.add(circuitRecipe); toAdd.add(CircuitImprintLoader.makeMoreExpensive(circuitRecipe)); } diff --git a/src/main/java/bartworks/system/material/WerkstoffLoader.java b/src/main/java/bartworks/system/material/WerkstoffLoader.java index 858fda7a58..a1b1aac2ed 100644 --- a/src/main/java/bartworks/system/material/WerkstoffLoader.java +++ b/src/main/java/bartworks/system/material/WerkstoffLoader.java @@ -95,7 +95,6 @@ import bartworks.API.SideReference; import bartworks.API.WerkstoffAdderRegistry; import bartworks.MainMod; import bartworks.client.renderer.BWBlockOreRenderer; -import bartworks.common.configs.ConfigHandler; import bartworks.system.material.CircuitGeneration.BWCircuitsLoader; import bartworks.system.material.gtenhancement.GTMetaItemEnhancer; import bartworks.system.material.processingLoaders.AdditionalRecipes; @@ -1956,11 +1955,11 @@ public class WerkstoffLoader { GameRegistry.registerBlock(WerkstoffLoader.BWOres, BWItemMetaGeneratedBlock.class, "bw.blockores.01"); GameRegistry.registerBlock(WerkstoffLoader.BWSmallOres, BWItemMetaGeneratedBlock.class, "bw.blockores.02"); GameRegistry.registerBlock(WerkstoffLoader.BWBlocks, BWItemMetaGeneratedBlock.class, "bw.werkstoffblocks.01"); - if (!ConfigHandler.disableBoltedBlocksCasing) GameRegistry.registerBlock( + GameRegistry.registerBlock( WerkstoffLoader.BWBlockCasings, BWItemMetaGeneratedBlock.class, "bw.werkstoffblockscasing.01"); - if (!ConfigHandler.disableReboltedBlocksCasing) GameRegistry.registerBlock( + GameRegistry.registerBlock( WerkstoffLoader.BWBlockCasingsAdvanced, BWItemMetaGeneratedBlock.class, "bw.werkstoffblockscasingadvanced.01"); diff --git a/src/main/java/bartworks/system/material/processingLoaders/DownTierLoader.java b/src/main/java/bartworks/system/material/processingLoaders/DownTierLoader.java deleted file mode 100644 index 7be8b72bf0..0000000000 --- a/src/main/java/bartworks/system/material/processingLoaders/DownTierLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following - * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial - * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -package bartworks.system.material.processingLoaders; - -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -import bartworks.util.BWUtil; -import bartworks.util.StreamUtils; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.util.GTRecipe; - -public class DownTierLoader { - - public static void run() { - RecipeMap.ALL_RECIPE_MAPS.values() - .stream() - .filter(map -> StreamUtils.filterVisualMaps(map) && map != RecipeMaps.fusionRecipes) - .forEach(map -> { - Set<GTRecipe> newRecipes = new HashSet<>(); - Set<GTRecipe> toRem = new HashSet<>(); - map.getAllRecipes() - .stream() - .filter(recipe -> Objects.nonNull(recipe) && recipe.mEUt > 128) - .forEach(recipe -> { - toRem.add(recipe); - newRecipes.add(BWUtil.copyAndSetTierToNewRecipe(recipe, (byte) 2)); - }); - map.getBackend() - .removeRecipes(toRem); - newRecipes.forEach(map::add); - }); - } -} diff --git a/src/main/java/bartworks/system/oregen/BWWorldGenRoss128b.java b/src/main/java/bartworks/system/oregen/BWWorldGenRoss128b.java index 2c996c4668..8c50a2803e 100644 --- a/src/main/java/bartworks/system/oregen/BWWorldGenRoss128b.java +++ b/src/main/java/bartworks/system/oregen/BWWorldGenRoss128b.java @@ -29,7 +29,7 @@ import net.minecraft.init.Blocks; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import bartworks.common.configs.ConfigHandler; +import bartworks.common.configs.Configuration; import bartworks.system.material.WerkstoffLoader; import bwcrossmod.galacticraft.planets.ross128b.WorldProviderRoss128b; import gregtech.api.interfaces.ISubTagContainer; @@ -183,6 +183,6 @@ public class BWWorldGenRoss128b extends BWOreLayer { @Override public boolean isGenerationAllowed(String aDimName, int aDimensionType, int aAllowedDimensionType) { - return aDimensionType == ConfigHandler.ross128BID; + return aDimensionType == Configuration.crossModInteractions.ross128BID; } } diff --git a/src/main/java/bartworks/system/oregen/BWWorldGenRoss128ba.java b/src/main/java/bartworks/system/oregen/BWWorldGenRoss128ba.java index d4df2b8340..74b4ec51ae 100644 --- a/src/main/java/bartworks/system/oregen/BWWorldGenRoss128ba.java +++ b/src/main/java/bartworks/system/oregen/BWWorldGenRoss128ba.java @@ -26,7 +26,7 @@ import net.minecraft.block.Block; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import bartworks.common.configs.ConfigHandler; +import bartworks.common.configs.Configuration; import bartworks.system.material.WerkstoffLoader; import bwcrossmod.galacticraft.planets.ross128ba.WorldProviderRoss128ba; import gregtech.api.interfaces.ISubTagContainer; @@ -171,6 +171,6 @@ public class BWWorldGenRoss128ba extends BWOreLayer { @Override public boolean isGenerationAllowed(String aDimName, int aDimensionType, int aAllowedDimensionType) { - return aDimensionType == ConfigHandler.ross128BAID; + return aDimensionType == Configuration.crossModInteractions.ross128BAID; } } 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++; |