diff --git a/README.md b/README.md index c78930f..0be1fbe 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,3 @@ -# BTA Example Mod - Babric +# Inventory Pausing - BTA -A simple mod template for Better Than Adventure, yet this template is for Babric. - -Original version: https://github.com/pkstDev/BTAExampleMod - -### Setup (Same as the original one) - -1. Grab a full BTA jar from the MultiMC instance (or anywhere else you want) and rename it to "bta.jar". - -2. Place the jar in the "libs" folder in your project. - -3. Run the following command: -```shell -gradlew build -``` - -4. Start your modding trip! - -### Extra Tips - -Since BTA is distributed without obfuscation, all Mixin classes must set the 'remap' option to false! +Pauses the game when in inventory screen. Multiplayer safe. diff --git a/build.gradle b/build.gradle index 3a3709f..45a7a5b 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,7 @@ repositories { name = 'Fabric' url = 'https://maven.fabricmc.net/' } + maven { url 'https://jitpack.io' } } // We use shadow here to avoid the following dependencies being shadowed. @@ -41,6 +42,9 @@ dependencies { shadow "org.slf4j:slf4j-api:1.8.0-beta4" shadow 'org.apache.logging.log4j:log4j-slf4j18-impl:2.17.2' + + implementation("com.github.LlamaLad7:MixinExtras:0.0.11") + annotationProcessor("com.github.LlamaLad7:MixinExtras:0.0.11") } java { diff --git a/gradle.properties b/gradle.properties index af66bd8..5487954 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,5 +9,5 @@ loader_version=0.14.6-babric.1 # Mod mod_version=1.0.0 -mod_group=com.example -mod_name=BTAExampleMod-babric +mod_group=io.github,pkstdev +mod_name=InventoryPausing-bta diff --git a/src/main/java/com/example/examplemod/ExampleMod.java b/src/main/java/com/example/examplemod/ExampleMod.java deleted file mode 100644 index 4ed9b07..0000000 --- a/src/main/java/com/example/examplemod/ExampleMod.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example.examplemod; - -import net.fabricmc.api.ModInitializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ExampleMod implements ModInitializer { - public static final Logger LOGGER = LoggerFactory.getLogger("modid"); - - @Override - public void onInitialize() { - LOGGER.info("Hello BTA world! hahaye"); - } -} diff --git a/src/main/java/com/example/examplemod/mixin/ExampleMixin.java b/src/main/java/com/example/examplemod/mixin/ExampleMixin.java deleted file mode 100644 index 1df455a..0000000 --- a/src/main/java/com/example/examplemod/mixin/ExampleMixin.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.example.examplemod.mixin; - -import com.example.examplemod.ExampleMod; -import net.minecraft.src.GuiMainMenu; -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 = GuiMainMenu.class, remap = false) // Remap must be set to false in ANY Mixin classes because BTA is distributed WITHOUT being obfuscated! -public class ExampleMixin { - @Inject(method = "", at = @At("HEAD")) - private static void onClinit(CallbackInfo ci) { - ExampleMod.LOGGER.info("This line is printed by an example Mixin!"); - } -} diff --git a/src/main/java/io/github/pkstdev/invpausing/InventoryPausingPreLaunch.java b/src/main/java/io/github/pkstdev/invpausing/InventoryPausingPreLaunch.java new file mode 100644 index 0000000..61682e5 --- /dev/null +++ b/src/main/java/io/github/pkstdev/invpausing/InventoryPausingPreLaunch.java @@ -0,0 +1,11 @@ +package io.github.pkstdev.invpausing; + +import com.llamalad7.mixinextras.MixinExtrasBootstrap; +import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; + +public class InventoryPausingPreLaunch implements PreLaunchEntrypoint { + @Override + public void onPreLaunch() { + MixinExtrasBootstrap.init(); + } +} diff --git a/src/main/java/io/github/pkstdev/invpausing/mixin/GuiContainerMixin.java b/src/main/java/io/github/pkstdev/invpausing/mixin/GuiContainerMixin.java new file mode 100644 index 0000000..893fd77 --- /dev/null +++ b/src/main/java/io/github/pkstdev/invpausing/mixin/GuiContainerMixin.java @@ -0,0 +1,20 @@ +package io.github.pkstdev.invpausing.mixin; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import net.minecraft.src.GuiContainer; +import net.minecraft.src.GuiInventory; +import net.minecraft.src.GuiScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(value = GuiContainer.class, remap = false) +public class GuiContainerMixin extends GuiScreen { + @ModifyReturnValue(method = "doesGuiPauseGame", at = @At("RETURN")) + private boolean onDoesGuiPauseGame(boolean original) { + if (!this.mc.isMultiplayerWorld()) { + return ((GuiScreen)this) instanceof GuiInventory; + } else { + return false; + } + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 16c5bbb..9270e0d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,34 +1,27 @@ { "schemaVersion": 1, - "id": "modid", + "id": "invpausing", "version": "${version}", - "name": "Example Mod", - "description": "This is an example description! Tell everyone what your mod is about!", + "name": "Inventory Pausing", + "description": "Pause the game when displaying player inventory, for Better than Adventure", "authors": [ - "Me!" + "pkstDev" ], - "contact": { - "homepage": "https://fabricmc.net/", - "sources": "https://github.com/FabricMC/fabric-example-mod" - }, "license": "CC0-1.0", - "environment": "*", + "environment": "client", "entrypoints": { - "main": [ - "com.example.examplemod.ExampleMod" + "preLaunch": [ + "io.github.pkstdev.invpausing.InventoryPausingPreLaunch" ] }, "mixins": [ - "modid.mixins.json" + "invpausing.mixins.json" ], "depends": { "fabricloader": ">=0.13.3" - }, - "suggests": { - "another-mod": "*" } } diff --git a/src/main/resources/modid.mixins.json b/src/main/resources/invpausing.mixins.json similarity index 68% rename from src/main/resources/modid.mixins.json rename to src/main/resources/invpausing.mixins.json index aad549f..1cf6597 100644 --- a/src/main/resources/modid.mixins.json +++ b/src/main/resources/invpausing.mixins.json @@ -1,12 +1,12 @@ { "required": true, "minVersion": "0.8", - "package": "com.example.examplemod.mixin", + "package": "io.github.pkstdev.invpausing.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ ], "client": [ - "ExampleMixin" + "GuiContainerMixin" ], "injectors": { "defaultRequire": 1