diff options
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java')
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java index bf38d49..fb1bd13 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java @@ -1,19 +1,13 @@ package com.thatgravyboat.skyblockhud.handlers; -import static com.thatgravyboat.skyblockhud.GuiTextures.mapOverlay; - import com.thatgravyboat.skyblockhud.SkyblockHud; -import com.thatgravyboat.skyblockhud.Utils; import com.thatgravyboat.skyblockhud.config.KeyBindings; import com.thatgravyboat.skyblockhud.config.SBHConfig; import com.thatgravyboat.skyblockhud.core.config.Position; import com.thatgravyboat.skyblockhud.handlers.mapicons.DwarvenIcons; import com.thatgravyboat.skyblockhud.handlers.mapicons.HubIcons; import com.thatgravyboat.skyblockhud.location.LocationHandler; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import javax.vecmath.Vector2f; +import com.thatgravyboat.skyblockhud.utils.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; @@ -26,6 +20,13 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.opengl.GL11; +import javax.vecmath.Vector2f; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static com.thatgravyboat.skyblockhud.GuiTextures.mapOverlay; + public class MapHandler { public enum MapIconTypes { @@ -56,9 +57,13 @@ public class MapHandler { this.command = command; } - public boolean canRender() { + public boolean cantRender() { SBHConfig.Map mapConfig = SkyblockHud.config.map; - if (mapConfig.showInfoIcons && type.equals(MapIconTypes.INFO)) return true; else if (mapConfig.showMiscIcons && type.equals(MapIconTypes.MISC)) return true; else if (mapConfig.showNpcIcons && type.equals(MapIconTypes.NPC)) return true; else if (mapConfig.showQuestIcons && type.equals(MapIconTypes.QUEST)) return true; else return (mapConfig.showShopIcons && type.equals(MapIconTypes.SHOPS)); + if (mapConfig.showInfoIcons && type.equals(MapIconTypes.INFO)) return false; + else if (mapConfig.showMiscIcons && type.equals(MapIconTypes.MISC)) return false; + else if (mapConfig.showNpcIcons && type.equals(MapIconTypes.NPC)) return false; + else if (mapConfig.showQuestIcons && type.equals(MapIconTypes.QUEST)) return false; + else return (!mapConfig.showShopIcons || !type.equals(MapIconTypes.SHOPS)); } } @@ -69,19 +74,20 @@ public class MapHandler { NETHER(0.5f, 257, 371, 436, 732, 433, 736, new ResourceLocation("skyblockhud", "maps/fort.png"), Collections.emptyList()), BARN(1.5f, 135, 130, -82, 320, -81, 318, new ResourceLocation("skyblockhud", "maps/barn.png"), Collections.emptyList()), DWARVEN(0.5f, 409, 461, 206, 160, 202, 166, new ResourceLocation("skyblockhud", "maps/dwarven.png"), DwarvenIcons.dwarvenIcons), + CRYSTAL(0.5f, 624, 624, -202, -215.7, -202, -212, new ResourceLocation("skyblockhud", "maps/crystal.png"), Collections.emptyList()), PARK(1f, 211, 230, 480, 133, 478, 134, new ResourceLocation("skyblockhud", "maps/park.png"), Collections.emptyList()); public float scaleFactor; public int width; public int height; - public int xMiniOffset; - public int yMiniOffset; - public int xOffset; - public int yOffset; + public double xMiniOffset; + public double yMiniOffset; + public double xOffset; + public double yOffset; public ResourceLocation mapTexture; public List<MapIcon> icons; - Maps(float scaleFactor, int width, int height, int xMiniOffset, int yMiniOffset, int xOffset, int yOffset, ResourceLocation mapTexture, List<MapIcon> icons) { + Maps(float scaleFactor, int width, int height, double xMiniOffset, double yMiniOffset, double xOffset, double yOffset, ResourceLocation mapTexture, List<MapIcon> icons) { this.scaleFactor = scaleFactor; this.width = width; this.height = height; @@ -108,10 +114,10 @@ public class MapHandler { Gui.drawModalRectWithCustomSizedTexture(pos.getAbsX(event.resolution, 72), pos.getAbsY(event.resolution, 72), 72, 0, 72, 72, 256, 256); mc.renderEngine.bindTexture(map.mapTexture); - int x = mc.thePlayer.getPosition().getX() + map.xMiniOffset; - int z = mc.thePlayer.getPosition().getZ() + map.yMiniOffset; - float u = (x / (map.width / 256f)) - 33f; - float v = (z / (map.height / 256f)) - 28f; + double x = mc.thePlayer.getPosition().getX() + map.xMiniOffset; + double z = mc.thePlayer.getPosition().getZ() + map.yMiniOffset; + float u = (float) ((x / (map.width / 256f)) - 33f); + float v = (float) ((z / (map.height / 256f)) - 28f); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); @@ -154,8 +160,8 @@ public class MapHandler { Gui.drawModalRectWithCustomSizedTexture((int) mapX, (int) mapY, 0, 0, (int) (map.width * map.scaleFactor), (int) (map.height * map.scaleFactor), (int) (map.width * map.scaleFactor), (int) (map.height * map.scaleFactor)); drawIcons((int) mapX, (int) mapY); if (this.mc.thePlayer != null && SkyblockHud.config.map.showPlayerLocation) { - int x = this.mc.thePlayer.getPosition().getX() + map.xOffset; - int z = this.mc.thePlayer.getPosition().getZ() + map.yOffset; + double x = this.mc.thePlayer.getPosition().getX() + map.xOffset; + double z = this.mc.thePlayer.getPosition().getZ() + map.yOffset; fontRendererObj.drawString("\u2022", (int) (x * map.scaleFactor + mapX), (int) (z * map.scaleFactor + mapY), 0xff0000); } GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); @@ -165,12 +171,12 @@ public class MapHandler { public void drawIcons(int startX, int startY) { if (map.icons == null) return; for (MapIcon icon : map.icons) { - if (!icon.canRender()) continue; + if (icon.cantRender()) continue; GlStateManager.enableBlend(); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); this.mc.renderEngine.bindTexture(icon.icon); - float x = ((icon.position.x + map.xOffset) * map.scaleFactor) + startX - 4; - float y = ((icon.position.y + map.yOffset) * map.scaleFactor) + startY - 4; + double x = ((icon.position.x + map.xOffset) * map.scaleFactor) + startX - 4; + double y = ((icon.position.y + map.yOffset) * map.scaleFactor) + startY - 4; Gui.drawModalRectWithCustomSizedTexture((int) x, (int) y, 0, 0, 8, 8, 8, 8); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); } @@ -179,7 +185,7 @@ public class MapHandler { public void onTooltip(int mouseX, int mouseY, int startX, int startY) { if (map.icons == null) return; for (MapIcon icon : map.icons) { - if (!icon.canRender()) continue; + if (icon.cantRender()) continue; if (Utils.inRangeInclusive(mouseX, (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + startX - 4, (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + startX + 4) && Utils.inRangeInclusive(mouseY, (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + startY - 4, (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + startY + 4)) { drawHoveringText(Arrays.asList(icon.tooltip.split("\n")), mouseX, mouseY); break; @@ -192,7 +198,7 @@ public class MapHandler { int mapX = (int) ((width / 2f) - ((map.width / 2f) * map.scaleFactor)); int mapY = (int) ((height / 2f) - ((map.height / 2f) * map.scaleFactor)); for (MapIcon icon : map.icons) { - if (!icon.canRender()) continue; + if (icon.cantRender()) continue; if (Utils.inRangeInclusive(mouseX, (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + mapX - 4, (int) ((icon.position.x + map.xOffset) * map.scaleFactor) + mapX + 4) && Utils.inRangeInclusive(mouseY, (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + mapY - 4, (int) ((icon.position.y + map.yOffset) * map.scaleFactor) + mapY + 4)) { if (!icon.command.isEmpty()) { this.mc.thePlayer.sendChatMessage("/" + icon.command); |