From ba875c2a7c6ec064a1dcde171cd8996ae58e5c28 Mon Sep 17 00:00:00 2001 From: TexTrue <3140846162@qq.com> Date: Thu, 23 May 2024 19:45:48 +0800 Subject: [PATCH] update MaFgLib version --- CHANGELOG.md | 2 +- gradle.properties | 4 +-- .../fi/dy/masa/itemscroller/ItemScroller.java | 18 ++-------- .../mixin/MixinForgeHooksClient.java | 20 ----------- .../rocknroller/RocknRoller.java | 34 +++++++++++++++++++ src/main/resources/rocknroller.mixins.json | 1 - 6 files changed, 40 insertions(+), 39 deletions(-) delete mode 100644 src/main/java/fi/dy/masa/itemscroller/mixin/MixinForgeHooksClient.java create mode 100644 src/main/java/org/thinkingstudio/rocknroller/RocknRoller.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 6774f07..7e57227 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,2 @@ ## Change -- update Forge & MaFgLib version \ No newline at end of file +- update MaFgLib version \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 4ab0583..391cbaa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ loom.platform=forge yarn_mappings=1.19.2+build.28 # Mod Properties - mod_version=0.1.3 + mod_version=0.1.4 maven_group=org.thinkingstudio.rocknroller archives_base_name=RocknRoller mod_id=rocknroller @@ -21,4 +21,4 @@ loom.platform=forge curseforge_id=916852 # Dependencies - malilib_version=0.1.10-mc1.19.2 \ No newline at end of file + malilib_version=0.1.12-mc1.19.2 \ No newline at end of file diff --git a/src/main/java/fi/dy/masa/itemscroller/ItemScroller.java b/src/main/java/fi/dy/masa/itemscroller/ItemScroller.java index c9193ee..fae816d 100644 --- a/src/main/java/fi/dy/masa/itemscroller/ItemScroller.java +++ b/src/main/java/fi/dy/masa/itemscroller/ItemScroller.java @@ -1,26 +1,14 @@ package fi.dy.masa.itemscroller; -import fi.dy.masa.itemscroller.gui.GuiConfigs; -import fi.dy.masa.malilib.compat.forge.ForgePlatformUtils; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.loading.FMLLoader; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import fi.dy.masa.malilib.event.InitializationHandler; -@Mod(Reference.MOD_ID) public class ItemScroller { public static final Logger logger = LogManager.getLogger(Reference.MOD_ID); - public ItemScroller() { - if (FMLLoader.getDist().isClient()) { - ForgePlatformUtils.getInstance().getClientModIgnoredServerOnly(); - InitializationHandler.getInstance().registerInitializationHandler(new InitHandler()); - ForgePlatformUtils.getInstance().getMod(Reference.MOD_ID).registerModConfigScreen((screen) -> { - GuiConfigs gui = new GuiConfigs(); - gui.setParent(screen); - return gui; - }); - } + public static void onInitialize() + { + InitializationHandler.getInstance().registerInitializationHandler(new InitHandler()); } } diff --git a/src/main/java/fi/dy/masa/itemscroller/mixin/MixinForgeHooksClient.java b/src/main/java/fi/dy/masa/itemscroller/mixin/MixinForgeHooksClient.java deleted file mode 100644 index e05e58e..0000000 --- a/src/main/java/fi/dy/masa/itemscroller/mixin/MixinForgeHooksClient.java +++ /dev/null @@ -1,20 +0,0 @@ -package fi.dy.masa.itemscroller.mixin; - -import fi.dy.masa.itemscroller.event.RenderEventHandler; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraftforge.client.ForgeHooksClient; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(value = ForgeHooksClient.class, remap = false) -public abstract class MixinForgeHooksClient { - @Inject(method = "drawScreen", at = @At("RETURN")) - private static void onDrawScreenPost(Screen screen, MatrixStack poseStack, int mouseX, int mouseY, float partialTick, CallbackInfo ci) - { - RenderEventHandler.instance().onDrawScreenPost(MinecraftClient.getInstance()); - } -} diff --git a/src/main/java/org/thinkingstudio/rocknroller/RocknRoller.java b/src/main/java/org/thinkingstudio/rocknroller/RocknRoller.java new file mode 100644 index 0000000..be649ad --- /dev/null +++ b/src/main/java/org/thinkingstudio/rocknroller/RocknRoller.java @@ -0,0 +1,34 @@ +package org.thinkingstudio.rocknroller; + +import fi.dy.masa.itemscroller.ItemScroller; +import fi.dy.masa.itemscroller.Reference; +import fi.dy.masa.itemscroller.event.RenderEventHandler; +import fi.dy.masa.itemscroller.gui.GuiConfigs; +import net.minecraftforge.client.event.ScreenEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.loading.FMLLoader; +import org.thinkingstudio.mafglib.util.ForgePlatformUtils; + +@Mod(Reference.MOD_ID) +public class RocknRoller { + public RocknRoller() { + if (FMLLoader.getDist().isClient()) { + // Make sure the mod being absent on the other network side does not cause + // the client to display the server as incompatible + ForgePlatformUtils.getInstance().getClientModIgnoredServerOnly(); + ItemScroller.onInitialize(); + + // Config Screen + ForgePlatformUtils.getInstance().registerModConfigScreen(Reference.MOD_ID, (screen) -> { + GuiConfigs gui = new GuiConfigs(); + gui.setParent(screen); + return gui; + }); + + MinecraftForge.EVENT_BUS.addListener(event -> { + RenderEventHandler.instance().onDrawScreenPost(event.getScreen().getMinecraft()); + }); + } + } +} diff --git a/src/main/resources/rocknroller.mixins.json b/src/main/resources/rocknroller.mixins.json index 7e04730..4be4d54 100644 --- a/src/main/resources/rocknroller.mixins.json +++ b/src/main/resources/rocknroller.mixins.json @@ -11,7 +11,6 @@ "MixinAbstractInventoryScreen", "MixinClientPlayerInteractionManager", "MixinCraftingScreenHandler", - "MixinForgeHooksClient", "MixinMerchantScreen", "MixinMerchantScreenHandler" ],