Skip to content

Commit

Permalink
Finish 1.21 update
Browse files Browse the repository at this point in the history
Everything works except Xaero map names and forced settings
  • Loading branch information
triphora committed Jun 25, 2024
1 parent 5a3174b commit 93ad743
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 66 deletions.
2 changes: 1 addition & 1 deletion common/src/main/java/coffee/waffle/emcutils/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public int compare(EnhancedTabListEntry entry1, EnhancedTabListEntry entry2) {
SERVER_DESCENDING {
@Override
public int compare(EnhancedTabListEntry entry1, EnhancedTabListEntry entry2) {
return Integer.compare(entry1.server.tabListRank, entry2.server.tabListRank);
return Integer.compare(entry2.server.tabListRank, entry1.server.tabListRank);
}
};

Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/coffee/waffle/emcutils/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Util {
public static int playerGroupId = 0;

public static void setCurrentServer(String name) {
if (name.equalsIgnoreCase("utop")) name = "utopia";
for (EmpireServer server : EmpireServer.values()) {
if (server.name.equalsIgnoreCase(name)) {
currentServer = server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public void collectResidences(HttpClient client) {

residences.add(new EmpireResidence(this, e.getValue().getAsJsonObject()));
});
LOG.info("Loaded residences for: " + name.toLowerCase());
LOG.info("Loaded residences for: {}", name.toLowerCase());
} catch (IOException | InterruptedException e) {
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.");
LOG.info("Residence collector for {} 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.", name.toLowerCase());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ private static void drawButton(Screen screen, DrawContext context, ChatChannel c
int height = textRenderer.fontHeight;

if (currentChannel == channel && !inPrivateConversation) {
context.fill(channel.getOffset(), screen.height - 33, channel.getOffset() + width + 5, screen.height - (32 - height - 4), (0xff << 24) | channel.format.getColorValue());
context.fill(channel.getOffset(), screen.height - 33, channel.getOffset() + width + 5, screen.height - (32 - height - 4), (0xff << 24) | channel.color);
}

context.fill(channel.getOffset() + 1, screen.height - 32, channel.getOffset() + width + 4, screen.height - (32 - height - 3), (0xc0 << 24));
context.drawText(textRenderer, Text.of(channel.name), channel.getOffset() + 3, screen.height - 30, channel.format.getColorValue(), true);
context.drawText(textRenderer, Text.of(channel.name), channel.getOffset() + 3, screen.height - 30, channel.color, true);
}

private static void drawPrivateConversation(Screen screen, DrawContext context) {
Expand Down Expand Up @@ -110,24 +110,25 @@ public static Formatting groupIdToFormatting(int groupId) {
}

public enum ChatChannel {
COMMUNITY("Community", "cc", Formatting.DARK_GREEN, null),
MARKET("Market", "cm", Formatting.GOLD, COMMUNITY),
SERVER("Server", "cs", Formatting.RED, MARKET),
LOCAL("Local", "cl", Formatting.YELLOW, SERVER),
RESIDENCE("Residence", "cr", Formatting.BLUE, LOCAL),
GROUP("Group", "cg", Formatting.DARK_AQUA, RESIDENCE),
SUPPORTER("Supporter", "cp", Formatting.AQUA, GROUP),
MODERATOR("Moderator", "cx", Formatting.LIGHT_PURPLE, SUPPORTER);
COMMUNITY("Community", "cc", Formatting.DARK_GREEN.getColorValue(), null),
DISCORD("Discord", "cd", 0x7087d6, COMMUNITY),
MARKET("Market", "cm", Formatting.GOLD.getColorValue(), DISCORD),
SERVER("Server", "cs", Formatting.RED.getColorValue(), MARKET),
LOCAL("Local", "cl", Formatting.YELLOW.getColorValue(), SERVER),
RESIDENCE("Residence", "cr", Formatting.BLUE.getColorValue(), LOCAL),
GROUP("Group", "cg", Formatting.DARK_AQUA.getColorValue(), RESIDENCE),
SUPPORTER("Supporter", "cp", 0xfbbf00, GROUP),
MODERATOR("Moderator", "cx", Formatting.LIGHT_PURPLE.getColorValue(), SUPPORTER);

private final String name;
private final String command;
private final Formatting format;
private final Integer color;
private final ChatChannel adjustAgainst;

ChatChannel(String name, String command, Formatting format, ChatChannel adjustAgainst) {
ChatChannel(String name, String command, Integer color, ChatChannel adjustAgainst) {
this.name = name;
this.command = command;
this.format = format;
this.color = color;
this.adjustAgainst = adjustAgainst;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void init() {

private static ActionResult handlePrivateMessageStart(Text text) {
if (text.getString().matches(CHAT_PRIVATE_MESSAGE)) {
var user = text.getSiblings().get(0);
var user = text.getSiblings().getFirst();

ChatChannels.inPrivateConversation = true;
ChatChannels.currentChannel = null;
Expand All @@ -40,7 +40,7 @@ private static ActionResult handlePrivateMessageStart(Text text) {

private static ActionResult handleChatChannelChange(Text text) {
if (text.getString().matches(CHAT_FOCUS_MESSAGE)) {
var channel = ChatChannels.ChatChannel.getChannelByName(text.getSiblings().get(0).getString().trim());
var channel = ChatChannels.ChatChannel.getChannelByName(text.getSiblings().getFirst().getString().trim());

if (channel != null) {
ChatChannels.currentChannel = channel;
Expand All @@ -54,14 +54,14 @@ private static ActionResult handleChatChannelChange(Text text) {
private static ActionResult initialServerInfo(Text text) {
if (text.getString().matches(WELCOME_TO_EMC)) {
var currentServer = text // Welcome to
.getSiblings().get(0) // Empire Minecraft
.getSiblings().get(0) // -
.getSiblings().get(0); // SMPx
.getSiblings().getFirst() // Empire Minecraft
.getSiblings().getFirst() // -
.getSiblings().getFirst(); // SMPx/UTOPIA
Util.setCurrentServer(currentServer.getString().substring(0, 4));

var group = currentServer
.getSiblings().get(0) // ,
.getSiblings().get(0) // PLAYERNAME
.getSiblings().getFirst() // ,
.getSiblings().getFirst() // PLAYERNAME
.getStyle().getColor();
if (group != null) Util.playerGroupId = getGroupIdFromColor(group);

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
org.gradle.jvmargs=-Xmx4G
org.gradle.parallel=true

mod_version=9.0.0-alpha.1
mod_version=9.0.0
4 changes: 0 additions & 4 deletions gradle/loader.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ shadowJar {
archiveClassifier = 'dev-shadow'
}

tasks.register('gabagool') {
print remapJar.getTaskDependencies().getDependencies(remapJar)
}

remapJar {
inputFile.set shadowJar.archiveFile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import coffee.waffle.emcutils.Util;
import journeymap.api.v2.client.IClientAPI;
import journeymap.api.v2.client.IClientPlugin;
import journeymap.api.v2.client.JourneyMapPlugin;
import journeymap.api.v2.client.display.Context;
import journeymap.api.v2.client.event.MappingEvent;
import journeymap.api.v2.client.fullscreen.ModPopupMenu;
Expand All @@ -16,6 +17,7 @@
import static coffee.waffle.emcutils.Util.LOG;
import static coffee.waffle.emcutils.Util.MODID;

@JourneyMapPlugin(apiVersion = "2.0.0")
public class EMCUtilsJourney implements IClientPlugin {
private static final MinecraftClient client = MinecraftClient.getInstance();

Expand Down Expand Up @@ -44,8 +46,9 @@ public void initialize(@NotNull final IClientAPI api) {
});

// Add residence TP button
ClientEventRegistry.FULLSCREEN_POPUP_MENU_EVENT.subscribe(MODID, event ->
event.getPopupMenu().addMenuItem("Teleport to Residence", new TeleportToResidenceAction()));
ClientEventRegistry.FULLSCREEN_POPUP_MENU_EVENT.subscribe(MODID, event -> {
if (Util.isOnEMC) event.getPopupMenu().addMenuItem("Teleport to Residence", new TeleportToResidenceAction());
});
}

@Override
Expand Down
19 changes: 11 additions & 8 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ apply from: '../gradle/loader.gradle'

architectury.neoForge()

//maven {
// url "https://maven.neoforged.net/releases/"
//}

loom.neoForge {
// convertAccessWideners.set true
loom {
neoForge {
accessWidenerPath.set project(":common").file("src/main/resources/emcutils.accesswidener")
//convertAccessWideners.set true
}
}

configurations {
Expand All @@ -26,7 +25,11 @@ dependencies {
processResources {
inputs.property 'version', project.version

filesMatching('META-INF/mods.toml') {
expand 'version': project.version
filesMatching('META-INF/neoforge.mods.toml') {
expand version: project.version
}
}

remapJar {
atAccessWideners.add "emcutils.accesswidener"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coffee.waffle.emcutils.forge;
package coffee.waffle.emcutils.neoforge;

import coffee.waffle.emcutils.Config.ChatAlertSound;
import coffee.waffle.emcutils.Config.TabListCurrentServerPlacement;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package coffee.waffle.emcutils.forge;
package coffee.waffle.emcutils.neoforge;

import coffee.waffle.emcutils.event.TooltipCallback;
import coffee.waffle.emcutils.feature.VaultScreen;
import coffee.waffle.emcutils.Util;
import net.minecraft.client.gui.screen.ingame.HandledScreens;
import net.minecraft.registry.Registries;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.fml.loading.FMLPaths;
import net.neoforged.neoforge.registries.DeferredRegister;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -23,9 +26,15 @@
import static coffee.waffle.emcutils.Util.MODID;

@Mod(MODID)
public class EMCUtilsForge {
public EMCUtilsForge(ModContainer container) {
NeoForge.EVENT_BUS.addListener(this::clientSetupEvent);
public class EMCUtilsNeoForge {
public EMCUtilsNeoForge(ModContainer container, IEventBus modBus) {
modBus.addListener(this::clientSetupEvent);
modBus.addListener(this::registerScreen);
NeoForge.EVENT_BUS.addListener(this::tooltipEvent);

var registry = DeferredRegister.create(Registries.SCREEN_HANDLER, MODID);
registry.register(modBus);
registry.register("generic_63", () -> VaultScreen.GENERIC_9X7);

container.registerConfig(ModConfig.Type.CLIENT, ConfigImpl.SPEC);

Expand All @@ -44,7 +53,7 @@ private static void movePacks(String... packs) {
}

for (String pack : packs) {
try (InputStream packZip = EMCUtilsForge.class.getResourceAsStream("/resourcepacks/" + pack + ".zip")) {
try (InputStream packZip = EMCUtilsNeoForge.class.getResourceAsStream("/resourcepacks/" + pack + ".zip")) {
Files.copy(packZip, Paths.get("resourcepacks/" + pack + ".zip")); // This works in prod but not dev
} catch (FileAlreadyExistsException ignored) {
} catch (IOException | NullPointerException e) {
Expand All @@ -53,14 +62,18 @@ private static void movePacks(String... packs) {
}
}

@SubscribeEvent
public void registerScreen(RegisterMenuScreensEvent event) {
event.register(VaultScreen.GENERIC_9X7, VaultScreen::new);
}

@SubscribeEvent
public void clientSetupEvent(FMLClientSetupEvent event) {
HandledScreens.register(VaultScreen.GENERIC_9X7, VaultScreen::new);
Util.runResidenceCollector();
}

@SubscribeEvent
public static void tooltipEvent(ItemTooltipEvent event) {
public void tooltipEvent(ItemTooltipEvent event) {
TooltipCallback.ITEM.invoker().append(event.getItemStack(), event.getToolTip(), event.getContext(), event.getFlags());
}
}
19 changes: 8 additions & 11 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader = "javafml"
loaderVersion = "[44,)"
loaderVersion = "[4,)"
issueTrackerURL = "https://github.com/emmods/emcutils/issues"
license = "MIT"

Expand All @@ -23,22 +23,19 @@ updateJSONURL = "https://api.modrinth.com/updates/emcutils/forge_updates.json"
config = "emcutils-common.mixins.json"

[[dependencies.emcutils]]
modId = "forge"
mandatory = true
versionRange = "[44,)"
ordering = "NONE"
modId = "neoforge"
type = "required"
versionRange = "[21.0,)"
side = "CLIENT"

[[dependencies.emcutils]]
modId = "minecraft"
mandatory = true
versionRange = "[1.19.3,)"
ordering = "NONE"
type = "required"
versionRange = "[1.21,)"
side = "CLIENT"

[[dependencies.emcutils]]
modId = "configured"
mandatory = false
versionRange = "[2.0.2,)"
ordering = "NONE"
type = "optional"
versionRange = "[2.5,)"
side = "CLIENT"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import coffee.waffle.emcutils.container.EmpireResidence;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.registry.RegistryKey;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -17,7 +19,7 @@
@Mixin(MapTeleporter.class)
abstract class MapTeleporterMixin {
@Inject(method = "teleport", at = @At(value = "INVOKE_ASSIGN", target = "Lxaero/map/world/MapWorld;getTeleportCommandFormat()Ljava/lang/String;", remap = false), cancellable = true, remap = false)
private void emcutils$xaero$enableMapTeleportation(Screen screen, MapWorld mapWorld, int x, int y, int z, CallbackInfo ci) {
private void emcutils$xaero$enableMapTeleportation(Screen screen, MapWorld mapWorld, int x, int y, int z, RegistryKey<World> d, CallbackInfo ci) {
if (Util.isOnEMC) {
EmpireResidence res = Util.currentServer.getResidenceByLoc(new Vec3d(x, y, z));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xaero.common.minimap.waypoints.Waypoint;
import xaero.common.minimap.waypoints.WaypointWorld;
import xaero.map.mods.SupportXaeroMinimap;
import xaero.map.mods.gui.Waypoint;
import xaero.common.minimap.waypoints.WaypointsManager;

@Pseudo
@Mixin(SupportXaeroMinimap.class)
abstract class SupportXaeroMinimapMixin {
@Inject(method = "teleportToWaypoint(Lnet/minecraft/client/gui/screen/Screen;Lxaero/map/mods/gui/Waypoint;Lxaero/common/minimap/waypoints/WaypointWorld;)V", at = @At("HEAD"), cancellable = true)
public void emcutils$xaero$teleportToResidence(Screen screen, Waypoint w, WaypointWorld world, CallbackInfo ci) {
@Mixin(WaypointsManager.class)
abstract class WaypointsManagerMixin {
@Inject(method = "teleportToWaypoint(Lxaero/common/minimap/waypoints/Waypoint;Lxaero/common/minimap/waypoints/WaypointWorld;Lnet/minecraft/client/gui/screen/Screen;Z)V", at = @At("HEAD"), cancellable = true)
public void emcutils$xaero$teleportToResidence(Waypoint w, WaypointWorld world, Screen screen, boolean respectHiddenCoords, CallbackInfo ci) {
if (world != null) {
if (Util.isOnEMC) {
EmpireResidence res = Util.currentServer.getResidenceByLoc(new Vec3d(w.getX(), 64, w.getZ()));
Expand Down
2 changes: 1 addition & 1 deletion xaero/src/main/resources/emcutils-xaero.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"GuiMapNameMixin",
"MapTeleporterMixin",
"ModSettingsMixin",
"SupportXaeroMinimapMixin"
"WaypointsManagerMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 93ad743

Please sign in to comment.