From e37b1e7cf62ab6d4fef4eb0c59b1f3ca15584e11 Mon Sep 17 00:00:00 2001 From: ev chang Date: Wed, 1 Jan 2025 15:28:50 +0900 Subject: [PATCH] fabric port --- gradle.properties | 2 +- .../org/polyfrost/example/ExampleMod.java | 18 ++++++------- ...ftMixin.java => MinecraftClientMixin.java} | 6 ++--- src/main/resources/fabric.mod.json | 25 +++++++++++++++++++ src/main/resources/mcmod.info | 18 ------------- src/main/resources/mixins.examplemod.json | 2 +- 6 files changed, 39 insertions(+), 32 deletions(-) rename src/main/java/org/polyfrost/example/mixin/{MinecraftMixin.java => MinecraftClientMixin.java} (83%) create mode 100644 src/main/resources/fabric.mod.json delete mode 100644 src/main/resources/mcmod.info diff --git a/gradle.properties b/gradle.properties index 0ddc67f..f4f7697 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ mod.version=1.0.0 mod.group=org.polyfrost # Configures the mod loader that we're developing for. -loom.platform=forge +loom.platform=fabric # Configures the Minecraft version that we're developing for. minecraft.version=1.8.9 diff --git a/src/main/java/org/polyfrost/example/ExampleMod.java b/src/main/java/org/polyfrost/example/ExampleMod.java index 3602126..7cddc61 100644 --- a/src/main/java/org/polyfrost/example/ExampleMod.java +++ b/src/main/java/org/polyfrost/example/ExampleMod.java @@ -1,33 +1,34 @@ package org.polyfrost.example; +import net.fabricmc.api.ClientModInitializer; import org.polyfrost.example.command.ExampleCommand; import org.polyfrost.example.config.ExampleConfig; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; import org.polyfrost.oneconfig.api.commands.v1.CommandManager; /** * The entrypoint of the Example Mod which initializes it. * This is what is run when the game is started and typically how your mod will set up its functionality. * - * @see Mod + * @see ClientModInitializer */ -@Mod(modid = ExampleMod.ID, name = ExampleMod.NAME, version = ExampleMod.VERSION) -public class ExampleMod { +public class ExampleMod implements ClientModInitializer { // Sets the variables from `gradle.properties`. Depends on the `bloom` DGT plugin. public static final String ID = "@MOD_ID@"; public static final String NAME = "@MOD_NAME@"; public static final String VERSION = "@MOD_VERSION@"; - @Mod.Instance(ID) public static ExampleMod INSTANCE; // Adds the instance of the mod, so we can access other variables. private static ExampleConfig config; + public ExampleMod() { + INSTANCE = this; + } + // Register the config and commands. - @Mod.EventHandler - public void onInit(FMLInitializationEvent event) { + @Override + public void onInitializeClient() { config = new ExampleConfig(); CommandManager.registerCommand(new ExampleCommand()); } @@ -35,5 +36,4 @@ public void onInit(FMLInitializationEvent event) { public static ExampleConfig getConfig() { return config; } - } diff --git a/src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java b/src/main/java/org/polyfrost/example/mixin/MinecraftClientMixin.java similarity index 83% rename from src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java rename to src/main/java/org/polyfrost/example/mixin/MinecraftClientMixin.java index b109546..cf5ddea 100644 --- a/src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java +++ b/src/main/java/org/polyfrost/example/mixin/MinecraftClientMixin.java @@ -1,6 +1,6 @@ package org.polyfrost.example.mixin; -import net.minecraft.client.Minecraft; +import net.minecraft.client.MinecraftClient; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,8 +12,8 @@ * @see Mixin * @see Inject */ -@Mixin(Minecraft.class) -public class MinecraftMixin { +@Mixin(MinecraftClient.class) +public class MinecraftClientMixin { @Inject(method = "", at = @At(value = "RETURN")) private void examplemod$onStartGame(CallbackInfo ci) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..e789dcc --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,25 @@ +{ + "schemaVersion": 1, + "id": "${mod_id}", + "version": "${mod_version}", + "name": "${mod_name}", + "description": "${mod_description}", + "authors": [ + "Polyfrost" + ], + "environment": "*", + "entrypoints": { + "client": [ + { + "value": "org.polyfrost.example.ExampleMod" + } + ] + }, + "mixins": [ + "mixins.${mod_id}.json" + ], + "depends": { + "minecraft": "~${minor_mc_version}", + "fabricloader": ">=0.15.11" + } +} \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info deleted file mode 100644 index 76001f3..0000000 --- a/src/main/resources/mcmod.info +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "modid": "${mod_id}", - "name": "${mod_name}", - "description": "", - "version": "${mod_version}", - "mcversion": "${mc_version}", - "url": "", - "updateUrl": "", - "authorList": [ - "Your Name" - ], - "credits": "", - "logoFile": "", - "screenshots": [], - "dependencies": [] - } -] \ No newline at end of file diff --git a/src/main/resources/mixins.examplemod.json b/src/main/resources/mixins.examplemod.json index 8a18b95..baeb0d5 100644 --- a/src/main/resources/mixins.examplemod.json +++ b/src/main/resources/mixins.examplemod.json @@ -7,7 +7,7 @@ "maxShiftBy": 5 }, "client": [ - "MinecraftMixin" + "MinecraftClientMixin" ], "verbose": true }