diff --git a/build.gradle b/build.gradle index 2a6705f..db2f517 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.4-SNAPSHOT' + id 'fabric-loom' version '1.5-SNAPSHOT' id 'maven-publish' } @@ -16,6 +16,13 @@ repositories { // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. // See https://docs.gradle.org/current/userguide/declaring_repositories.html // for more information about repositories. + + maven { url "https://maven.shedaniel.me/" } + + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + } } dependencies { @@ -31,6 +38,12 @@ dependencies { // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" + + modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_version}") { + exclude(group: "net.fabricmc.fabric-api") + } + + modCompileOnly "maven.modrinth:cloth-gamerules:${project.clothGamerules_version}" } processResources { @@ -59,7 +72,7 @@ java { jar { from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} + rename { "${it}_${project.base.archivesName.get()}"} } } diff --git a/gradle.properties b/gradle.properties index 4707acf..c05a1b6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,12 +6,16 @@ org.gradle.parallel=true # check these on https://fabricmc.net/develop minecraft_version=1.19.4 yarn_mappings=1.19.4+build.2 -loader_version=0.15.3 +loader_version=0.15.7 #Fabric api fabric_version=0.87.2+1.19.4 # Mod Properties -mod_version=1.1.0 +mod_version=1.2.0 maven_group=tk.estecka.packrulemenus archives_base_name=packrule-menus + +# Optional Dependencies +clothGamerules_version=1.0.0+1.19.4 +cloth_version=10.1.117 diff --git a/port.md b/port.md new file mode 100644 index 0000000..a31cd4a --- /dev/null +++ b/port.md @@ -0,0 +1,6 @@ +# Minecraft Code Breaking Changes +### 1.19.4 +Current master + +### 1.20.0 +- `MatrixStack` parameters are replaced with `DrawContext` in most GUI. \ No newline at end of file diff --git a/src/main/java/tk/estecka/packrulemenus/mixin/OptionScreenMixin.java b/src/main/java/tk/estecka/packrulemenus/mixin/OptionScreenMixin.java index 1704c51..0d41186 100644 --- a/src/main/java/tk/estecka/packrulemenus/mixin/OptionScreenMixin.java +++ b/src/main/java/tk/estecka/packrulemenus/mixin/OptionScreenMixin.java @@ -1,6 +1,8 @@ package tk.estecka.packrulemenus.mixin; import java.util.Collection; +import java.util.Optional; +import java.util.function.Consumer; import java.util.function.Supplier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -11,6 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.llamalad7.mixinextras.sugar.Local; import it.unimi.dsi.fastutil.booleans.BooleanConsumer; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.gui.screen.MessageScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.TitleScreen; @@ -29,18 +32,19 @@ import net.minecraft.util.Identifier; import net.minecraft.util.WorldSavePath; import net.minecraft.world.GameRules; +import tk.estecka.clothgamerules.api.ClothGamerulesScreenFactory; import tk.estecka.packrulemenus.GenericWarningScreen; import tk.estecka.packrulemenus.PackRuleMenus; +@Unique @Mixin(OptionsScreen.class) abstract public class OptionScreenMixin extends Screen { - private OptionScreenMixin(){ super(null); throw new AssertionError(); } + private OptionScreenMixin(){ super(null); } @Shadow abstract ButtonWidget createButton(Text message, Supplier screenSupplier); - @Unique private IntegratedServer server; @Inject( method="init", at=@At(value="INVOKE", ordinal=1, shift=Shift.AFTER, target="net/minecraft/client/gui/widget/GridWidget$Adder.add (Lnet/minecraft/client/gui/widget/Widget;)Lnet/minecraft/client/gui/widget/Widget;") ) @@ -54,9 +58,9 @@ abstract public class OptionScreenMixin final GameRules worldRules = server.getOverworld().getGameRules(); adder.add(createButton( Text.translatable("selectWorld.gameRules"), - () -> new EditGameRulesScreen( + () -> CreateGameruleScreen( worldRules.copy(), - optRules -> { RevertScreen(); optRules.ifPresent(r -> worldRules.setAllValues(r, server)); } + optRules -> optRules.ifPresent(r -> worldRules.setAllValues(r, server)) ) )); @@ -72,13 +76,18 @@ abstract public class OptionScreenMixin )); } } + + private Screen CreateGameruleScreen(GameRules rules, Consumer> saveConsumer){ + if (FabricLoader.getInstance().isModLoaded("cloth-gamerules")) + return ClothGamerulesScreenFactory.CreateScreen(this, rules, saveConsumer); + else + return new EditGameRulesScreen(rules, saveConsumer.andThen( __->RevertScreen() )); + } - @Unique private void RevertScreen(){ client.setScreen((OptionsScreen)(Object)this); }; - @Unique private void HandleDatapackRefresh(final ResourcePackManager manager, Collection rollback){ FeatureSet neoFeatures = manager.getRequestedFeatures(); FeatureSet oldFeatures = server.getSaveProperties().getEnabledFeatures(); @@ -113,7 +122,6 @@ private void HandleDatapackRefresh(final ResourcePackManager manager, Collection } } - @Unique private void ApplyFlags(final ResourcePackManager manager){ FeatureSet features = manager.getRequestedFeatures(); @@ -126,7 +134,6 @@ private void ApplyFlags(final ResourcePackManager manager){ } - @Unique private void ReloadPacks(final ResourcePackManager manager){ client.inGameHud.getChatHud().addMessage(Text.translatable("commands.reload.success"));