Skip to content

Commit

Permalink
Update to 1.20.4 and convert Quilt module to Fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
triphora committed Feb 12, 2024
1 parent fa00491 commit e109874
Show file tree
Hide file tree
Showing 35 changed files with 206 additions and 265 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- uses: gradle/gradle-build-action@v2
with:
gradle-version: release-candidate
arguments: forge:modrinth quilt:modrinth
arguments: forge:modrinth fabric:modrinth
cache-read-only: ${{ github.repository_owner != 'emmods' }}
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ run/
generated/
.architectury-transformer/
*.jar
quilt/.quilt
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021-2023 MrFrydae, triphora, and contributors
Copyright (c) 2021–2024 MrFrydae, triphora, and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# Empire Minecraft Utilities
<!-- modrinth_exclude.end -->

![Forge](https://raw.githubusercontent.com/intergrav/devins-badges/v1/assets/supported/forge_64h.png) ![Quilt](https://raw.githubusercontent.com/intergrav/devins-badges/v1/assets/supported/quilt_64h.png) ![No Fabric](https://raw.githubusercontent.com/intergrav/devins-badges/v1/assets/unsupported/no-fabric_64h.png)<br>
![Forge](https://raw.githubusercontent.com/intergrav/devins-badges/v1/assets/supported/forge_64h.png) ![Fabric](https://raw.githubusercontent.com/intergrav/devins-badges/v1/assets/supported/fabric_64h.png)<br>
[![Modrinth](https://raw.githubusercontent.com/intergrav/devins-badges/v1/assets/download/modrinth_64h.png)](https://modrinth.com/mod/emcutils) [![GitHub](https://raw.githubusercontent.com/intergrav/devins-badges/v1/assets/repository/github_64h.png)](https://github.com/emmods/emcutils)

Empire Minecraft Utilities, aka emcutils, is a 1.16-1.19 client-side mod containing a collection of small utilities for players of [Empire Minecraft](https://ref.emc.gs/triphora).
Feature idea credits go to [Giselbaer](https://u.emc.gs/Giselbaer)/[gbl](https://github.com/gbl).

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

On Forge, there are no dependencies which you need to download. On Quilt, you need to download the [Quilt Standard Libraries](https://modrinth.com/mod/qsl) like most Quilt mods, and [MidnightLib](https://modrinth.com/mod/midnightlib) is embedded. [Mod Menu](https://modrinth.com/mod/modmenu) and [JourneyMap](https://modrinth.com/mod/journeymap) are recommended on Quilt.
On Forge, there are no dependencies that you need to download. On Fabric, you need to download [Fabric API](https://modrinth.com/mod/fabric-api) like most Fabric mods, and [MidnightLib](https://modrinth.com/mod/midnightlib) is embedded. [Mod Menu](https://modrinth.com/mod/modmenu) and [JourneyMap](https://modrinth.com/mod/journeymap) are recommended on Fabric.

## Feature List

Expand All @@ -19,7 +19,7 @@ On Forge, there are no dependencies which you need to download. On Quilt, you ne
* 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)
* Customizable tab list sorting
* Vault buttons
* Quilt-only: Integration with JourneyMap and Xaero's World Map/Minimap
* Fabric-only: Integration with JourneyMap and Xaero's World Map/Minimap
* Clicking on a residence will teleport you to that residence
* Automatic world detection and map confirmation/creation

Expand Down
7 changes: 0 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
plugins {
alias libs.plugins.architectury.plugin
alias libs.plugins.architectury.loom apply false
alias libs.plugins.loom.quiltflower apply false
//alias libs.plugins.machete
}

String mcVer = libs.versions.minecraft.get()
architectury.minecraft = mcVer

subprojects {
apply plugin: 'dev.architectury.loom'
apply plugin: 'io.github.juuxel.loom-quiltflower'

repositories {
[
['Modrinth', 'api.modrinth.com/maven', ['maven.modrinth'], []],
['QuiltMC', 'maven.quiltmc.org/repository/release', ['org.quiltmc'], ['org\\.quiltmc\\..*']],
].forEach { var mavenInfo ->
exclusiveContent {
forRepository {
Expand All @@ -41,8 +37,6 @@ subprojects {
mappings variantOf(libs.yarn) { classifier 'v2' }
}

quiltflower.addToRuntimeClasspath = true

loom {
runtimeOnlyLog4j = true

Expand All @@ -58,7 +52,6 @@ allprojects {
apply plugin: 'java'
apply plugin: 'architectury-plugin'
apply plugin: 'maven-publish'
//apply plugin: 'io.github.p03w.machete'

group = 'coffee.waffle'
archivesBaseName = "emcutils-$project.name-$mcVer"
Expand Down
4 changes: 2 additions & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependencies {
modImplementation libs.quilt.loader
modImplementation libs.fabric.loader
}

architectury.common 'quilt', 'forge'
architectury.common 'fabric', 'forge'

loom.accessWidenerPath.set file('src/main/resources/emcutils.accesswidener')
1 change: 0 additions & 1 deletion common/gradle.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.List;
import java.util.Objects;

import static coffee.waffle.emcutils.Util.LOG;

Expand Down Expand Up @@ -80,7 +81,7 @@ public static List<EmpireResidence> getAllResidences() {
}

public void sendToServer() {
MinecraftClient.getInstance().player.networkHandler.sendCommand(command);
Objects.requireNonNull(MinecraftClient.getInstance().getNetworkHandler()).sendCommand(command);
Util.setCurrentServer(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

public interface ChatCallback {
Event<ChatCallback> POST_RECEIVE_MESSAGE = new Event<>(ChatCallback.class,
(listeners) -> (player, text) -> {
(listeners) -> (text) -> {
for (ChatCallback listener : listeners) {
ActionResult result = listener.onPostReceiveMessage(player, text);
ActionResult result = listener.onPostReceiveMessage(text);

if (result != ActionResult.PASS) {
return result;
Expand All @@ -19,5 +19,5 @@ public interface ChatCallback {
}
);

ActionResult onPostReceiveMessage(ClientPlayerEntity player, Text message);
ActionResult onPostReceiveMessage(Text message);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
@FunctionalInterface
public interface CommandCallback {
Event<CommandCallback> PRE_EXECUTE_COMMAND = new Event<>(CommandCallback.class,
(listeners) -> (player, command, args) -> {
(listeners) -> (command, args) -> {
for (CommandCallback listener : listeners) {
ActionResult result = listener.onPreExecuteCommand(player, command, args);
ActionResult result = listener.onPreExecuteCommand(command, args);

if (result != ActionResult.PASS) {
return result;
Expand All @@ -21,5 +21,5 @@ public interface CommandCallback {
}
);

ActionResult onPreExecuteCommand(ClientPlayerEntity player, String command, List<String> args);
ActionResult onPreExecuteCommand(String command, List<String> args);
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static long getSecondsUntilUsable(ItemStack item) {
if (useTimerLine == -1) return 0L;

long time = JsonParser.parseString(originalLore.get(useTimerLine + 1).getAsString())
.getAsJsonObject().getAsJsonArray("extra").get(0).getAsJsonObject().get("text").getAsLong();
.getAsJsonObject().get("text").getAsLong();

return Math.max(0, (time - System.currentTimeMillis()) / 1000L);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import net.minecraft.util.Identifier;
import org.apache.commons.lang3.math.NumberUtils;

import java.util.UUID;

import static coffee.waffle.emcutils.Util.id;
import static coffee.waffle.emcutils.Util.plural;

Expand Down Expand Up @@ -58,7 +60,7 @@ private ItemStack getHead(int amount, boolean positive) {
"NWYxMzNlOTE5MTlkYjBhY2VmZGMyNzJkNjdmZDg3YjRiZTg4ZGM0NGE5NTg5NTg4MjQ0NzRlMjFlMDZkNTNlNi") + "J9fX0=";

stack.setCustomName(formattedText(String.format("Go %s %s page%s", positive ? "forward" : "back", amount, plural(amount))));
GameProfile profile = new GameProfile(null, "MrFrydae");
GameProfile profile = new GameProfile(UUID.fromString("1635371d-8f8b-4a90-8495-4e7df6c946b2"), "MrFrydae");
profile.getProperties().put("textures", new Property("Value", head));

assert stack.getNbt() != null;
Expand All @@ -69,7 +71,7 @@ private ItemStack getHead(int amount, boolean positive) {

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
this.renderBackground(context);
this.renderBackground(context, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);

for (int i = 4; i > 0; i--) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import coffee.waffle.emcutils.Util;
import coffee.waffle.emcutils.event.ChatCallback;
import coffee.waffle.emcutils.feature.ChatChannels;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;
import net.minecraft.util.ActionResult;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ChatListener {
private static final String WELCOME_TO_EMC = "Welcome to Empire Minecraft - .*, .*!\n?";
Expand All @@ -26,7 +25,7 @@ public static void init() {
ChatCallback.POST_RECEIVE_MESSAGE.register(ChatListener::handlePrivateMessageStart);
}

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

Expand All @@ -39,7 +38,7 @@ private static ActionResult handlePrivateMessageStart(ClientPlayerEntity player,
return ActionResult.PASS;
}

private static ActionResult handleChatChannelChange(ClientPlayerEntity player, 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());

Expand All @@ -52,7 +51,7 @@ private static ActionResult handleChatChannelChange(ClientPlayerEntity player, T
return ActionResult.PASS;
}

private static ActionResult initialServerInfo(ClientPlayerEntity player, 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
Expand All @@ -67,7 +66,7 @@ private static ActionResult initialServerInfo(ClientPlayerEntity player, Text te
if (group != null) Util.playerGroupId = getGroupIdFromColor(group);

if (Util.onJoinCommand != null) {
player.networkHandler.sendCommand(Util.onJoinCommand);
MinecraftClient.getInstance().getNetworkHandler().sendCommand(Util.onJoinCommand);
Util.onJoinCommand = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import coffee.waffle.emcutils.event.CommandCallback;
import coffee.waffle.emcutils.feature.VisitResidenceHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.util.ActionResult;
import org.apache.commons.lang3.math.NumberUtils;

Expand All @@ -17,7 +16,7 @@ public static void init() {
CommandCallback.PRE_EXECUTE_COMMAND.register(CommandListener::handleResidenceHomeCommand);
}

private static ActionResult handleResidenceHomeCommand(ClientPlayerEntity player, String command, List<String> args) {
private static ActionResult handleResidenceHomeCommand(String command, List<String> args) {
if (!command.equalsIgnoreCase("home")) {
return ActionResult.PASS;
}
Expand All @@ -38,12 +37,12 @@ private static ActionResult handleResidenceHomeCommand(ClientPlayerEntity player
}
}

String resName = MinecraftClient.getInstance().player.getEntityName() + (num > 1 ? "-" + num : "");
String resName = MinecraftClient.getInstance().player.getName().getLiteralString() + (num > 1 ? "-" + num : "");

return handleResCommandsCommon(resName, loc);
}

private static ActionResult handleResidenceVisitCommand(ClientPlayerEntity player, String command, List<String> args) {
private static ActionResult handleResidenceVisitCommand(String command, List<String> args) {
if (!(command.equalsIgnoreCase("v") || command.equalsIgnoreCase("visit")) || args.isEmpty()) {
return ActionResult.PASS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
import net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -28,18 +26,17 @@

@Mixin(ClientPlayNetworkHandler.class)
abstract class ClientPlayNetworkHandlerMixin {
@Shadow @Final private MinecraftClient client;
@Unique private boolean emcutils$online = false;

@Inject(at = @At("HEAD"), method = "sendChatCommand")
void emcutils$onPreExecuteCommand(String message, CallbackInfo info) {
String[] parts = message.split(" ");
CommandCallback.PRE_EXECUTE_COMMAND.invoker().onPreExecuteCommand(client.player, parts[0], parts.length > 1 ? Arrays.stream(parts, 1, parts.length).toList() : Lists.newArrayList());
CommandCallback.PRE_EXECUTE_COMMAND.invoker().onPreExecuteCommand(parts[0], parts.length > 1 ? Arrays.stream(parts, 1, parts.length).toList() : Lists.newArrayList());
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/message/MessageHandler;onGameMessage(Lnet/minecraft/text/Text;Z)V", shift = At.Shift.AFTER), method = "onGameMessage")
void emcutils$onPostReceiveMessage(GameMessageS2CPacket packet, CallbackInfo info) {
ChatCallback.POST_RECEIVE_MESSAGE.invoker().onPostReceiveMessage(client.player, packet.content());
ChatCallback.POST_RECEIVE_MESSAGE.invoker().onPostReceiveMessage(packet.content());
}

@Inject(at = @At("TAIL"), method = "onGameJoin")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import coffee.waffle.emcutils.Util;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.multiplayer.ConnectScreen;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.network.ServerInfo;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
7 changes: 3 additions & 4 deletions quilt/build.gradle → fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
plugins {
alias libs.plugins.minotaur
alias libs.plugins.shadow
alias libs.plugins.loom.quiltflower
}

apply from: '../gradle/loader.gradle'
apply from: '../gradle/quilt-based.gradle'
apply from: '../gradle/fabric-based.gradle'

architectury.loader 'quilt'
architectury.loader 'fabric'

File commonAW = project ':common' file 'src/main/resources/emcutils.accesswidener'
File generatedResources = file 'src/generated/resources'

configurations {
developmentQuilt.extendsFrom common
developmentFabric.extendsFrom common
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package coffee.waffle.emcutils.fabric;

import coffee.waffle.emcutils.Util;
import coffee.waffle.emcutils.event.TooltipCallback;
import coffee.waffle.emcutils.feature.VaultScreen;
import eu.midnightdust.lib.config.MidnightConfig;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.client.gui.screen.ingame.HandledScreens;

import static coffee.waffle.emcutils.Util.LOG;
import static coffee.waffle.emcutils.Util.MODID;
import static coffee.waffle.emcutils.Util.id;
import static net.fabricmc.fabric.api.resource.ResourcePackActivationType.NORMAL;

public class EMCUtilsFabric implements ClientModInitializer {

@Override
public void onInitializeClient() {
MidnightConfig.init(MODID, ConfigImpl.class);

ModContainer mod = FabricLoader.getInstance().getModContainer(MODID).get();

// These don't work in dev for whatever reason, but work in prod
ResourceManagerHelper.registerBuiltinResourcePack(id("dark-ui-vault"), mod, NORMAL);
ResourceManagerHelper.registerBuiltinResourcePack(id("vt-dark-vault"), mod, NORMAL);

Util.runResidenceCollector();

HandledScreens.register(VaultScreen.GENERIC_9X7, VaultScreen::new);

ItemTooltipCallback.EVENT.register((stack, context, lines) -> {
TooltipCallback.ITEM.invoker().append(stack, lines, context);
});

LOG.info("Initialized " + MODID);
}
}
Loading

0 comments on commit e109874

Please sign in to comment.