Skip to content

Commit

Permalink
Merge pull request #181 from mysticdrew/update_jm_api
Browse files Browse the repository at this point in the history
Fixes journeymap support and adds groups.
  • Loading branch information
LordDeatHunter authored Oct 9, 2024
2 parents 4f1c2bf + 8fbc7a9 commit b789de4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ archives_base_name=wraith-waystones
fabric_version=0.100.4+1.21
# Optional Dependencies
# Journeymap & api
journeymap_api_version=2.0.0-1.21-SNAPSHOT
journeymap_api_version=2.0.0-1.21.1-SNAPSHOT
#jm_project_id=32274
#jm_file_id=5485233
rs_project_id=391366
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import journeymap.api.v2.client.option.BooleanOption;
import journeymap.api.v2.client.option.OptionCategory;
import journeymap.api.v2.common.event.ClientEventRegistry;
import journeymap.api.v2.common.event.FullscreenEventRegistry;
import journeymap.api.v2.common.waypoint.WaypointFactory;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -50,10 +51,10 @@ public void initialize(@NotNull IClientAPI api) {
this.api = api;

// event registration
ClientEventRegistry.OPTIONS_REGISTRY_EVENT_EVENT.subscribe(getModId(), event -> {
ClientEventRegistry.OPTIONS_REGISTRY_EVENT.subscribe(getModId(), event -> {
OptionCategory category = new OptionCategory(getModId(), "fwaystones.integration.journeymap.category");
this.enabled = new BooleanOption(category, "enabled", "fwaystones.integration.journeymap.enable", true);
this.displayWaypoints = new BooleanOption(category, "displayed", "fwaystones.integration.journeymap.enable", true);
this.displayWaypoints = new BooleanOption(category, "displayed", "fwaystones.integration.journeymap.waypoints_enable", true);
});

ClientEventRegistry.MAPPING_EVENT.subscribe(getModId(), event -> {
Expand All @@ -66,7 +67,7 @@ public void initialize(@NotNull IClientAPI api) {
}
});

ClientEventRegistry.ADDON_BUTTON_DISPLAY_EVENT.subscribe(getModId(), this::onFullscreenAddonButton);
FullscreenEventRegistry.ADDON_BUTTON_DISPLAY_EVENT.subscribe(getModId(), this::onFullscreenAddonButton);

WaystoneEvents.REMOVE_WAYSTONE_EVENT.register(this::onRemove);
WaystoneEvents.DISCOVER_WAYSTONE_EVENT.register(this::onDiscover);
Expand All @@ -85,7 +86,7 @@ private void onFullscreenAddonButton(
.addThemeToggleButton(
"fwaystones.integration.journeymap.theme.on",
"fwaystones.integration.journeymap.theme.off",
Identifier.of("fabric_waystones_icon"), // required to be in assets/journeymap/flat/icon due to themes
Identifier.of(FabricWaystones.MOD_ID, "fabric_waystones_icon.png"),
displayWaypoints.get(),
b -> {
b.toggle();
Expand Down Expand Up @@ -143,6 +144,12 @@ private void onRename(String hash) {

private void addWaypoint(String hash) {
var waypointId = waypointHashes.get(hash);
var group = this.api.getWaypointGroupByName(FabricWaystones.MOD_ID, "Waystones");
if(group == null)
{
group = WaypointFactory.createWaypointGroup(FabricWaystones.MOD_ID, "Waystones"); // might want to add this to i18n
group.setLocked(true); // so users cannot move waypoints in and out of the group(can still delete the group, but will be recreated on game join.)
}
if (FabricWaystones.WAYSTONE_STORAGE == null || api.getWaypoint(getModId(), waypointId) != null) {
return; // do not recreate waypoint
}
Expand All @@ -159,14 +166,18 @@ private void addWaypoint(String hash) {
false
);

waypoint.setIconResourceLoctaion(Identifier.of("images/fabric_waystones_icon.png"));
waypoint.setIconResourceLoctaion(Identifier.of(FabricWaystones.MOD_ID, "images/fabric_waystones_icon.png"));

waypointHashes.put(hash, waypoint.getId());
waypointHashes.put(hash, waypoint.getGuid());

try {
waypoint.setColor(waystone.getColor());
waypoint.setIconColor(null); // so icon is not colored
waypoint.setEnabled(displayWaypoints.get());
this.api.addWaypoint(getModId(), waypoint);
group.setLocked(false); // needed for now until JM is updated, cannot add waypoints to locked groups in code currently. So we need to unlock it and lock it.
group.addWaypoint(waypoint);
group.setLocked(true);
} catch (Throwable t) {
FabricWaystones.LOGGER.error(t.getMessage(), t);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/fwaystones/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
"fwaystones.integration.journeymap.category.tooltip": "Fabric-Waystones Journeymap Properties",
"fwaystones.integration.journeymap.enable": "Enable",
"fwaystones.integration.journeymap.enable.tooltip": "Enable Integration, disabling will not hide existing waypoints but it will prevent new ones being created when waystones are discovered",
"fwaystones.integration.journeymap.waypoints_enable": "Enable Waystone Waypoints",
"fwaystones.integration.journeymap.waypoints_enable.tooltip": "Creates waypoints for waystones.",
"fwaystones.integration.journeymap.random_color": "Randomize Color",
"fwaystones.integration.journeymap.random_color.tooltip": "Randomizes waypoint color on creation",
"fwaystones.integration.journeymap.theme.on": "Hide Waystones",
Expand Down
Binary file not shown.

0 comments on commit b789de4

Please sign in to comment.