diff options
author | YannickMG <yannickmg@gmail.com> | 2022-07-06 15:35:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-06 20:35:36 +0100 |
commit | 7836eea57a199661e1ac4b41d9ae678e62588ee2 (patch) | |
tree | ed9c71b33553fcdc58b52664b1efb3dbe4e3cb45 /src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java | |
parent | 1cb11f470f296eb4db63174f7e58b17c7af7000d (diff) | |
download | GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.tar.gz GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.tar.bz2 GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.zip |
Enhanced NEI discoverability (#17)
* Removed unused code
* Addressed IDE warnings
* Refactored PluginGT5VeinStat::loadCraftingRecipes for readability
* Refactored PluginGT5VeinStat::drawExtras for readability
* Added OreVeinLayer class for the concept of ore layer
* Updated buildscript
* Ran spotlessApply
* Addressed some trivial IDE warnings
* Load both Small Ores and regular Ores when either is queried.
* Refactored PluginGT5SmallOreStat::loadCraftingRecipes for readability
* Refactored PluginGT5SmallOreStat::drawExtras for readability
Diffstat (limited to 'src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java')
-rw-r--r-- | src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java | 83 |
1 files changed, 57 insertions, 26 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java index 6dc155e9fd..a730b3d148 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java @@ -6,20 +6,20 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.world.GT_Worldgen; import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces; -import net.minecraft.item.ItemStack; - import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import net.minecraft.item.ItemStack; public class GT5OreSmallHelper { + private static final int SMALL_ORE_BASE_META = 16000; public static boolean restrictBiomeSupport = false; public static boolean gcBasicSupport = false; - public static List<ItemStack> oreSmallList = new ArrayList<ItemStack>(); - public static HashMap<String, OreSmallWrapper> mapOreSmallWrapper = new HashMap<String, OreSmallWrapper>(); - public static HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<String, Short>(); - public static HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<Short, List<ItemStack>>(); + public static List<ItemStack> oreSmallList = new ArrayList<>(); + public static HashMap<String, OreSmallWrapper> mapOreSmallWrapper = new HashMap<>(); + public static HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<>(); + public static HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<>(); public static HashMap<OreSmallWrapper, String> bufferedDims = new HashMap<>(); public GT5OreSmallHelper() { @@ -31,48 +31,63 @@ public class GT5OreSmallHelper { if (worldGen.mWorldGenName.startsWith("ore.small.") && worldGen instanceof GT_Worldgen_GT_Ore_SmallPieces) { GT_Worldgen_GT_Ore_SmallPieces worldGenSmallPieces = (GT_Worldgen_GT_Ore_SmallPieces) worldGen; meta = worldGenSmallPieces.mMeta; - if (meta < 0) - break; + if (meta < 0) break; material = GregTech_API.sGeneratedMaterials[meta]; mapOreSmallWrapper.put(worldGen.mWorldGenName, new OreSmallWrapper(worldGenSmallPieces)); - if (!mapOreMetaToOreDrops.keySet().contains(meta)) { - List<ItemStack> stackList = new ArrayList<ItemStack>(); - stack = GT_OreDictUnificator.get(OrePrefixes.gemExquisite, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + if (!mapOreMetaToOreDrops.containsKey(meta)) { + List<ItemStack> stackList = new ArrayList<>(); + stack = GT_OreDictUnificator.get( + OrePrefixes.gemExquisite, + material, + GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), + 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); stackList.add(stack); } - stack = GT_OreDictUnificator.get(OrePrefixes.gemFlawless, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + stack = GT_OreDictUnificator.get( + OrePrefixes.gemFlawless, + material, + GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), + 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); stackList.add(stack); } stack = GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); stackList.add(stack); } - stack = GT_OreDictUnificator.get(OrePrefixes.gemFlawed, material, GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + stack = GT_OreDictUnificator.get( + OrePrefixes.gemFlawed, + material, + GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L), + 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); stackList.add(stack); } stack = GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); stackList.add(stack); } - stack = GT_OreDictUnificator.get(OrePrefixes.gemChipped, material, GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + stack = GT_OreDictUnificator.get( + OrePrefixes.gemChipped, + material, + GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L), + 1L); + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); stackList.add(stack); } stack = GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) { + if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); stackList.add(stack); } - oreSmallList.add(new ItemStack(GregTech_API.sBlockOres1, 1, meta + 16000)); + oreSmallList.add(new ItemStack(GregTech_API.sBlockOres1, 1, meta + SMALL_ORE_BASE_META)); mapOreMetaToOreDrops.put(meta, stackList); } } @@ -82,9 +97,9 @@ public class GT5OreSmallHelper { } private static void checkExtraSupport() { - Class clazzGTOreSmall = null; + Class<?> clazzGTOreSmall = null; try { - clazzGTOreSmall = Class.forName("gregtech.common.GT_Worldgen_GT_Ore_SmallPieces"); + clazzGTOreSmall = Class.forName("gregtech.common" + ".GT_Worldgen_GT_Ore_SmallPieces"); } catch (ClassNotFoundException e) { } if (clazzGTOreSmall != null) { @@ -103,10 +118,19 @@ public class GT5OreSmallHelper { } public static Materials[] getDroppedDusts() { - return new Materials[]{Materials.Stone, Materials.Netherrack, Materials.Endstone, Materials.GraniteBlack, Materials.GraniteRed, Materials.Marble, Materials.Basalt, Materials.Stone}; + return new Materials[] { + Materials.Stone, + Materials.Netherrack, + Materials.Endstone, + Materials.GraniteBlack, + Materials.GraniteRed, + Materials.Marble, + Materials.Basalt, + Materials.Stone + }; } - public class OreSmallWrapper { + public static class OreSmallWrapper { public String oreGenName; public short oreMeta; public String worldGenHeightRange; @@ -119,5 +143,12 @@ public class GT5OreSmallHelper { this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY; this.amountPerChunk = worldGen.mAmount; } + + public List<ItemStack> getMaterialDrops(int maximumIndex) { + List<ItemStack> stackList = new ArrayList<>(); + for (int i = 0; i < maximumIndex; i++) + stackList.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreMeta + SMALL_ORE_BASE_META + i * 1000)); + return stackList; + } } } |