Skip to content

Commit fc4d857

Browse files
committed
fix optional dependency on AxolotlClient
1 parent 6994dd0 commit fc4d857

File tree

10 files changed

+110
-69
lines changed

10 files changed

+110
-69
lines changed

1.20/src/main/java/io/github/axolotlclient/waypoints/AxolotlClientWaypoints.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static Screen createOptionsScreen(Screen parent) {
115115
}
116116

117117
public static ResourceLocation rl(String path) {
118-
return (ResourceLocation) AxolotlClientWaypointsCommon.rl(path);
118+
return new ResourceLocation(AxolotlClientWaypointsCommon.MODID, path);
119119
}
120120

121121
public static Component tr(String key, Object... args) {

1.20/src/main/java/io/github/axolotlclient/waypoints/map/Minimap.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
package io.github.axolotlclient.waypoints.map;
2424

2525
import com.mojang.blaze3d.platform.NativeImage;
26-
import io.github.axolotlclient.AxolotlClientConfig.api.AxolotlClientConfig;
27-
import io.github.axolotlclient.AxolotlClientConfig.impl.managers.JsonConfigManager;
2826
import io.github.axolotlclient.bridge.render.AxoRenderContext;
29-
import io.github.axolotlclient.modules.hud.HudManager;
3027
import io.github.axolotlclient.waypoints.AxolotlClientWaypoints;
3128
import io.github.axolotlclient.waypoints.AxolotlClientWaypointsCommon;
29+
import io.github.axolotlclient.waypoints.HudCreator;
3230
import io.github.axolotlclient.waypoints.util.ARGB;
3331
import io.github.axolotlclient.waypoints.waypoints.Waypoint;
3432
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
@@ -70,18 +68,8 @@ public void init() {
7068
AxolotlClientWaypoints.category.add(Minimap.minimap);
7169
if (AxolotlClientWaypointsCommon.AXOLOTLCLIENT_PRESENT) {
7270
usingHud = true;
73-
var hud = new MinimapHudEntry(this);
74-
hud.setEnabled(true);
75-
var hudConfigManager = new JsonConfigManager(AxolotlClientWaypointsCommon.OPTIONS_PATH.resolveSibling(hud.getId().br$getPath() + ".json"), hud.getAllOptions());
76-
hudConfigManager.suppressName("x");
77-
hudConfigManager.suppressName("y");
78-
hudConfigManager.suppressName(minimapOutline.getName());
79-
hudConfigManager.suppressName(outlineColor.getName());
80-
AxolotlClientConfig.getInstance().register(hudConfigManager);
81-
hudConfigManager.load();
82-
ClientLifecycleEvents.CLIENT_STOPPING.register(mc -> hudConfigManager.save());
83-
minimap.add(hud.getAllOptions(), false);
84-
HudManager.getInstance().addNonConfigured(hud);
71+
var save = HudCreator.createHud(this);
72+
ClientLifecycleEvents.CLIENT_STOPPING.register(mc -> save.run());
8573
}
8674
}
8775

@@ -116,10 +104,13 @@ public void renderMapOverlay(GuiGraphics guiGraphics, float delta) {
116104
}
117105

118106
public void renderMap(AxoRenderContext ctx) {
107+
renderMap((GuiGraphics) ctx);
108+
}
109+
110+
public void renderMap(GuiGraphics guiGraphics) {
119111
if (!isEnabled()) {
120112
return;
121113
}
122-
var guiGraphics = (GuiGraphics) ctx;
123114
guiGraphics.pose().pushPose();
124115
{
125116
guiGraphics.enableScissor(x, y, x + size, y + size);

1.21.8/src/main/java/io/github/axolotlclient/waypoints/AxolotlClientWaypoints.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static Screen createOptionsScreen(Screen parent) {
105105
}
106106

107107
public static ResourceLocation rl(String path) {
108-
return (ResourceLocation) AxolotlClientWaypointsCommon.rl(path);
108+
return ResourceLocation.fromNamespaceAndPath(AxolotlClientWaypointsCommon.MODID, path);
109109
}
110110

111111
public static Component tr(String key, Object... args) {

1.21.8/src/main/java/io/github/axolotlclient/waypoints/map/Minimap.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
package io.github.axolotlclient.waypoints.map;
2424

2525
import com.mojang.blaze3d.platform.NativeImage;
26-
import io.github.axolotlclient.AxolotlClientConfig.api.AxolotlClientConfig;
27-
import io.github.axolotlclient.AxolotlClientConfig.impl.managers.JsonConfigManager;
2826
import io.github.axolotlclient.bridge.render.AxoRenderContext;
29-
import io.github.axolotlclient.modules.hud.HudManager;
3027
import io.github.axolotlclient.waypoints.AxolotlClientWaypoints;
3128
import io.github.axolotlclient.waypoints.AxolotlClientWaypointsCommon;
29+
import io.github.axolotlclient.waypoints.HudCreator;
3230
import io.github.axolotlclient.waypoints.util.ARGB;
3331
import io.github.axolotlclient.waypoints.waypoints.Waypoint;
3432
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
@@ -72,18 +70,8 @@ public void init() {
7270
AxolotlClientWaypoints.category.add(minimap);
7371
if (AxolotlClientWaypointsCommon.AXOLOTLCLIENT_PRESENT) {
7472
usingHud = true;
75-
var hud = new MinimapHudEntry(this);
76-
hud.setEnabled(true);
77-
var hudConfigManager = new JsonConfigManager(AxolotlClientWaypointsCommon.OPTIONS_PATH.resolveSibling(hud.getId().br$getPath() + ".json"), hud.getAllOptions());
78-
hudConfigManager.suppressName("x");
79-
hudConfigManager.suppressName("y");
80-
hudConfigManager.suppressName(minimapOutline.getName());
81-
hudConfigManager.suppressName(outlineColor.getName());
82-
AxolotlClientConfig.getInstance().register(hudConfigManager);
83-
hudConfigManager.load();
84-
ClientLifecycleEvents.CLIENT_STOPPING.register(mc -> hudConfigManager.save());
85-
minimap.add(hud.getAllOptions(), false);
86-
HudManager.getInstance().addNonConfigured(hud);
73+
var save = HudCreator.createHud(this);
74+
ClientLifecycleEvents.CLIENT_STOPPING.register(mc -> save.run());
8775
}
8876
}
8977

@@ -115,10 +103,13 @@ public void renderMapOverlay(GuiGraphics guiGraphics, DeltaTracker deltaTracker)
115103
}
116104

117105
public void renderMap(AxoRenderContext ctx) {
106+
renderMap((GuiGraphics) ctx);
107+
}
108+
109+
public void renderMap(GuiGraphics guiGraphics) {
118110
if (!isEnabled()) {
119111
return;
120112
}
121-
var guiGraphics = (GuiGraphics) ctx;
122113
guiGraphics.pose().pushMatrix();
123114
{
124115
guiGraphics.enableScissor(x, y, x + size, y + size);

1.21/src/main/java/io/github/axolotlclient/waypoints/AxolotlClientWaypoints.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static Screen createOptionsScreen(Screen parent) {
115115
}
116116

117117
public static ResourceLocation rl(String path) {
118-
return (ResourceLocation) AxolotlClientWaypointsCommon.rl(path);
118+
return ResourceLocation.fromNamespaceAndPath(AxolotlClientWaypointsCommon.MODID, path);
119119
}
120120

121121
public static Component tr(String key, Object... args) {

1.21/src/main/java/io/github/axolotlclient/waypoints/map/Minimap.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
package io.github.axolotlclient.waypoints.map;
2424

2525
import com.mojang.blaze3d.platform.NativeImage;
26-
import io.github.axolotlclient.AxolotlClientConfig.api.AxolotlClientConfig;
27-
import io.github.axolotlclient.AxolotlClientConfig.impl.managers.JsonConfigManager;
2826
import io.github.axolotlclient.bridge.render.AxoRenderContext;
29-
import io.github.axolotlclient.modules.hud.HudManager;
3027
import io.github.axolotlclient.waypoints.AxolotlClientWaypoints;
3128
import io.github.axolotlclient.waypoints.AxolotlClientWaypointsCommon;
29+
import io.github.axolotlclient.waypoints.HudCreator;
3230
import io.github.axolotlclient.waypoints.util.ARGB;
3331
import io.github.axolotlclient.waypoints.waypoints.Waypoint;
3432
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
@@ -72,18 +70,8 @@ public void init() {
7270
AxolotlClientWaypoints.category.add(Minimap.minimap);
7371
if (AxolotlClientWaypointsCommon.AXOLOTLCLIENT_PRESENT) {
7472
usingHud = true;
75-
var hud = new MinimapHudEntry(this);
76-
hud.setEnabled(true);
77-
var hudConfigManager = new JsonConfigManager(AxolotlClientWaypointsCommon.OPTIONS_PATH.resolveSibling(hud.getId().br$getPath() + ".json"), hud.getAllOptions());
78-
hudConfigManager.suppressName("x");
79-
hudConfigManager.suppressName("y");
80-
hudConfigManager.suppressName(minimapOutline.getName());
81-
hudConfigManager.suppressName(outlineColor.getName());
82-
AxolotlClientConfig.getInstance().register(hudConfigManager);
83-
hudConfigManager.load();
84-
ClientLifecycleEvents.CLIENT_STOPPING.register(mc -> hudConfigManager.save());
85-
minimap.add(hud.getAllOptions(), false);
86-
HudManager.getInstance().addNonConfigured(hud);
73+
var save = HudCreator.createHud(this);
74+
ClientLifecycleEvents.CLIENT_STOPPING.register(mc -> save.run());
8775
}
8876
}
8977

@@ -116,10 +104,13 @@ public void renderMapOverlay(GuiGraphics guiGraphics, DeltaTracker deltaTracker)
116104
}
117105

118106
public void renderMap(AxoRenderContext ctx) {
107+
renderMap((GuiGraphics) ctx);
108+
}
109+
110+
public void renderMap(GuiGraphics guiGraphics) {
119111
if (!isEnabled()) {
120112
return;
121113
}
122-
var guiGraphics = (GuiGraphics) ctx;
123114
guiGraphics.pose().pushPose();
124115
{
125116
guiGraphics.enableScissor(x, y, x + size, y + size);

1.8.9/src/main/java/io/github/axolotlclient/waypoints/AxolotlClientWaypoints.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public static Screen createOptionsScreen(Screen parent) {
114114
}
115115

116116
public static Identifier rl(String path) {
117-
return (Identifier) AxolotlClientWaypointsCommon.rl(path);
117+
return new Identifier(AxolotlClientWaypointsCommon.MODID, path);
118118
}
119119

120120
public static String tr(String key, Object... args) {

1.8.9/src/main/java/io/github/axolotlclient/waypoints/map/Minimap.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@
2323
package io.github.axolotlclient.waypoints.map;
2424

2525
import com.mojang.blaze3d.platform.GlStateManager;
26-
import io.github.axolotlclient.AxolotlClientConfig.api.AxolotlClientConfig;
27-
import io.github.axolotlclient.AxolotlClientConfig.impl.managers.JsonConfigManager;
2826
import io.github.axolotlclient.AxolotlClientConfig.impl.util.DrawUtil;
2927
import io.github.axolotlclient.bridge.render.AxoRenderContext;
30-
import io.github.axolotlclient.modules.hud.HudManager;
3128
import io.github.axolotlclient.waypoints.AxolotlClientWaypoints;
3229
import io.github.axolotlclient.waypoints.AxolotlClientWaypointsCommon;
30+
import io.github.axolotlclient.waypoints.HudCreator;
3331
import io.github.axolotlclient.waypoints.util.ARGB;
3432
import io.github.axolotlclient.waypoints.waypoints.Waypoint;
3533
import net.minecraft.block.Blocks;
@@ -67,18 +65,8 @@ public void init() {
6765
AxolotlClientWaypoints.category.add(Minimap.minimap);
6866
if (AxolotlClientWaypointsCommon.AXOLOTLCLIENT_PRESENT) {
6967
usingHud = true;
70-
var hud = new MinimapHudEntry(this);
71-
hud.setEnabled(true);
72-
var hudConfigManager = new JsonConfigManager(AxolotlClientWaypointsCommon.OPTIONS_PATH.resolveSibling(hud.getId().br$getPath() + ".json"), hud.getAllOptions());
73-
hudConfigManager.suppressName("x");
74-
hudConfigManager.suppressName("y");
75-
hudConfigManager.suppressName(minimapOutline.getName());
76-
hudConfigManager.suppressName(outlineColor.getName());
77-
AxolotlClientConfig.getInstance().register(hudConfigManager);
78-
hudConfigManager.load();
79-
MinecraftClientEvents.STOP.register(mc -> hudConfigManager.save());
80-
minimap.add(hud.getAllOptions(), false);
81-
HudManager.getInstance().addNonConfigured(hud);
68+
var save = HudCreator.createHud(this);
69+
MinecraftClientEvents.STOP.register(mc -> save.run());
8270
}
8371
}
8472

@@ -110,10 +98,14 @@ public void renderMapOverlay() {
11098
}
11199
this.y += 20;
112100
}*/
113-
renderMap(null);
101+
renderMap();
114102
}
115103

116104
public void renderMap(AxoRenderContext ctx) {
105+
renderMap();
106+
}
107+
108+
public void renderMap() {
117109
if (!isEnabled()) {
118110
return;
119111
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright © 2025 moehreag <moehreag@gmail.com> & Contributors
3+
*
4+
* This file is part of AxolotlClient (Waypoints Mod).
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*
20+
* For more information, see the LICENSE file.
21+
*/
22+
23+
package io.github.axolotlclient.waypoints;
24+
25+
import io.github.axolotlclient.AxolotlClientConfig.api.AxolotlClientConfig;
26+
import io.github.axolotlclient.AxolotlClientConfig.impl.managers.JsonConfigManager;
27+
import io.github.axolotlclient.bridge.events.Events;
28+
import io.github.axolotlclient.modules.hud.HudManagerCommon;
29+
import io.github.axolotlclient.waypoints.map.MinimapCommon;
30+
import io.github.axolotlclient.waypoints.map.MinimapHudEntry;
31+
32+
/*
33+
* Springboard class to not need to reference classes from
34+
* AxolotlClient directly. This allows this mod to not
35+
* have to explicitly depend on AxolotlClient but instead leave
36+
* this dependency optional.
37+
*/
38+
public class HudCreator {
39+
40+
public static Runnable createHud(MinimapCommon minimap) {
41+
var hud = new MinimapHudEntry(minimap);
42+
hud.setEnabled(true);
43+
var hudConfigManager = new JsonConfigManager(AxolotlClientWaypointsCommon.OPTIONS_PATH.resolveSibling(hud.getId().br$getPath() + ".json"), hud.getAllOptions());
44+
hudConfigManager.suppressName("x");
45+
hudConfigManager.suppressName("y");
46+
hudConfigManager.suppressName(minimap.minimapOutline.getName());
47+
hudConfigManager.suppressName(minimap.outlineColor.getName());
48+
AxolotlClientConfig.getInstance().register(hudConfigManager);
49+
hudConfigManager.load();
50+
MinimapCommon.minimap.add(hud.getAllOptions(), false);
51+
Events.CLIENT_READY.register(() -> HudManagerCommon.getInstance().addNonConfigured(hud));
52+
return hudConfigManager::save;
53+
}
54+
}

common/src/main/java/io/github/axolotlclient/waypoints/map/MinimapCommon.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright © 2025 moehreag <moehreag@gmail.com> & Contributors
3+
*
4+
* This file is part of AxolotlClient (Waypoints Mod).
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*
20+
* For more information, see the LICENSE file.
21+
*/
22+
123
package io.github.axolotlclient.waypoints.map;
224

325
import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory;
@@ -25,7 +47,7 @@ public abstract class MinimapCommon {
2547
protected final IntegerOption mapScale = new IntegerOption("map_scale", 1, 1, 5);
2648
protected final BooleanOption showWaypoints = new BooleanOption("show_waypoints", true);
2749
protected final BooleanOption showCardinalDirections = new BooleanOption("show_cardinal_directions", true);
28-
protected static final OptionCategory minimap = OptionCategory.create("minimap");
50+
public static final OptionCategory minimap = OptionCategory.create("minimap");
2951

3052
public abstract void renderMap(AxoRenderContext ctx);
3153

0 commit comments

Comments
 (0)