diff options
author | bowser0000 <bowser0000@gmail.com> | 2021-07-17 00:00:25 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2021-07-17 00:00:25 -0400 |
commit | 37977ec66605e240533180ebacf4377fc3a55a15 (patch) | |
tree | 69fa5678fb448731cb962b0a2f384511a9b6a7ba /src/main | |
parent | 6eed0d48eeaa054392efe19dffaef691701c1356 (diff) | |
download | SkyblockMod-37977ec66605e240533180ebacf4377fc3a55a15.tar.gz SkyblockMod-37977ec66605e240533180ebacf4377fc3a55a15.tar.bz2 SkyblockMod-37977ec66605e240533180ebacf4377fc3a55a15.zip |
Show applied gemstones in item lore
Diffstat (limited to 'src/main')
6 files changed, 100 insertions, 3 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 9ee1d33..b85c608 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -64,7 +64,7 @@ import java.util.Map; @Mod(modid = DankersSkyblockMod.MODID, version = DankersSkyblockMod.VERSION, clientSideOnly = true) public class DankersSkyblockMod { public static final String MODID = "Danker's Skyblock Mod"; - public static final String VERSION = "1.8.7-beta3"; + public static final String VERSION = "1.8.7-beta4"; public static int titleTimer = -1; public static boolean showTitle = false; public static String titleText = ""; @@ -116,6 +116,7 @@ public class DankersSkyblockMod { MinecraftForge.EVENT_BUS.register(new EndOfFarmAlert()); MinecraftForge.EVENT_BUS.register(new ExpertiseLore()); MinecraftForge.EVENT_BUS.register(new FasterMaddoxCalling()); + MinecraftForge.EVENT_BUS.register(new GemstonesLore()); MinecraftForge.EVENT_BUS.register(new GiantHPDisplay()); MinecraftForge.EVENT_BUS.register(new GoldenEnchants()); MinecraftForge.EVENT_BUS.register(new GolemSpawningAlert()); @@ -156,6 +157,7 @@ public class DankersSkyblockMod { GoldenEnchants.init(); TriviaSolver.init(); CustomMusic.init(configDirectory); + GemstonesLore.init(); keyBindings[0] = new KeyBinding("Open Maddox Menu", Keyboard.KEY_M, "Danker's Skyblock Mod"); keyBindings[1] = new KeyBinding("Regular Ability", Keyboard.KEY_NUMPAD4, "Danker's Skyblock Mod"); diff --git a/src/main/java/me/Danker/commands/DankerGuiCommand.java b/src/main/java/me/Danker/commands/DankerGuiCommand.java index 4375d57..9561074 100644 --- a/src/main/java/me/Danker/commands/DankerGuiCommand.java +++ b/src/main/java/me/Danker/commands/DankerGuiCommand.java @@ -99,6 +99,7 @@ public class DankerGuiCommand extends CommandBase { debug.append("[hidepetcandy][").append(ToggleCommand.hidePetCandy).append("]\n"); debug.append("[customcolourednames][").append(ToggleCommand.customColouredNames).append("]\n"); debug.append("[endoffarmalert][").append(ToggleCommand.endOfFarmAlert).append("]\n"); + debug.append("[gemstonelore][").append(ToggleCommand.gemstoneLore).append("]\n"); debug.append("[dungeonbossmusic][").append(ToggleCommand.dungeonBossMusic).append("]\n"); debug.append("[bloodroommusic][").append(ToggleCommand.bloodRoomMusic).append("]\n"); debug.append("[dungeonmusic][").append(ToggleCommand.dungeonMusic).append("]\n"); diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 95c4d98..d52ee76 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -14,6 +14,7 @@ import net.minecraft.util.ChatComponentText; import java.util.List; public class ToggleCommand extends CommandBase implements ICommand { + // Some of these end with toggled and some don't, I don't want to go back and fix them all for consistency public static boolean gpartyToggled; public static boolean coordsToggled; public static boolean goldenToggled; @@ -39,6 +40,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean hidePetCandy; public static boolean customColouredNames; public static boolean endOfFarmAlert; + public static boolean gemstoneLore; // Chat Messages public static boolean sceptreMessages; public static boolean midasStaffMessages; @@ -100,7 +102,7 @@ public class ToggleCommand extends CommandBase implements ICommand { "startswithterminal/selectallterminal/clickinorderterminal/" + "ultrasequencer/chronomatron/superpairs/hidetooltipsinaddons/pickblock/" + "melodytooltips/highlightslayers/highlightarachne/highlightskeletonmasters/teammatesinradius/" + - "gianthp/hidepetcandy/customcolorednames/endoffarmalert/dungeonbossmusic/bloodroommusic/dungeonmusic/list>"; + "gianthp/hidepetcandy/customcolorednames/endoffarmalert/gemstonelore/dungeonbossmusic/bloodroommusic/dungeonmusic/list>"; } public static String usage(ICommandSender arg0) { @@ -129,7 +131,8 @@ public class ToggleCommand extends CommandBase implements ICommand { "ultrasequencer", "chronomatron", "superpairs", "hidetooltipsinaddons", "pickblock", "melodytooltips", "highlightslayers", "highlightskeletonmasters", "dungeonbossmusic", "bloodroommusic", "dungeonmusic", - "teammatesinradius", "gianthp", "hidepetcandy", "customcolorednames", "endoffarmalert", "list"); + "teammatesinradius", "gianthp", "hidepetcandy", "customcolorednames", "endoffarmalert", + "gemstonelore", "list"); } return null; } @@ -441,6 +444,11 @@ public class ToggleCommand extends CommandBase implements ICommand { ConfigHandler.writeBooleanConfig("toggles", "EndOfFarmAlert", endOfFarmAlert); player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "End of farm alert has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + endOfFarmAlert + DankersSkyblockMod.MAIN_COLOUR + ".")); break; + case "gemstonelore": + gemstoneLore = !gemstoneLore; + ConfigHandler.writeBooleanConfig("toggles", "GemstoneLore", gemstoneLore); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Gemstone in lore has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + gemstoneLore + DankersSkyblockMod.MAIN_COLOUR + ".")); + break; case "dungeonbossmusic": dungeonBossMusic = !dungeonBossMusic; CustomMusic.dungeonboss.stop(); @@ -511,6 +519,7 @@ public class ToggleCommand extends CommandBase implements ICommand { DankersSkyblockMod.TYPE_COLOUR + " Hide pet candy: " + DankersSkyblockMod.VALUE_COLOUR + hidePetCandy + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Custom name colors: " + DankersSkyblockMod.VALUE_COLOUR + customColouredNames + "\n" + DankersSkyblockMod.TYPE_COLOUR + " End of farm alert: " + DankersSkyblockMod.VALUE_COLOUR + endOfFarmAlert + "\n" + + DankersSkyblockMod.TYPE_COLOUR + " Gemstone in lore: " + DankersSkyblockMod.VALUE_COLOUR + gemstoneLore + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Custom dungeon boss music: " + DankersSkyblockMod.VALUE_COLOUR + dungeonBossMusic + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Custom blood room music: " + DankersSkyblockMod.VALUE_COLOUR + bloodRoomMusic + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Custom dungeon music: " + DankersSkyblockMod.VALUE_COLOUR + dungeonMusic diff --git a/src/main/java/me/Danker/features/GemstonesLore.java b/src/main/java/me/Danker/features/GemstonesLore.java new file mode 100644 index 0000000..dfae746 --- /dev/null +++ b/src/main/java/me/Danker/features/GemstonesLore.java @@ -0,0 +1,77 @@ +package me.Danker.features; + +import me.Danker.commands.ToggleCommand; +import me.Danker.utils.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class GemstonesLore { + + static Map<String, EnumChatFormatting> gemstoneColours = new HashMap<>(); + + public static void init() { + gemstoneColours.put("Amber", EnumChatFormatting.GOLD); + gemstoneColours.put("Sapphire", EnumChatFormatting.AQUA); + gemstoneColours.put("Jasper", EnumChatFormatting.LIGHT_PURPLE); + gemstoneColours.put("Amethyst", EnumChatFormatting.DARK_PURPLE); + gemstoneColours.put("Topaz", EnumChatFormatting.YELLOW); + gemstoneColours.put("Jade", EnumChatFormatting.GREEN); + gemstoneColours.put("Ruby", EnumChatFormatting.RED); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onTooltip(ItemTooltipEvent event) { + if (!Utils.inSkyblock) return; + if (event.toolTip == null) return; + + ItemStack item = event.itemStack; + if (ToggleCommand.gemstoneLore) { + if (item.hasTagCompound()) { + NBTTagCompound tags = item.getSubCompound("ExtraAttributes", false); + if (tags != null) { + if (tags.hasKey("gems")) { + NBTTagCompound gems = tags.getCompoundTag("gems"); + Set<String> set = gems.getKeySet(); + + if (set.size() == 0) return; + + int index = Minecraft.getMinecraft().gameSettings.advancedItemTooltips ? 4 : 2; + + event.toolTip.add(event.toolTip.size() - index, ""); + event.toolTip.add(event.toolTip.size() - index, "Gemstones Applied:"); + + for (String gem : set) { + char last = gem.charAt(gem.length() - 1); + if (!Character.isDigit(last)) continue; + + String gemstone = " " + Utils.capitalizeString(gems.getString(gem)) + " "; + if (gem.startsWith("UNIVERSAL_")) { + gemstone += Utils.capitalizeString(gems.getString(gem + "_gem")); + } else { + gemstone += Utils.capitalizeString(gem.substring(0, gem.indexOf("_"))); + } + + for (String colour : gemstoneColours.keySet()) { + if (gemstone.contains(colour)) { + gemstone = gemstoneColours.get(colour) + gemstone; + } + } + + event.toolTip.add(event.toolTip.size() - index, gemstone); + } + } + } + } + } + } + +} diff --git a/src/main/java/me/Danker/gui/DankerGui.java b/src/main/java/me/Danker/gui/DankerGui.java index 3f4ebe7..d7e2c16 100644 --- a/src/main/java/me/Danker/gui/DankerGui.java +++ b/src/main/java/me/Danker/gui/DankerGui.java @@ -68,6 +68,7 @@ public class DankerGui extends GuiScreen { private GuiButton hidePetCandy; private GuiButton customColouredNames; private GuiButton endOfFarmAlert; + private GuiButton gemstoneLore; // Chat Messages private GuiButton sceptreMessages; private GuiButton midasStaffMessages; @@ -157,6 +158,7 @@ public class DankerGui extends GuiScreen { hidePetCandy = new FeatureButton("Hide Pet Candy: " + Utils.getColouredBoolean(ToggleCommand.hidePetCandy), "Hide pet candy in pet tooltips."); customColouredNames = new FeatureButton("Custom Name Colors: " + Utils.getColouredBoolean(ToggleCommand.customColouredNames), "Replaces some player's usernames with a custom color."); endOfFarmAlert = new FeatureButton("Alert When Reaching End of Farm: " + Utils.getColouredBoolean(ToggleCommand.endOfFarmAlert), "Alerts when you go past coords set with /dsmfarmlength."); + gemstoneLore = new FeatureButton("Applied Gemstones in Lore: " + Utils.getColouredBoolean(ToggleCommand.gemstoneLore), "Adds applied gemstones to item tooltip."); allButtons.clear(); allButtons.add(changeDisplay); @@ -204,6 +206,7 @@ public class DankerGui extends GuiScreen { allButtons.add(hidePetCandy); allButtons.add(customColouredNames); allButtons.add(endOfFarmAlert); + allButtons.add(gemstoneLore); search.setText(initSearchText); search.setVisible(true); @@ -454,6 +457,10 @@ public class DankerGui extends GuiScreen { ToggleCommand.endOfFarmAlert = !ToggleCommand.endOfFarmAlert; ConfigHandler.writeBooleanConfig("toggles", "EndOfFarmAlert", ToggleCommand.endOfFarmAlert); endOfFarmAlert.displayString = "Alert When Reaching End of Farm: " + Utils.getColouredBoolean(ToggleCommand.endOfFarmAlert); + } else if (button == gemstoneLore) { + ToggleCommand.gemstoneLore = !ToggleCommand.gemstoneLore; + ConfigHandler.writeBooleanConfig("toggles", "GemstoneLore", ToggleCommand.gemstoneLore); + gemstoneLore.displayString = "Applied Gemstones in Lore: " + Utils.getColouredBoolean(ToggleCommand.gemstoneLore); } } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 29fa882..1d6311e 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -216,6 +216,7 @@ public class ConfigHandler { ToggleCommand.hidePetCandy = initBoolean("toggles", "HidePetCandy", false); ToggleCommand.customColouredNames = initBoolean("toggles", "CustomColouredNames", true); ToggleCommand.endOfFarmAlert = initBoolean("toggles", "EndOfFarmAlert", false); + ToggleCommand.gemstoneLore = initBoolean("toggles", "GemstoneLore", false); // Chat Messages ToggleCommand.sceptreMessages = initBoolean("toggles", "SceptreMessages", true); ToggleCommand.midasStaffMessages = initBoolean("toggles", "MidasStaffMessages", true); |