Skip to content

Commit ae3e6e7

Browse files
authored
Add JourneyMap integration (#42)
1 parent 0b85d10 commit ae3e6e7

File tree

13 files changed

+155
-38
lines changed

13 files changed

+155
-38
lines changed

README.md

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1+
<!-- modrinth_exclude.start -->
12
# Empire Minecraft Utilities
23

34
[![Modrinth downloads](https://img.shields.io/modrinth/dt/emcutils?color=5da545&label=downloads&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMSAxMSIgd2lkdGg9IjE0LjY2NyIgaGVpZ2h0PSIxNC42NjciICB4bWxuczp2PSJodHRwczovL3ZlY3RhLmlvL25hbm8iPjxkZWZzPjxjbGlwUGF0aCBpZD0iQSI+PHBhdGggZD0iTTAgMGgxMXYxMUgweiIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNBKSI+PHBhdGggZD0iTTEuMzA5IDcuODU3YTQuNjQgNC42NCAwIDAgMS0uNDYxLTEuMDYzSDBDLjU5MSA5LjIwNiAyLjc5NiAxMSA1LjQyMiAxMWMxLjk4MSAwIDMuNzIyLTEuMDIgNC43MTEtMi41NTZoMGwtLjc1LS4zNDVjLS44NTQgMS4yNjEtMi4zMSAyLjA5Mi0zLjk2MSAyLjA5MmE0Ljc4IDQuNzggMCAwIDEtMy4wMDUtMS4wNTVsMS44MDktMS40NzQuOTg0Ljg0NyAxLjkwNS0xLjAwM0w4LjE3NCA1LjgybC0uMzg0LS43ODYtMS4xMTYuNjM1LS41MTYuNjk0LS42MjYuMjM2LS44NzMtLjM4N2gwbC0uMjEzLS45MS4zNTUtLjU2Ljc4Ny0uMzcuODQ1LS45NTktLjcwMi0uNTEtMS44NzQuNzEzLTEuMzYyIDEuNjUxLjY0NSAxLjA5OC0xLjgzMSAxLjQ5MnptOS42MTQtMS40NEE1LjQ0IDUuNDQgMCAwIDAgMTEgNS41QzExIDIuNDY0IDguNTAxIDAgNS40MjIgMCAyLjc5NiAwIC41OTEgMS43OTQgMCA0LjIwNmguODQ4QzEuNDE5IDIuMjQ1IDMuMjUyLjgwOSA1LjQyMi44MDljMi42MjYgMCA0Ljc1OCAyLjEwMiA0Ljc1OCA0LjY5MSAwIC4xOS0uMDEyLjM3Ni0uMDM0LjU2bC43NzcuMzU3aDB6IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGZpbGw9IiM1ZGE0MjYiLz48L2c+PC9zdmc+)](https://modrinth.com/mod/emcutils)
4-
![](https://tokei.rs/b1/github/wafflecoffee/Empire-Minecraft-Utilities?category=code)
5-
![](https://tokei.rs/b1/github/wafflecoffee/Empire-Minecraft-Utilities?category=files)
65
![](https://img.shields.io/badge/environment-client-1976d2)
6+
<!-- modrinth_exclude.end -->
77

88
Empire Minecraft Utilities, aka emcutils, is a 1.16, 1.17, and 1.18 mod containing a collection of small utilities for players of [Empire Minecraft](https://ref.emc.gs/wafflecoffee).
99
Feature idea credits go to [Giselbaer](https://u.emc.gs/Giselbaer)/[gbl](https://github.com/gbl).
1010

1111
Made by [MrFrydae](https://u.emc.gs/GreenMeanie) and [wafflecoffee/Emmaffle](https://u.emc.gs/wafflecoffee), available under the MIT License.
1212

13-
Modrinth page for downloads: https://modrinth.com/mod/emcutils
14-
1513
Architectury API is the only required dependency (download for [Fabric](https://www.curseforge.com/minecraft/mc-mods/architectury-fabric) or [Forge](https://www.curseforge.com/minecraft/mc-mods/architectury-forge)). [Not Enough Crashes](https://modrinth.com/mod/notenoughcrashes) is recommended, as are [Mod Menu](https://modrinth.com/mod/modmenu) and [VoxelMap](https://www.curseforge.com/minecraft/mc-mods/voxelmap) when on Fabric.
1614

1715
## Feature List
@@ -21,15 +19,11 @@ Architectury API is the only required dependency (download for [Fabric](https://
2119
* Easier viewing of usable Custom Items such as [Pot of Gold](https://wiki.emc.gs/pot-of-gold) or [EMC Peppermint](https://wiki.emc.gs/emc-peppermint)
2220
* Customizable tab list sorting
2321
* Vault buttons
24-
* Integration with VoxelMap and Xaero's World Map/Minimap
22+
* Integration with JourneyMap, VoxelMap, and Xaero's World Map/Minimap
2523
* Clicking on a residence will teleport you to that residence
26-
* Automatic world detection and map confirmation/creation (Voxel only)
24+
* Automatic world detection and map confirmation/creation (not available on Xaero's)
2725
* And more to come :)
2826

29-
## Maven/Development
30-
31-
See [here](https://gist.github.com/wafflecoffee/95cc480698ec06b6295d1e9c8946fa61) for instructions on developing with emcutils.
32-
3327
## Disclaimer
3428

3529
This mod is not sponsored by nor affiliated with Empire Minecraft, Starlis LLC, or Mojang Studios. It has been approved for use on Empire Minecraft in accordance with its [approved mod](https://mods.emc.gs) policies.

build.gradle

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ plugins {
22
id "architectury-plugin" version "3.4.+"
33
id "dev.architectury.loom" version "0.11.0.+" apply false
44
id "com.modrinth.minotaur" version "2.+" apply false
5-
id "io.github.juuxel.loom-quiltflower" version "1.+" apply false
5+
id "org.quiltmc.quilt-mappings-on-loom" version "4.+"
6+
//id "io.github.juuxel.loom-quiltflower" version "1.+" apply false
67
}
78

89
architectury {
@@ -11,10 +12,11 @@ architectury {
1112

1213
subprojects {
1314
apply plugin: "dev.architectury.loom"
14-
apply plugin: "io.github.juuxel.loom-quiltflower"
15+
//apply plugin: "io.github.juuxel.loom-quiltflower"
1516
apply plugin: "com.modrinth.minotaur"
1617

1718
repositories {
19+
mavenLocal()
1820
maven {
1921
url "https://api.modrinth.com/maven"
2022
content { includeGroup "maven.modrinth" }
@@ -31,7 +33,9 @@ subprojects {
3133

3234
dependencies {
3335
minecraft "com.mojang:minecraft:${rootProject.mc_version}"
34-
mappings "net.fabricmc:yarn:${rootProject.mc_version}+build.${rootProject.yarn_mappings}:v2"
36+
mappings( loom.layered { it.addLayer ( quiltMappings.mappings (
37+
"org.quiltmc:quilt-mappings:${rootProject.mc_version}+build.${rootProject.quilt_mappings}:v2"
38+
))})
3539

3640
if (project.name != "forge") {
3741
modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}"
@@ -50,9 +54,6 @@ allprojects {
5054
archivesBaseName = "emcutils-${project.name}-${rootProject.mc_version}"
5155
version = mod_version + System.getenv().SNAPSHOT
5256

53-
// Comment this line out if you have good internet
54-
idea { module { downloadJavadoc = false } }
55-
5657
tasks.withType(JavaCompile) {
5758
options.encoding = "UTF-8"
5859
//noinspection all

common/src/main/java/dev/frydae/emcutils/containers/EmpireServer.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public enum EmpireServer {
3838
@Getter private final char tabListDisplay;
3939
@Getter private final String command;
4040
@Getter private final List<EmpireResidence> residences;
41-
private static boolean didConnectionFail;
4241

4342
EmpireServer(int id, String name, int tabListRank, char tabListDisplay) {
4443
this.id = id;
@@ -136,11 +135,9 @@ public void collectResidences() {
136135
.getAsJsonObject("areas");
137136

138137
object.entrySet().forEach(e -> residences.add(new EmpireResidence(this, e.getValue().getAsJsonObject())));
139-
} catch (IOException ioException) {
140-
didConnectionFail = true;
138+
LOG.info("Loaded Residences for: " + name.toLowerCase());
139+
} catch (IOException e) {
140+
LOG.info("Residence collector for " + name.toLowerCase() + " failed; you may find the 'Don't run residence collector' option to be useful. This option will prevent the residence collector from running at all, which, on very slow connections, will help prevent requests which will fail anyway.");
141141
}
142-
143-
if (didConnectionFail) LOG.info("Residence collector for " + name.toLowerCase() + " failed; you may find the 'Don't run residence collector' option to be useful. This option will prevent the residence collector from running at all, which, on very slow connections, will help prevent requests which will fail anyway.");
144-
else LOG.info("Loaded Residences for: " + name.toLowerCase());
145142
}
146143
}

common/src/main/java/dev/frydae/emcutils/features/VaultScreen.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ private void handleClick(int buttonX, double mouseX, double mouseY, String comma
171171
}
172172

173173
@Override
174-
public void close() {
175-
if (shouldCallClose) super.close();
174+
public void onClose() {
175+
if (shouldCallClose) super.onClose();
176176
else shouldCallClose = true;
177177
}
178178
}

common/src/main/java/dev/frydae/emcutils/mixins/ClientPlayNetworkHandlerMixin.java

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public void onPostReceiveMessage(GameMessageS2CPacket packet, CallbackInfo info)
4040
@Inject(at = @At("TAIL"), method = "onGameJoin")
4141
public void onGameJoin(GameJoinS2CPacket packet, CallbackInfo info) {
4242
if (Util.isOnEMC) {
43+
Util.world = packet.dimensionId().getValue().getPath();
44+
4345
EmpireMinecraftUtilities.onJoinEmpireMinecraft();
4446

4547
ClientTickEvent.CLIENT_LEVEL_POST.register(instance -> Util.executeJoinCommands());

common/src/main/java/dev/frydae/emcutils/mixins/MinecraftClientMixin.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import dev.frydae.emcutils.features.VaultScreen;
44
import net.minecraft.client.MinecraftClient;
55
import net.minecraft.client.gui.screen.Screen;
6-
import net.minecraft.client.option.KeyBinding;
6+
import net.minecraft.client.option.KeyBind;
77
import net.minecraft.client.util.Window;
88
import org.jetbrains.annotations.Nullable;
99
import org.spongepowered.asm.mixin.Final;
@@ -33,7 +33,7 @@ public void onOpenScreen(@Nullable Screen screen, CallbackInfo ci) {
3333

3434
mc.currentScreen = screen;
3535
mc.mouse.unlockCursor();
36-
KeyBinding.unpressAll();
36+
KeyBind.unpressAll();
3737
screen.init(mc, window.getScaledWidth(), window.getScaledHeight());
3838
mc.skipGameRender = false;
3939

common/src/main/java/dev/frydae/emcutils/utils/Util.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import lombok.SneakyThrows;
1010
import net.minecraft.client.MinecraftClient;
1111
import net.minecraft.client.network.PlayerListEntry;
12-
import org.apache.logging.log4j.LogManager;
13-
import org.apache.logging.log4j.Logger;
12+
import org.slf4j.Logger;
13+
import org.slf4j.LoggerFactory;
1414

1515
import java.util.Arrays;
1616
import java.util.Collections;
@@ -22,10 +22,10 @@
2222

2323
public class Util {
2424
public static final String MODID = "emcutils";
25-
public static final Logger LOG = LogManager.getLogger(MODID);
25+
public static final Logger LOG = LoggerFactory.getLogger(MODID);
2626
public static boolean isOnEMC = false;
2727
@Getter public static String world;
28-
public static boolean hideFeatureMessages;
28+
@Setter public static boolean hideFeatureMessages;
2929
@Getter @Setter private static String serverAddress;
3030
@Getter private static EmpireServer currentServer;
3131
private static Queue<String> onJoinCommandQueue;
@@ -98,10 +98,6 @@ public static synchronized Util getInstance() {
9898
return singleton;
9999
}
100100

101-
public void setHideFeatureMessages(boolean hide) {
102-
hideFeatureMessages = hide;
103-
}
104-
105101
public static void runResidenceCollector() {
106102
if (!Config.dontRunResidenceCollector()) {
107103
ExecutorService executor = Executors.newCachedThreadPool();

fabric/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies {
3333
exclude group: "net.fabricmc"
3434
}
3535

36+
include project(":journey")
3637
include project(":voxel")
3738
include project(":xaero")
3839

@@ -91,7 +92,9 @@ modrinth {
9192
new ModDependency("codAaoxh", "required"), // MidnightLib
9293
new ModDependency("mOgUt4GM", "optional"), // Mod Menu
9394
]
95+
syncBodyFrom = rootProject.file("README.md").text
9496
}
97+
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
9598

9699
publishing {
97100
publications {

gradle.properties

+11-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ org.gradle.jvmargs=-Xmx4G
33
org.gradle.parallel=true
44

55
mc_version=1.18.2
6-
mod_version=3.0.1-SNAPSHOT
6+
mod_version=3.1.0
77

8-
release_title=Update to 1.18.2
9-
changeLog=
8+
release_title=Add JourneyMap compatibility
9+
changeLog=JM compat requires 5.8.1beta3 or higher.\n\nAlso has some internal changes in how presence of compat mods are present.
10+
11+
# https://lambdaurora.dev/tools/import_quilt.html
12+
quilt_mappings=21
1013

1114
# https://fabricmc.net/develop
12-
yarn_mappings=2
1315
loader_version=0.13.3
1416
fabric_version=0.48.0+1.18.2
1517

@@ -28,6 +30,11 @@ modmenu_version=3.1.0
2830
# https://www.curseforge.com/minecraft/mc-mods/config-menus-forge/files/all
2931
config_menus_version=3671318
3032

33+
# https://www.curseforge.com/minecraft/mc-mods/journeymap/files/all
34+
jm_version=3717512
35+
# https://jm.gserv.me/service/rest/repository/browse/maven-public/info/journeymap/journeymap-api/
36+
jm_api_version=1.18.2-1.8-fabric-SNAPSHOT
37+
3138
# https://www.curseforge.com/minecraft/mc-mods/voxelmap/files/all
3239
# voxel_version=3345206
3340

journey/build.gradle

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repositories {
2+
maven {
3+
url "https://jm.gserv.me/repository/maven-public/"
4+
}
5+
}
6+
7+
dependencies {
8+
modCompileOnlyApi "info.journeymap:journeymap-api:${project.jm_api_version}"
9+
modRuntimeOnly "curse.maven:jm-32274:${project.jm_version}"
10+
11+
api project(":common")
12+
api project(":fabric")
13+
}
14+
15+
processResources {
16+
inputs.property "version", rootProject.mod_version
17+
18+
filesMatching("fabric.mod.json") {
19+
expand "version": rootProject.mod_version
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package dev.frydae.emcutils.journey;
2+
3+
import dev.frydae.emcutils.containers.EmpireResidence;
4+
import dev.frydae.emcutils.utils.Util;
5+
import journeymap.client.api.IClientAPI;
6+
import journeymap.client.api.IClientPlugin;
7+
import journeymap.client.api.display.Context;
8+
import journeymap.client.api.display.ModPopupMenu;
9+
import journeymap.client.api.event.ClientEvent;
10+
import journeymap.client.api.event.fabric.FabricEvents;
11+
import net.minecraft.client.MinecraftClient;
12+
import net.minecraft.util.math.BlockPos;
13+
import net.minecraft.util.math.Vec3d;
14+
import org.jetbrains.annotations.NotNull;
15+
16+
import java.util.EnumSet;
17+
18+
import static dev.frydae.emcutils.utils.Util.MODID;
19+
import static journeymap.client.api.event.ClientEvent.Type.MAPPING_STARTED;
20+
21+
public class EmpireMinecraftUtilitiesJourney implements IClientPlugin {
22+
private IClientAPI api;
23+
@Override
24+
public void initialize(@NotNull final IClientAPI api) {
25+
this.api = api;
26+
27+
api.subscribe(getModId(), EnumSet.of(MAPPING_STARTED));
28+
29+
// Turn off radars on EMC
30+
FabricEvents.ENTITY_RADAR_UPDATE_EVENT.register(event -> { if (Util.isOnEMC) event.setCanceled(true); });
31+
32+
// Add residence TP button
33+
FabricEvents.FULLSCREEN_POPUP_MENU_EVENT.register(event ->
34+
event.getPopupMenu().addMenuItem("Teleport to Residence", new TeleportToResidenceAction()));
35+
}
36+
37+
@Override
38+
public String getModId() {
39+
return MODID;
40+
}
41+
42+
@SuppressWarnings("deprecation")
43+
@Override
44+
public void onEvent(@NotNull final ClientEvent event) {
45+
if (event.type.equals(MAPPING_STARTED) && Util.isOnEMC) {
46+
// Disable cave maps on EMC
47+
api.toggleDisplay(null, Context.MapType.Underground, Context.UI.Any, false);
48+
49+
// Set world names on EMC
50+
api.setWorldId(Util.getCurrentServer().getName().toLowerCase());
51+
}
52+
}
53+
54+
private static class TeleportToResidenceAction implements ModPopupMenu.Action {
55+
@Override
56+
public void doAction(final @NotNull BlockPos pos) {
57+
if (Util.isOnEMC) {
58+
EmpireResidence res = Util.getCurrentServer().getResidenceByLoc(new Vec3d(pos.getX(), pos.getY(), pos.getZ()));
59+
if (res != null) {
60+
MinecraftClient.getInstance().player.sendChatMessage(res.getVisitCommand());
61+
}
62+
}
63+
}
64+
}
65+
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"schemaVersion": 1,
3+
"id": "emcutils-jm-compat",
4+
"version": "${version}",
5+
"name": "Empire Minecraft Utilities JourneyMap Compatibility",
6+
"description": "JourneyMap compatibility for Empire Minecraft Utilities",
7+
"authors": [
8+
"wafflecoffee"
9+
],
10+
"license": "MIT",
11+
"environment": "client",
12+
"entrypoints": {
13+
"journeymap": [
14+
"dev.frydae.emcutils.journey.EmpireMinecraftUtilitiesJourney"
15+
]
16+
},
17+
"custom": {
18+
"modmenu": {
19+
"parent": "emcutils"
20+
}
21+
},
22+
"depends": {
23+
"journeymap-fabric": ">=5.8.1beta3",
24+
"emcutils": ">=3.0.0"
25+
}
26+
}

settings.gradle

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
pluginManagement {
22
repositories {
3+
maven {
4+
name = 'Quilt'
5+
url = 'https://maven.quiltmc.org/repository/release/'
6+
}
37
maven {
48
name = 'Fabric'
59
url = 'https://maven.fabricmc.net/'
@@ -23,5 +27,6 @@ pluginManagement {
2327
include 'common'
2428
include 'fabric'
2529
include 'forge'
30+
include 'journey'
2631
include 'voxel'
2732
include 'xaero'

0 commit comments

Comments
 (0)