diff options
author | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-17 01:26:21 -0230 |
---|---|---|
committer | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-17 01:26:21 -0230 |
commit | e364de18cbcbc9f334d890703812876789374bab (patch) | |
tree | d9360da1aaba43d88a2637ac73d9a15bd374886a /src | |
parent | 3f3a68b898930c9c33ff852e6d0d8270835c4b98 (diff) | |
download | SkyblockHud-Death-Defied-e364de18cbcbc9f334d890703812876789374bab.tar.gz SkyblockHud-Death-Defied-e364de18cbcbc9f334d890703812876789374bab.tar.bz2 SkyblockHud-Death-Defied-e364de18cbcbc9f334d890703812876789374bab.zip |
Added the ability to turn off the map for certain locations and added the ability for texture pack devs to add textures for npc dialogue
Diffstat (limited to 'src')
6 files changed, 77 insertions, 15 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java index 95a9499..07b7bfc 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java @@ -19,6 +19,7 @@ public class GuiTextures { public static final ResourceLocation TWO = new ResourceLocation("skyblockhud:core/toggle_2.png"); public static final ResourceLocation THREE = new ResourceLocation("skyblockhud:core/toggle_3.png"); public static final ResourceLocation ON = new ResourceLocation("skyblockhud:core/toggle_on.png"); + public static final ResourceLocation DELETE = new ResourceLocation("skyblockhud:core/delete.png"); public static final ResourceLocation slider_off_cap = new ResourceLocation("skyblockhud:core/slider/slider_off_cap.png"); public static final ResourceLocation slider_off_notch = new ResourceLocation("skyblockhud:core/slider/slider_off_notch.png"); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java index ab957a0..763e5fc 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java @@ -27,6 +27,7 @@ import java.nio.charset.StandardCharsets; import java.util.Set; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.Scoreboard; import net.minecraftforge.client.event.ClientChatReceivedEvent; @@ -87,6 +88,8 @@ public class SkyblockHud { MinecraftForge.EVENT_BUS.register(new FarmHouseHandler()); Commands.init(); + ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new NpcDialogue()); + configFile = new File(event.getModConfigurationDirectory(), "sbh-config.json"); if (configFile.exists()) { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java index 3f0f452..27236f4 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java @@ -7,6 +7,9 @@ import com.thatgravyboat.skyblockhud.core.config.Config; import com.thatgravyboat.skyblockhud.core.config.Position; import com.thatgravyboat.skyblockhud.core.config.annotations.*; import com.thatgravyboat.skyblockhud.core.config.gui.GuiPositionEditor; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import net.minecraft.client.Minecraft; public class SBHConfig extends Config { @@ -297,6 +300,25 @@ public class SBHConfig extends Config { public boolean showMiniMap = false; @Expose + @ConfigOption(name = "Map Locations", desc = "Remove a location from this list if you would like the map to not show up in that location. This is so you can use other mods maps.") + @ConfigEditorDraggableList(exampleText = { + "HUB", + "BARN", + "MUSHROOMDESERT", + "GOLDMINE (No Map Yet)", + "DEEPCAVERNS (No Map Yet)", + "SPIDERSDEN", + "PARK", + "FORTRESS", + "DUNGEONHUB (No Map Yet)", + "JERRY (No Map Yet)", + "THEEND (No Map Yet)", + "DWARVENMINES", + "CRYSTALHOLLOWS (No Map Yet)" + }) + public List<Integer> mapLocations = new ArrayList<>(Arrays.asList(0, 1, 2, 5, 6, 7, 11)); + + @Expose @ConfigOption(name = "Mini-Map Position", desc = "Allows you to change the position of the Mini-Map.") @ConfigEditorButton(runnableId = "map", buttonText = "Edit") public Position miniMapPosition = new Position(0, 100, false, false); diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java index 16df6c2..36c0ec3 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java @@ -1,7 +1,5 @@ package com.thatgravyboat.skyblockhud.core.config.gui; -import static com.thatgravyboat.skyblockhud.GuiTextures.*; - import com.thatgravyboat.skyblockhud.Utils; import com.thatgravyboat.skyblockhud.core.config.struct.ConfigProcessor; import com.thatgravyboat.skyblockhud.core.util.lerp.LerpUtils; @@ -15,13 +13,13 @@ import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -public class GuiOptionEditorDraggableList extends GuiOptionEditor { +import static com.thatgravyboat.skyblockhud.GuiTextures.DELETE; +import static com.thatgravyboat.skyblockhud.GuiTextures.button_tex; - private static final ResourceLocation DELETE = new ResourceLocation("notenoughupdates:core/delete.png"); +public class GuiOptionEditorDraggableList extends GuiOptionEditor { private String[] exampleText; private List<Integer> activeText; diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java index ab4afbc..1db9d1a 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java @@ -1,28 +1,39 @@ package com.thatgravyboat.skyblockhud.handlers; -import static com.thatgravyboat.skyblockhud.GuiTextures.dialogue; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.Utils; -import java.util.ArrayDeque; -import java.util.List; -import java.util.Locale; -import java.util.Queue; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -public class NpcDialogue { +import static com.thatgravyboat.skyblockhud.GuiTextures.dialogue; + +public class NpcDialogue implements IResourceManagerReloadListener { public static final Pattern NPC_DIALOGUE_REGEX = Pattern.compile("\\[NPC] (.*): (.*)"); + private static final Gson gson = new GsonBuilder().create(); + private static final Map<String, ResourceLocation> NPCS = new HashMap<>(); + private static boolean showDialogue = false; private static int ticks = 0; @@ -77,6 +88,13 @@ public class NpcDialogue { Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 0, 182, 68, 256, 256); + String npcID = currentNpc.toLowerCase(Locale.ENGLISH).replace(" ", "_"); + + if (NPCS.containsKey(npcID)){ + mc.renderEngine.bindTexture(NPCS.get(npcID)); + Gui.drawModalRectWithCustomSizedTexture(x + 4, y + 4, 0, 0, 32, 60, 128, 128); + } + FontRenderer font = mc.fontRendererObj; font.drawString(currentNpc, x + 40, y + 10, 0xffffff); @@ -88,4 +106,22 @@ public class NpcDialogue { } } } + + @Override + public void onResourceManagerReload(IResourceManager resourceManager) { + NPCS.clear(); + try { + ResourceLocation trackers = new ResourceLocation("skyblockhud:data/npc_textures.json"); + InputStream is = resourceManager.getResource(trackers).getInputStream(); + + try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { + for (JsonElement npc : gson.fromJson(reader, JsonObject.class).getAsJsonArray("npcs")) { + JsonObject npcObject = npc.getAsJsonObject(); + String npcName = npcObject.get("name").getAsString(); + ResourceLocation rl = new ResourceLocation(npcObject.get("texture").getAsString()); + NPCS.put(npcName.toLowerCase(Locale.ENGLISH).replace(" ", "_"), rl); + } + } + } catch (Exception ignored) {} + } } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java index cf93295..65256ac 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java @@ -1,9 +1,10 @@ package com.thatgravyboat.skyblockhud.location; -import static com.thatgravyboat.skyblockhud.handlers.MapHandler.Maps; - +import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.handlers.MapHandler; +import static com.thatgravyboat.skyblockhud.handlers.MapHandler.Maps; + public enum LocationCategory { ERROR("error", 34), ISLAND("island", 43), @@ -44,7 +45,8 @@ public enum LocationCategory { } public MapHandler.Maps getMap() { - return this.map; + if (this.map != null && SkyblockHud.config.map.mapLocations.contains(this.ordinal() - 2)) return this.map; + else return null; } public boolean isMiningCategory() { |