From e3c6d46b1c071bdb831e4fbb7dcc88251599a26b Mon Sep 17 00:00:00 2001 From: Deftu Date: Sat, 28 Dec 2024 15:34:55 +0200 Subject: [PATCH] Finish porting to Legacy Fabric (aside from ASM) --- build.gradle.kts | 2 +- .../java/org/polyfrost/hytils/HytilsReborn.java | 13 +++++++++++++ .../polyfrost/hytils/forge/HytilsMixinPlugin.java | 2 +- .../hytils/handlers/general/AutoStart.java | 9 +++------ .../mixin/RenderEntityItemMixin_UHCOverlay.java | 10 +++++++++- src/main/resources/fabric.mod.json | 2 +- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 887358d..f5f801e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,7 +20,7 @@ preprocess { toolkitLoomHelper { // Adds OneConfig to our project - useOneConfig("1.1.0-alpha.34", "1.0.0-alpha.46", mcData, "commands", "config-impl", "events", "hud", "internal", "ui") + useOneConfig("1.1.0-alpha.34", "1.0.0-alpha.47", mcData, "commands", "config-impl", "events", "hud", "internal", "ui") useDevAuth() // Removes the server configs from IntelliJ IDEA, leaving only client runs. diff --git a/src/main/java/org/polyfrost/hytils/HytilsReborn.java b/src/main/java/org/polyfrost/hytils/HytilsReborn.java index 91e4fd7..ebd7491 100644 --- a/src/main/java/org/polyfrost/hytils/HytilsReborn.java +++ b/src/main/java/org/polyfrost/hytils/HytilsReborn.java @@ -25,6 +25,8 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; //#else //$$ import net.fabricmc.api.ClientModInitializer; +//$$ import net.fabricmc.loader.api.FabricLoader; +//$$ import net.fabricmc.loader.api.entrypoint.EntrypointContainer; //#endif import org.polyfrost.oneconfig.api.event.v1.EventManager; @@ -111,6 +113,17 @@ public class HytilsReborn private RankType rank; private void initialize() { + //#if FABRIC + //$$ INSTANCE = FabricLoader.getInstance() + //$$ .getEntrypointContainers("client", ClientModInitializer.class) + //$$ .stream() + //$$ .map(EntrypointContainer::getEntrypoint) + //$$ .filter(HytilsReborn.class::isInstance) + //$$ .map(HytilsReborn.class::cast) + //$$ .findFirst() + //$$ .orElseThrow(() -> new IllegalStateException("Could not find HytilsReborn entrypoint")); + //#endif + config = new HytilsConfig(); CommandManager.registerCommand(new HousingVisitCommand()); diff --git a/src/main/java/org/polyfrost/hytils/forge/HytilsMixinPlugin.java b/src/main/java/org/polyfrost/hytils/forge/HytilsMixinPlugin.java index 2b665e1..1649c28 100644 --- a/src/main/java/org/polyfrost/hytils/forge/HytilsMixinPlugin.java +++ b/src/main/java/org/polyfrost/hytils/forge/HytilsMixinPlugin.java @@ -132,7 +132,7 @@ public void postApply( private String mapMethodNameFromNode(AbstractInsnNode node) { MethodInsnNode methodInsnNode = (MethodInsnNode) node; - return FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(methodInsnNode.owner, methodInsnNode.name, methodInsnNode.desc); + return DeobfuscationRemapper.INSTANCE.mapMethodName(methodInsnNode.owner, methodInsnNode.name, methodInsnNode.desc); } private InsnList modifyName() { diff --git a/src/main/java/org/polyfrost/hytils/handlers/general/AutoStart.java b/src/main/java/org/polyfrost/hytils/handlers/general/AutoStart.java index 7f32313..a78ae80 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/general/AutoStart.java +++ b/src/main/java/org/polyfrost/hytils/handlers/general/AutoStart.java @@ -22,11 +22,11 @@ import org.polyfrost.hytils.config.HytilsConfig; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiMainMenu; -import net.minecraft.client.gui.GuiMultiplayer; -import net.minecraft.client.multiplayer.ServerData; import org.polyfrost.oneconfig.api.event.v1.EventManager; import org.polyfrost.oneconfig.api.event.v1.events.TickEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; +import org.polyfrost.oneconfig.api.platform.v1.Platform; +import org.polyfrost.oneconfig.api.platform.v1.PlayerPlatform; public class AutoStart { @@ -34,10 +34,7 @@ public class AutoStart { public void tick(TickEvent event) { if (Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu && HytilsReborn.INSTANCE.isLoadedCall()) { if (HytilsConfig.autoStart) { - FMLClientHandler.instance().connectToServer( - new GuiMultiplayer(Minecraft.getMinecraft().currentScreen), - new ServerData("hypixel", "hypixel.net", false) - ); // TODO + Platform.player().joinServer(new PlayerPlatform.Server("hypixel", "hypixel.net")); } HytilsReborn.INSTANCE.setLoadedCall(false); diff --git a/src/main/java/org/polyfrost/hytils/mixin/RenderEntityItemMixin_UHCOverlay.java b/src/main/java/org/polyfrost/hytils/mixin/RenderEntityItemMixin_UHCOverlay.java index ea2dd0a..f0cbacc 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/RenderEntityItemMixin_UHCOverlay.java +++ b/src/main/java/org/polyfrost/hytils/mixin/RenderEntityItemMixin_UHCOverlay.java @@ -19,6 +19,7 @@ package org.polyfrost.hytils.mixin; import net.hypixel.data.type.GameType; +import net.minecraft.init.Items; import org.polyfrost.hytils.config.HytilsConfig; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderEntityItem; @@ -38,7 +39,14 @@ public class RenderEntityItemMixin_UHCOverlay { Item item = entity.getEntityItem().getItem(); GameType gameType = HypixelUtils.getLocation().getGameType().orElse(null); if (HypixelUtils.isHypixel() && (gameType == GameType.UHC || gameType == GameType.SPEED_UHC) && HytilsConfig.uhcOverlay) { - if (item.getRegistryName().equals("minecraft:apple") || item.getRegistryName().equals("minecraft:golden_apple") || item.getRegistryName().equals("minecraft:skull") || item.getRegistryName().equals("minecraft:gold_ingot") || item.getRegistryName().equals("minecraft:gold_nugget")) { + int itemId = Item.getIdFromItem(item); + if ( + itemId == 260 || + itemId == 322 || + itemId == 397 || + itemId == 266 || + itemId == 371 + ) { GlStateManager.scale(HytilsConfig.uhcOverlayMultiplier, HytilsConfig.uhcOverlayMultiplier, HytilsConfig.uhcOverlayMultiplier); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0de350e..68c5d45 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -21,7 +21,7 @@ ] }, "mixins": [ - "mixins.${mod_id}.json" + "mixins.hytils.json" ], "depends": { "fabricloader": ">=0.15.11",