diff options
Diffstat (limited to 'src/main/java/gregtech/api/GregTech_API.java')
-rw-r--r-- | src/main/java/gregtech/api/GregTech_API.java | 218 |
1 files changed, 142 insertions, 76 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index d8ad1ca07b..7a8b495a4b 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -185,12 +185,13 @@ public class GregTech_API { sHeatHazmatList = new GT_HashSet<>(), sRadioHazmatList = new GT_HashSet<>(), sElectroHazmatList = new GT_HashSet<>(); - private static final Multimap<Integer, ItemStack> sRealConfigurationList = Multimaps - .newListMultimap(new TreeMap<>(), ArrayList::new); + private static final Multimap<Integer, ItemStack> sRealConfigurationList = Multimaps.newListMultimap( + new TreeMap<>(), + ArrayList::new); private static final Map<Integer, List<ItemStack>> sConfigurationLists = new ConcurrentHashMap<>(); private static final Map<Predicate<ItemStack>, BiFunction<ItemStack, EntityPlayerMP, ItemStack>> sRealCircuitProgrammerList = new LinkedHashMap<>(); - public static final Map<Predicate<ItemStack>, BiFunction<ItemStack, EntityPlayerMP, ItemStack>> sCircuitProgrammerList = Collections - .unmodifiableMap(sRealCircuitProgrammerList); + public static final Map<Predicate<ItemStack>, BiFunction<ItemStack, EntityPlayerMP, ItemStack>> sCircuitProgrammerList = Collections.unmodifiableMap( + sRealCircuitProgrammerList); /** * The List of Dimensions, which are Whitelisted for the Teleporter. This list should not contain other Planets. @@ -455,34 +456,36 @@ public class GregTech_API { int aTier, int aDamageEnergyCost, int aSpecials, double aArmorAbsorbtionPercentage, boolean aChargeProvider, int aType, int aArmorIndex) { try { - return (Item) Class.forName("gregtechmod.api.items.GT_EnergyArmorIC_Item").getConstructors()[0].newInstance( - aUnlocalized, - aEnglish, - aCharge, - aTransfer, - aTier, - aDamageEnergyCost, - aSpecials, - aArmorAbsorbtionPercentage, - aChargeProvider, - aType, - aArmorIndex); + return (Item) Class.forName("gregtechmod.api.items.GT_EnergyArmorIC_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aCharge, + aTransfer, + aTier, + aDamageEnergyCost, + aSpecials, + aArmorAbsorbtionPercentage, + aChargeProvider, + aType, + aArmorIndex); } catch (Throwable e) { /* Do nothing */ } try { - return (Item) Class.forName("gregtechmod.api.items.GT_EnergyArmor_Item").getConstructors()[0].newInstance( - aUnlocalized, - aEnglish, - aCharge, - aTransfer, - aTier, - aDamageEnergyCost, - aSpecials, - aArmorAbsorbtionPercentage, - aChargeProvider, - aType, - aArmorIndex); + return (Item) Class.forName("gregtechmod.api.items.GT_EnergyArmor_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aCharge, + aTransfer, + aTier, + aDamageEnergyCost, + aSpecials, + aArmorAbsorbtionPercentage, + aChargeProvider, + aType, + aArmorIndex); } catch (Throwable e) { /* Do nothing */ } @@ -499,14 +502,28 @@ public class GregTech_API { public static Item constructElectricEnergyStorageItem(String aUnlocalized, String aEnglish, int aCharge, int aTransfer, int aTier, int aEmptyID, int aFullID) { try { - return (Item) Class.forName("gregtechmod.api.items.GT_EnergyStoreIC_Item").getConstructors()[0] - .newInstance(aUnlocalized, aEnglish, aCharge, aTransfer, aTier, aEmptyID, aFullID); + return (Item) Class.forName("gregtechmod.api.items.GT_EnergyStoreIC_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aCharge, + aTransfer, + aTier, + aEmptyID, + aFullID); } catch (Throwable e) { /* Do nothing */ } try { - return (Item) Class.forName("gregtechmod.api.items.GT_EnergyStore_Item").getConstructors()[0] - .newInstance(aUnlocalized, aEnglish, aCharge, aTransfer, aTier, aEmptyID, aFullID); + return (Item) Class.forName("gregtechmod.api.items.GT_EnergyStore_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aCharge, + aTransfer, + aTier, + aEmptyID, + aFullID); } catch (Throwable e) { /* Do nothing */ } @@ -523,8 +540,12 @@ public class GregTech_API { public static GT_Tool_Item constructHardHammerItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage) { try { - return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_HardHammer_Item").getConstructors()[0] - .newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage); + return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_HardHammer_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aMaxDamage, + aEntityDamage); } catch (Throwable e) { /* Do nothing */ } @@ -543,14 +564,22 @@ public class GregTech_API { public static GT_Tool_Item constructCrowbarItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage) { try { - return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_CrowbarRC_Item").getConstructors()[0] - .newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage); + return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_CrowbarRC_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aMaxDamage, + aEntityDamage); } catch (Throwable e) { /* Do nothing */ } try { - return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_Crowbar_Item").getConstructors()[0] - .newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage); + return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_Crowbar_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aMaxDamage, + aEntityDamage); } catch (Throwable e) { /* Do nothing */ } @@ -569,8 +598,13 @@ public class GregTech_API { public static GT_Tool_Item constructWrenchItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, int aDisChargedGTID) { try { - return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_Wrench_Item").getConstructors()[0] - .newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID); + return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_Wrench_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aMaxDamage, + aEntityDamage, + aDisChargedGTID); } catch (Throwable e) { /* Do nothing */ } @@ -589,8 +623,13 @@ public class GregTech_API { public static GT_Tool_Item constructElectricScrewdriverItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, int aDisChargedGTID) { try { - return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_ScrewdriverIC_Item").getConstructors()[0] - .newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID); + return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_ScrewdriverIC_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aMaxDamage, + aEntityDamage, + aDisChargedGTID); } catch (Throwable e) { /* Do nothing */ } @@ -609,8 +648,13 @@ public class GregTech_API { public static GT_Tool_Item constructElectricWrenchItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, int aDisChargedGTID) { try { - return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_WrenchIC_Item").getConstructors()[0] - .newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID); + return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_WrenchIC_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aMaxDamage, + aEntityDamage, + aDisChargedGTID); } catch (Throwable e) { /* Do nothing */ } @@ -630,15 +674,16 @@ public class GregTech_API { int aEntityDamage, int aToolQuality, float aToolStrength, int aEnergyConsumptionPerBlockBreak, int aDisChargedGTID) { try { - return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_SawIC_Item").getConstructors()[0].newInstance( - aUnlocalized, - aEnglish, - aMaxDamage, - aEntityDamage, - aToolQuality, - aToolStrength, - aEnergyConsumptionPerBlockBreak, - aDisChargedGTID); + return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_SawIC_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aMaxDamage, + aEntityDamage, + aToolQuality, + aToolStrength, + aEnergyConsumptionPerBlockBreak, + aDisChargedGTID); } catch (Throwable e) { /* Do nothing */ } @@ -658,16 +703,16 @@ public class GregTech_API { int aEntityDamage, int aToolQuality, float aToolStrength, int aEnergyConsumptionPerBlockBreak, int aDisChargedGTID) { try { - return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_DrillIC_Item").getConstructors()[0] - .newInstance( - aUnlocalized, - aEnglish, - aMaxDamage, - aEntityDamage, - aToolQuality, - aToolStrength, - aEnergyConsumptionPerBlockBreak, - aDisChargedGTID); + return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_DrillIC_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aMaxDamage, + aEntityDamage, + aToolQuality, + aToolStrength, + aEnergyConsumptionPerBlockBreak, + aDisChargedGTID); } catch (Throwable e) { /* Do nothing */ } @@ -686,8 +731,13 @@ public class GregTech_API { public static GT_Tool_Item constructElectricSolderingToolItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, int aDisChargedGTID) { try { - return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_SolderingToolIC_Item").getConstructors()[0] - .newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID); + return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_SolderingToolIC_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aMaxDamage, + aEntityDamage, + aDisChargedGTID); } catch (Throwable e) { /* Do nothing */ } @@ -706,8 +756,12 @@ public class GregTech_API { public static GT_Tool_Item constructEmptyElectricToolItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aChargedGTID) { try { - return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_EmptyToolIC_Item").getConstructors()[0] - .newInstance(aUnlocalized, aEnglish, aMaxDamage, aChargedGTID); + return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_EmptyToolIC_Item") + .getConstructors()[0].newInstance( + aUnlocalized, + aEnglish, + aMaxDamage, + aChargedGTID); } catch (Throwable e) { /* Do nothing */ } @@ -763,8 +817,10 @@ public class GregTech_API { sRealConfigurationList.put(minTier, stack); for (Map.Entry<Integer, List<ItemStack>> e : sConfigurationLists.entrySet()) { if (e.getKey() >= minTier) { - e.getValue().add(stack); - e.getValue().sort(getConfigurationCircuitsComparator()); + e.getValue() + .add(stack); + e.getValue() + .sort(getConfigurationCircuitsComparator()); } } } @@ -780,9 +836,12 @@ public class GregTech_API { return Collections.unmodifiableList( sConfigurationLists.computeIfAbsent( machineTier, - (t) -> sRealConfigurationList.entries().stream().filter(e -> e.getKey() <= machineTier) - .map(Map.Entry::getValue).sorted(getConfigurationCircuitsComparator()) - .collect(Collectors.toList()))); + (t) -> sRealConfigurationList.entries() + .stream() + .filter(e -> e.getKey() <= machineTier) + .map(Map.Entry::getValue) + .sorted(getConfigurationCircuitsComparator()) + .collect(Collectors.toList()))); } public static Comparator<ItemStack> getConfigurationCircuitsComparator() { @@ -794,7 +853,9 @@ public class GregTech_API { return GT_Mod.gregtechproxy.mCircuitsOrder.getOrDefault( String.valueOf(GameRegistry.findUniqueIdentifierFor(is.getItem())), Integer.MAX_VALUE); - }).thenComparing(ItemStack::getUnlocalizedName).thenComparing(ItemStack::getItemDamage); + }) + .thenComparing(ItemStack::getUnlocalizedName) + .thenComparing(ItemStack::getItemDamage); } public static void registerCircuitProgrammer(ItemStack stack, boolean ignoreNBT, boolean useContainer) { @@ -802,8 +863,11 @@ public class GregTech_API { } public static void registerCircuitProgrammer(Predicate<ItemStack> predicate, boolean useContainer) { - sRealCircuitProgrammerList - .put(predicate, useContainer ? (s, p) -> s.getItem().getContainerItem(s) : (s, p) -> s); + sRealCircuitProgrammerList.put( + predicate, + useContainer ? (s, p) -> s.getItem() + .getContainerItem(s) + : (s, p) -> s); } public static void registerCircuitProgrammer(Predicate<ItemStack> predicate, @@ -994,7 +1058,9 @@ public class GregTech_API { */ public static boolean registerTool(ItemStack aTool, Collection<GT_ItemStack> aToolList) { if (aTool == null || GT_Utility.isStackInList(aTool, sToolList) - || (!aTool.getItem().isDamageable() && !GT_ModHandler.isElectricItem(aTool) + || (!aTool.getItem() + .isDamageable() + && !GT_ModHandler.isElectricItem(aTool) && !(aTool.getItem() instanceof IDamagableItem))) return false; aToolList.add(new GT_ItemStack(GT_Utility.copyAmount(1, aTool))); |