This file was deleted.

Expand Up @@ -26,15 +26,17 @@
package dev.frydae.emcutils.mixins;

import dev.frydae.emcutils.EmpireMinecraftUtilities;
import dev.frydae.emcutils.interfaces.ChatCallback;
import dev.frydae.emcutils.features.ChatChannels;
import dev.frydae.emcutils.features.VaultButtons;
import dev.frydae.emcutils.features.VaultScreen;
import dev.frydae.emcutils.interfaces.ChatCallback;
import dev.frydae.emcutils.utils.Util;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.HandledScreens;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
import net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.util.ActionResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -69,8 +71,13 @@ public void onGameJoin(GameJoinS2CPacket packet, CallbackInfo info) {
}
}

@Inject(at = @At("INVOKE"), method = "onOpenScreen", cancellable = true)
@Inject(at = @At("HEAD"), method = "onOpenScreen", cancellable = true)
public void onOpenScreen(OpenScreenS2CPacket packet, CallbackInfo ci) {
VaultButtons.handleScreenOpen(packet, ci);
if (Util.isOnEMC) {
if (!packet.getName().getString().startsWith("Page: ")) return;
if (packet.getScreenHandlerType() != ScreenHandlerType.GENERIC_9X6) return;
HandledScreens.open(VaultScreen.GENERIC_9X7, MinecraftClient.getInstance(), packet.getSyncId(), packet.getName());
ci.cancel();
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/dev/frydae/emcutils/mixins/EMCMixinPlugin.java
Expand Up @@ -37,9 +37,9 @@
public class EMCMixinPlugin implements IMixinConfigPlugin {
@Override
public boolean shouldApplyMixin(@NotNull String targetClassName, String mixinClassName) {
if (targetClassName.contains("com.mamiyaotaru")) return FabricLoader.getInstance().isModLoaded("voxelmap");
else if (targetClassName.contains("xaero")) return FabricLoader.getInstance().isModLoaded("xaerosworldmap");
else return true;
if (mixinClassName.contains("voxelMap")) return FabricLoader.getInstance().isModLoaded("voxelmap");
if (mixinClassName.contains("xaero")) return FabricLoader.getInstance().isModLoaded("xaeroworldmap");
return true;
}

@Override public void onLoad(String mixinPackage) {}
Expand Down
Expand Up @@ -25,7 +25,7 @@

package dev.frydae.emcutils.mixins;

import dev.frydae.emcutils.features.vaultButtons.VaultScreen;
import dev.frydae.emcutils.features.VaultScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.option.KeyBinding;
Expand All @@ -44,7 +44,7 @@ public abstract class MinecraftClientMixin {
@Shadow
private Window window;

@Inject(at = @At("INVOKE"), method = "setScreen", cancellable = true)
@Inject(method = "setScreen", at = @At("HEAD"), cancellable = true)
public void onOpenScreen(@Nullable Screen screen, CallbackInfo ci) {
if (!(screen instanceof VaultScreen)) {
return;
Expand Down
Expand Up @@ -42,7 +42,7 @@ public abstract class GuiWaypointsMixin {

protected Waypoint selectedWaypoint;

@Inject(method = "teleportClicked", at = @At("INVOKE"), remap = false, cancellable = true)
@Inject(method = "teleportClicked", at = @At("HEAD"), remap = false, cancellable = true)
public void handleTeleport(CallbackInfo ci) {
if (Util.isOnEMC) {
Vec3d pos = new Vec3d(selectedWaypoint.getX(), selectedWaypoint.getY(), selectedWaypoint.getZ());
Expand Down
Expand Up @@ -25,6 +25,8 @@

package dev.frydae.emcutils.mixins.xaero;

public abstract class GuiMapNameMixin {}
/*
import dev.frydae.emcutils.utils.Util;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
Expand All @@ -39,8 +41,10 @@
public abstract class GuiMapNameMixin {
@Shadow(remap = false) private String currentNameFieldContent;
@Inject(method = "init()V", at = @At(value = "INVOKE"), remap = false, cancellable = true)
FIXME: This is currently broken to all hell and crashes the game and I have absolutely zero clue why
@Inject(method = "init()V", at = @At(value = "HEAD"), remap = false)
public void setSubworldName(CallbackInfo ci) {
if (Util.isOnEMC) this.currentNameFieldContent = Util.getCurrentServer().getName().toLowerCase() + " - " + Util.getWorld();
}
}
*/
Expand Up @@ -27,86 +27,22 @@

import dev.frydae.emcutils.utils.Util;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import xaero.common.settings.ModSettings;

import static xaero.common.settings.ModSettings.serverSettings;

/**
* A set of Overwrites into Xaero's configs. These are safe to do
* because no other mod that I could find mixins into this class.
*/
@Pseudo
@Mixin(ModSettings.class)
public class ModSettingsMixin {
/**
* @reason Force cave maps off on EMC
* @author wafflecoffee
*/
@Overwrite(remap = false)
public boolean caveMapsDisabled() {
if (Util.isOnEMC) return true;
else return (serverSettings & 16384) != 16384;
}

/**
* @reason Force radars off on EMC
* @author wafflecoffee
*/
@Overwrite(remap = false)
public boolean minimapDisplayPlayersDisabled() {
if (Util.isOnEMC) return true;
else return (serverSettings & 1024) != 1024;
}

/**
* @reason Force radars off on EMC
* @author wafflecoffee
*/
@Overwrite(remap = false)
public boolean minimapDisplayMobsDisabled() {
if (Util.isOnEMC) return true;
else return (serverSettings & 2048) != 2048;
}

/**
* @reason Force radars off on EMC
* @author wafflecoffee
*/
@Overwrite(remap = false)
public boolean minimapDisplayItemsDisabled() {
if (Util.isOnEMC) return true;
else return (serverSettings & 4096) != 4096;
}

/**
* @reason Force radars off on EMC
* @author wafflecoffee
*/
@Overwrite(remap = false)
public boolean minimapDisplayOtherDisabled() {
if (Util.isOnEMC) return true;
else return (serverSettings & 8192) != 8192;
}

/**
* @reason Force radars off on EMC
* @author wafflecoffee
*/
@Overwrite(remap = false)
public boolean showOtherTeamDisabled() {
if (Util.isOnEMC) return true;
else return (serverSettings & '耀') != 32768;
public abstract class ModSettingsMixin {
@Inject(method = "caveMapsDisabled", at = @At("HEAD"), cancellable = true, remap = false)
private void disableCaveMapsOnEMC(CallbackInfoReturnable<Boolean> cir) {
if (Util.isOnEMC) cir.setReturnValue(true);
}

/**
* @reason Force radars off on EMC
* @author wafflecoffee
*/
@Overwrite(remap = false)
private boolean minimapDisplayTamedMobsDisabled() {
if (Util.isOnEMC) return true;
else return (serverSettings & 16777216) == 0;
@Inject(method = "getEntityRadar", at = @At("HEAD"), cancellable = true, remap = false)
private void disableRadarOnEMC(CallbackInfoReturnable<Boolean> cir) {
if (Util.isOnEMC) cir.setReturnValue(false);
}
}
Expand Up @@ -30,12 +30,12 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.Shadow;
import xaero.common.XaeroMinimapSession;
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.WaypointWorld;
import xaero.common.minimap.waypoints.WaypointsManager;
import xaero.map.mods.SupportXaeroMinimap;
import xaero.map.mods.gui.Waypoint;

Expand All @@ -44,28 +44,15 @@
public abstract class SupportXaeroMinimapMixin {
@Shadow(remap = false) private WaypointWorld waypointWorld;

/**
* @reason Change teleport behaviour on EMC. This is safe to do because no other mod that I could find mixins into
* this class.
* @author wafflecoffee
*/
@Overwrite(remap = false)
public void teleportToWaypoint(Screen screen, Waypoint w) {
if (this.waypointWorld != null) {
XaeroMinimapSession minimapSession = XaeroMinimapSession.getCurrentSession();
WaypointsManager waypointsManager = minimapSession.getWaypointsManager();
@Inject(method = "teleportToWaypoint(Lnet/minecraft/client/gui/screen/Screen;Lxaero/map/mods/gui/Waypoint;)V", at = @At("HEAD"))
public void teleportToResidenceOnEMC(Screen screen, Waypoint w, CallbackInfo ci) {
if (waypointWorld != null) {
if (Util.isOnEMC) {
int x = w != null ? w.getX() : 1;
int z = w != null ? w.getZ() : 1;

Vec3d pos = new Vec3d(x, 64, z);

EmpireResidence res = Util.getCurrentServer().getResidenceByLoc(pos);
EmpireResidence res = Util.getCurrentServer().getResidenceByLoc(
new Vec3d(w.getX(), 64, w.getZ())
);

if (res != null) Util.getPlayer().sendChatMessage(res.getVisitCommand());

} else {
waypointsManager.teleportToWaypoint((xaero.common.minimap.waypoints.Waypoint) w.getOriginal(), this.waypointWorld, screen);
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/dev/frydae/emcutils/utils/Util.java
Expand Up @@ -228,18 +228,12 @@ public static void runResidenceCollector() {
}

public static void hasVoxelMap() {
try {
Class.forName("com.mamiyaotaru.voxelmap.VoxelMap");
LogManager.getLogger(MODID).info(MODID + " found VoxelMap - enabling integrations");
hasVoxelMap = true;
} catch (ClassNotFoundException ignored) {}
LogManager.getLogger(MODID).info(MODID + " found VoxelMap - enabling integrations");
hasVoxelMap = true;
}

public static void hasXaeroMap() {
try {
Class.forName("xaero.common.settings.ModSettings");
LogManager.getLogger(MODID).info(MODID + " found Xaero's World Map - enabling integrations");
hasXaeroMap = true;
} catch (ClassNotFoundException ignored) {}
LogManager.getLogger(MODID).info(MODID + " found Xaero's World Map - enabling integrations");
hasXaeroMap = true;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/assets/emcutils/lang/en_us.json
Expand Up @@ -18,5 +18,5 @@
"emcutils.midnightconfig.enum.ChatAlertSound.NOTE_PLING": "Note pling",
"emcutils.midnightconfig.enum.ChatAlertSound.ITEM_PICKUP": "Level up",
"emcutils.midnightconfig.dontRunResidenceCollector": "Don't run residence collector",
"emcutils.midnightconfig.dontRunResidenceCollector.tooltip": "The following config option can be enabled if you're running \n on a very slow connection to prevent spam in the console.\n Note, though, that this will disable cross-server visit \n command integration and VoxelMap integration."
"emcutils.midnightconfig.dontRunResidenceCollector.tooltip": "The following config option can be enabled if you're running \n on a very slow connection to prevent spam in the console.\n Note, though, that this will disable cross-server visit \n command integration and minimap integration."
}
9 changes: 0 additions & 9 deletions src/main/resources/emcutils.aw

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/emcutils.mixins.json
Expand Up @@ -17,7 +17,6 @@
"voxelMap.GuiPersistentMapMixin",
"voxelMap.GuiWaypointsMixin",
"voxelMap.VoxelMapMixin",
"xaero.GuiMapNameMixin",
"xaero.ModSettingsMixin",
"xaero.SupportXaeroMinimapMixin"
],
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/emcutils.tsv
@@ -0,0 +1,10 @@
accessWidener v1 named

accessible class net/minecraft/screen/ScreenHandlerType$Factory
accessible class net/minecraft/client/gui/screen/ingame/HandledScreens$Provider

extendable method net/minecraft/screen/ScreenHandlerType <init> (Lnet/minecraft/screen/ScreenHandlerType$Factory;)V
accessible method net/minecraft/screen/ScreenHandlerType register (Ljava/lang/String;Lnet/minecraft/screen/ScreenHandlerType$Factory;)Lnet/minecraft/screen/ScreenHandlerType;
accessible method net/minecraft/client/gui/screen/ingame/HandledScreens register (Lnet/minecraft/screen/ScreenHandlerType;Lnet/minecraft/client/gui/screen/ingame/HandledScreens$Provider;)V
accessible method net/minecraft/client/gui/screen/ingame/HandledScreen drawItem (Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V
accessible method net/minecraft/screen/GenericContainerScreenHandler <init> (Lnet/minecraft/screen/ScreenHandlerType;ILnet/minecraft/entity/player/PlayerInventory;I)V
19 changes: 10 additions & 9 deletions src/main/resources/fabric.mod.json
@@ -1,22 +1,22 @@
{
"schemaVersion": 1,
"id": "emcutils",
"version": "2.3.0",
"version": "2.3.1",
"name": "Empire Minecraft Utilities",
"description": "A collection of various utilities for the Empire Minecraft server.",
"authors": [
"MrFrydae"
"MrFrydae",
"wafflecoffee"
],
"contributors": [
"wafflecoffee",
"BlockHead_56"
],
"contact": {
"homepage": "https://emc.gs/t/84361",
"homepage": "https://emc.gs/t/84930",
"sources": "https://github.com/wafflecoffee/Empire-Minecraft-Utilities",
"issues": "https://github.com/wafflecoffee/Empire-Minecraft-Utilities/issues"
},
"accessWidener": "emcutils.aw",
"accessWidener": "emcutils.tsv",
"license": "MIT",
"icon": "assets/emcutils/icon.png",
"environment": "client",
Expand All @@ -32,15 +32,16 @@
"emcutils.mixins.json"
],
"depends": {
"fabricloader": ">=0.12.4",
"fabric-api-base": "*",
"fabric-item-api-v1": "*",
"fabric-networking-api-v1": "*",
"minecraft": "~1.17.1"
"minecraft": ">=1.17.1"
},
"suggests": {
"modmenu": ">=2.0.9",
"modmenu": ">=2.0.14",
"voxelmap": ">=1.10.15",
"xaeroworldmap": ">=1.17.0",
"xaerominimap": ">=21.16.0"
"xaeroworldmap": ">=1.18.0",
"xaerominimap": ">=21.20.0"
}
}