diff options
author | jani270 <69345714+jani270@users.noreply.github.com> | 2023-12-26 10:26:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-26 10:26:52 +0100 |
commit | 72f31f374f22736356d639775e48a2567babb288 (patch) | |
tree | 8840f92d5b419200cb4a99508d6a2ba2e293db65 /src/main | |
parent | 1d6937db0cfbf5db5a22b298615550dd41cf7ae6 (diff) | |
download | NotEnoughUpdates-72f31f374f22736356d639775e48a2567babb288.tar.gz NotEnoughUpdates-72f31f374f22736356d639775e48a2567babb288.tar.bz2 NotEnoughUpdates-72f31f374f22736356d639775e48a2567babb288.zip |
Reformated code in Crystal and Dwarven Overlay (#977)
Co-authored-by: hannibal2 <24389977+hannibal002@users.noreply.github.com>
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java | 124 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java | 184 |
2 files changed, 73 insertions, 235 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java index 1bc08744..7e7c4020 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java @@ -24,6 +24,7 @@ import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; import io.github.moulberry.notenoughupdates.options.NEUConfig; +import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -43,6 +44,8 @@ import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static io.github.moulberry.notenoughupdates.util.Utils.showOutdatedRepoNotification; + public class CrystalHollowOverlay extends TextOverlay { private static final Minecraft mc = Minecraft.getMinecraft(); private final StorageManager storageManager = StorageManager.getInstance(); @@ -500,98 +503,35 @@ public class CrystalHollowOverlay extends TextOverlay { private static Map<String, ItemStack> crystallHollowsIcons; private static void setupCrystallHollowsIcons() { - crystallHollowsIcons = new HashMap<String, ItemStack>() {{ - put( - "Scavenged Lapis Sword", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("DWARVEN_LAPIS_SWORD")) - ); - put( - "Scavenged Golden Hammer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("DWARVEN_GOLD_HAMMER")) - ); - put( - "Scavenged Diamond Axe", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("DWARVEN_DIAMOND_AXE")) - ); - put( - "Scavenged Emerald Hammer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("DWARVEN_EMERALD_HAMMER")) - ); - put( - "Electron Transmitter", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("ELECTRON_TRANSMITTER")) - ); - put( - "FTX 3070", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("FTX_3070")) - ); - put( - "Robotron Reflector", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("ROBOTRON_REFLECTOR")) - ); - put( - "Superlite Motor", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("SUPERLITE_MOTOR")) - ); - put( - "Control Switch", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("CONTROL_SWITCH")) - ); - put( - "Synthetic Heart", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("SYNTHETIC_HEART")) - ); - put( - "Amber", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("PERFECT_AMBER_GEM")) - ); - put( - "Sapphire", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("PERFECT_SAPPHIRE_GEM")) - ); - put( - "Jade", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("PERFECT_JADE_GEM")) - ); - put( - "Amethyst", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("PERFECT_AMETHYST_GEM")) - ); - put( - "Topaz", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("PERFECT_TOPAZ_GEM")) - ); - }}; + crystallHollowsIcons = new HashMap<String, ItemStack>() { + { + addItem("Scavenged Lapis Sword", "DWARVEN_LAPIS_SWORD"); + addItem("Scavenged Golden Hammer", "DWARVEN_GOLD_HAMMER"); + addItem("Scavenged Diamond Axe", "DWARVEN_DIAMOND_AXE"); + addItem("Scavenged Emerald Hammer", "DWARVEN_EMERALD_HAMMER"); + addItem("Electron Transmitter", "ELECTRON_TRANSMITTER"); + addItem("FTX 3070", "FTX_3070"); + addItem("Robotron Reflector", "ROBOTRON_REFLECTOR"); + addItem("Superlite Motor", "SUPERLITE_MOTOR"); + addItem("Control Switch", "CONTROL_SWITCH"); + addItem("Synthetic Heart", "SYNTHETIC_HEART"); + addItem("Amber", "PERFECT_AMBER_GEM"); + addItem("Sapphire", "PERFECT_SAPPHIRE_GEM"); + addItem("Jade", "PERFECT_JADE_GEM"); + addItem("Amethyst", "PERFECT_AMETHYST_GEM"); + addItem("Topaz", "PERFECT_TOPAZ_GEM"); + } + + private void addItem(String eventName, String internalName) { + ItemStack itemStack = new ItemResolutionQuery(NotEnoughUpdates.INSTANCE.manager) + .withKnownInternalName(internalName).resolveToItemStack(); + if (itemStack == null) { + showOutdatedRepoNotification(internalName); + return; + } + put(eventName, itemStack.copy()); + } + }; } @Override diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index f479276a..a8376974 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -27,6 +27,7 @@ import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; import io.github.moulberry.notenoughupdates.guifeatures.SkyMallDisplay; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; import io.github.moulberry.notenoughupdates.options.NEUConfig; +import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.StarCultCalculator; import io.github.moulberry.notenoughupdates.util.TabListUtils; @@ -34,7 +35,6 @@ import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.init.Items; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -50,6 +50,7 @@ import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static io.github.moulberry.notenoughupdates.util.Utils.showOutdatedRepoNotification; import static net.minecraft.util.EnumChatFormatting.BLUE; import static net.minecraft.util.EnumChatFormatting.BOLD; import static net.minecraft.util.EnumChatFormatting.DARK_AQUA; @@ -803,147 +804,44 @@ public class MiningOverlay extends TextTabOverlay { private static HashMap<String, ItemStack> miningOverlayCommissionItems; private static void setupMiningOverlayCommissionItems() { - miningOverlayCommissionItems = new HashMap<String, ItemStack>() {{ - put( - "Mithril Powder", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("INK_SACK-10")) - ); - put( - "Gemstone Powder", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("INK_SACK-9")) - ); - put( - "Lucky Raffle", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("MINING_RAFFLE_TICKET")) - ); - put( - "Raffle", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("MINING_RAFFLE_TICKET")) - ); - put( - "Pickaxe CD", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("DIAMOND_PICKAXE")) - ); - put( - "Star Cult", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("FALLEN_STAR_HAT")) - ); - put( - "Thyst Slayer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("THYST_MONSTER")) - ); - put( - "Hard Stone Miner", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("HARD_STONE")) - ); - put( - "Ice Walker Slayer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("ENCHANTED_ICE")) - ); - put( - "Goblin Slayer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("GOBLIN_MONSTER")) - ); - put( - "Star Sentry Puncher", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("NETHER_STAR")) - ); - put( - "Goblin Raid", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("ENCHANTED_GOLD")) - ); - put( - "Goblin Raid Slayer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("ENCHANTED_GOLD")) - ); - put("Golden Goblin Slayer", new ItemStack(Items.golden_helmet, 1, 0)); - put( - "2x Mithril Powder Collector", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("ENCHANTED_GLOWSTONE_DUST")) - ); - put( - "Automaton Slayer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("AUTOMATON_MONSTER")) - ); - put( - "Sludge Slayer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("SLUDGE_MONSTER")) - ); - put( - "Team Treasurite Member Slayer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("EXECUTIVE_WENDY_MONSTER")) - ); - put( - "Yog Slayer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("YOG_MONSTER")) - ); - put( - "Boss Corleone Slayer", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("BOSS_CORLEONE_BOSS")) - ); - put( - "Chest Looter", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("CHEST")) - ); - put( - "Titanium", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("TITANIUM_ORE")) - ); - put( - "Mithril", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("MITHRIL_ORE")) - ); - put( - "Forge", - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("ANVIL")) - ); - put("First Event", new ItemStack(Items.fireworks, 1, 0)); - }}; + miningOverlayCommissionItems = new HashMap<String, ItemStack>() { + { + addItem("Mithril Powder", "INK_SACK-10"); + addItem("Gemstone Powder", "INK_SACK-9"); + addItem("Lucky Raffle", "MINING_RAFFLE_TICKET"); + addItem("Raffle", "MINING_RAFFLE_TICKET"); + addItem("Pickaxe CD", "DIAMOND_PICKAXE"); + addItem("Star Cult", "FALLEN_STAR_HAT"); + addItem("Thyst Slayer", "THYST_MONSTER"); + addItem("Hard Stone Miner", "HARD_STONE"); + addItem("Ice Walker Slayer", "ENCHANTED_ICE"); + addItem("Goblin Slayer", "GOBLIN_MONSTER"); + addItem("Star Sentry Puncher", "NETHER_STAR"); + addItem("Goblin Raid", "ENCHANTED_GOLD"); + addItem("Goblin Raid Slayer", "ENCHANTED_GOLD"); + addItem("Golden Goblin Slayer", "GOLD_HELMET"); + addItem("2x Mithril Powder Collector", "ENCHANTED_GLOWSTONE_DUST"); + addItem("Automaton Slayer", "AUTOMATON_MONSTER"); + addItem("Sludge Slayer", "SLUDGE_MONSTER"); + addItem("Team Treasurite Member Slayer", "EXECUTIVE_WENDY_MONSTER"); + addItem("Yog Slayer", "YOG_MONSTER"); + addItem("Boss Corleone Slayer", "BOSS_CORLEONE_BOSS"); + addItem("Chest Looter", "CHEST"); + addItem("Titanium", "TITANIUM_ORE"); + addItem("Mithril", "MITHRIL_ORE"); + addItem("Forge", "ANVIL"); + addItem("First Event", "FIREWORK"); + } + + private void addItem(String eventName, String internalName) { + ItemStack itemStack = new ItemResolutionQuery(NotEnoughUpdates.INSTANCE.manager) + .withKnownInternalName(internalName).resolveToItemStack(); + if (itemStack == null) { + showOutdatedRepoNotification(internalName); + return; + } + put(eventName, itemStack.copy()); + } + }; } } |