diff options
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock')
4 files changed, 32 insertions, 13 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java index 171f13ea..2a1ce63a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java @@ -11,6 +11,7 @@ import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallba import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -20,7 +21,7 @@ import java.util.Map; public class CrystalsHud { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); - private static final Identifier MAP_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/crystals_map.png"); + protected static final Identifier MAP_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/crystals_map.png"); private static final Identifier MAP_ICON = new Identifier("textures/map/map_icons.png"); private static final String[] SMALL_LOCATIONS = { "Fairy Grotto", "King", "Corleone" }; @@ -43,8 +44,9 @@ public class CrystalsHud { }); } - protected static IntIntPair getDimForConfig() { - return IntIntPair.of(62, 62); + protected static IntIntPair getDimensionsForConfig() { + int size = (int) (62 * SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.mapScaling); + return IntIntPair.of(size, size); } @@ -55,9 +57,20 @@ public class CrystalsHud { * @param hudX Top left X coordinate of the map * @param hudY Top left Y coordinate of the map */ - protected static void render(DrawContext context, int hudX, int hudY) { + private static void render(DrawContext context, int hudX, int hudY) { + float scale = SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.mapScaling; + int size = (int) (62 * scale); + + //make sure the map renders infront of some stuff - improve this in the future with better layering (1.20.5?) + MatrixStack matrices = context.getMatrices(); + matrices.push(); + matrices.translate(0f, 0f, 200f); + //draw map texture - context.drawTexture(MAP_TEXTURE, hudX, hudY, 0, 0, 62, 62, 62, 62); + context.drawTexture(MAP_TEXTURE, hudX, hudY, 0, 0, size, size, size, size); + + //scale the rest of the stuff - this isn't applied to the map texture because doing so causes it to render with an "offset" + matrices.scale(scale, scale, 0f); //if enabled add waypoint locations to map if (SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.showLocations) { @@ -89,7 +102,8 @@ public class CrystalsHud { //draw marker on map context.drawTexture(MAP_ICON, hudX + renderPos.first() - 2, hudY + renderPos.second() - 2, 58, 2, 4, 4, 128, 128); - //todo add direction and scale (can not work out how to rotate) + //todo add direction (can not work out how to rotate) + matrices.pop(); } /** diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudConfigScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudConfigScreen.java index e30d6390..b4e423e9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudConfigScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudConfigScreen.java @@ -28,14 +28,14 @@ public class CrystalsHudConfigScreen extends Screen { public void render(DrawContext context, int mouseX, int mouseY, float delta) { super.render(context, mouseX, mouseY, delta); renderBackground(context, mouseX, mouseY, delta); - CrystalsHud.render( context, hudX, hudY); + renderHUDMap(context, hudX, hudY); context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, height / 2, Color.GRAY.getRGB()); } @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { - IntIntPair dims = CrystalsHud.getDimForConfig(); - if (RenderHelper.pointIsInArea(mouseX, mouseY, hudX, hudY, hudX + 200, hudY + 40) && button == 0) { + IntIntPair dims = CrystalsHud.getDimensionsForConfig(); + if (RenderHelper.pointIsInArea(mouseX, mouseY, hudX, hudY, hudX + dims.leftInt(), hudY + dims.rightInt()) && button == 0) { hudX = (int) Math.max(Math.min(mouseX - (double) dims.leftInt() / 2, this.width - dims.leftInt()), 0); hudY = (int) Math.max(Math.min(mouseY - (double) dims.rightInt() / 2, this.height - dims.rightInt()), 0); } @@ -45,13 +45,19 @@ public class CrystalsHudConfigScreen extends Screen { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (button == 1) { - IntIntPair dims = CrystalsHud.getDimForConfig(); + IntIntPair dims = CrystalsHud.getDimensionsForConfig(); hudX = this.width / 2 - dims.leftInt(); hudY = this.height / 2 - dims.rightInt(); } return super.mouseClicked(mouseX, mouseY, button); } + private void renderHUDMap(DrawContext context, int x, int y) { + float scaling = SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.mapScaling; + int size = (int) (62 * scaling); + context.drawTexture(CrystalsHud.MAP_TEXTURE, x, y, 0, 0, size, size, size, size); + } + @Override public void close() { SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.x = hudX; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java index 5b196f8e..1cbbb32e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -169,7 +169,7 @@ public class CrystalsLocationsManager { private static void addCustomWaypoint( Text waypointName, BlockPos pos) { CrystalsWaypoint.Category category = WAYPOINT_LOCATIONS.get(waypointName.getString()); CrystalsWaypoint waypoint = new CrystalsWaypoint(category, waypointName, pos); - activeWaypoints.put(waypointName.getString(),waypoint); + activeWaypoints.put(waypointName.getString(), waypoint); } public static void render(WorldRenderContext context) { @@ -183,7 +183,7 @@ public class CrystalsLocationsManager { } private static void reset() { - activeWaypoints.clear(); + activeWaypoints.clear(); } public static void update() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java index ad85e763..423a8cbd 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java @@ -25,7 +25,6 @@ import java.util.function.ToDoubleFunction; public class CrystalsWaypoint extends Waypoint { private static final Logger LOGGER = LoggerFactory.getLogger(CrystalsWaypoint.class); - private static final Supplier<SkyblockerConfig.Waypoints> CONFIG = () -> SkyblockerConfigManager.get().general.waypoints; private static final Supplier<Type> TYPE_SUPPLIER = () -> CONFIG.get().waypointType; final Category category; |