From bd7a03e0a86954a2b5a264cb0e219746618c8862 Mon Sep 17 00:00:00 2001 From: Mehrad Nayyeri Date: Thu, 16 Mar 2023 14:16:31 +0330 Subject: [PATCH] Migrated to Minecraft v1.19.4 --- build.gradle | 5 +++-- gradle.properties | 12 ++++++------ .../ir/mehradn/rollback/gui/RollbackScreen.java | 17 ++++++++++++++++- .../rollback/mixin/SelectWorldScreenMixin.java | 7 ++++--- src/main/resources/fabric.mod.json | 8 ++++---- 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index 0e1ddab..48b08a3 100644 --- a/build.gradle +++ b/build.gradle @@ -26,10 +26,11 @@ repositories { dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings loom.layered() { + mappings loom.officialMojangMappings() + /*mappings loom.layered() { officialMojangMappings() parchment("org.parchmentmc.data:parchment-${project.minecraft_version}:${project.parchment_version}@zip") - } + }*/ implementation "com.github.LlamaLad7:MixinExtras:${project.mixin_extras_version}" annotationProcessor "com.github.LlamaLad7:MixinExtras:${project.mixin_extras_version}" diff --git a/gradle.properties b/gradle.properties index 81dcb4b..67b2a37 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,16 +4,16 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.19.3 -parchment_version=2023.02.26 -loader_version=0.14.14 +minecraft_version=1.19.4 +#parchment_version=2023.02.26 +loader_version=0.14.17 # Mod Properties -mod_version=0.6.0 +mod_version=0.7.0 maven_group=ir.mehradn archives_base_name=rollback # Dependencies mixin_extras_version=0.1.1 -fabric_version=0.74.0+1.19.3 -midnightlib_version=1.1.0-fabric +fabric_version=0.76.0+1.19.4 +midnightlib_version=1.2.1-fabric diff --git a/src/main/java/ir/mehradn/rollback/gui/RollbackScreen.java b/src/main/java/ir/mehradn/rollback/gui/RollbackScreen.java index b13602a..6769f43 100644 --- a/src/main/java/ir/mehradn/rollback/gui/RollbackScreen.java +++ b/src/main/java/ir/mehradn/rollback/gui/RollbackScreen.java @@ -7,13 +7,17 @@ import ir.mehradn.rollback.util.mixin.WorldSelectionListCallbackAction; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.FileUtil; import net.minecraft.Util; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.CycleButton; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; +import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelSummary; +import java.io.IOException; +import java.nio.file.Path; import java.util.function.Consumer; @Environment(EnvType.CLIENT) @@ -84,7 +88,18 @@ protected void init() { )); addRenderableWidget(Button.builder( Component.translatable("selectWorld.edit.backupFolder"), - (button) -> Util.getPlatform().openFile(this.minecraft.getLevelSource().getBackupPath().toFile()) + (button) -> { + LevelStorageSource levelStorageSource = this.minecraft.getLevelSource(); + Path path = levelStorageSource.getBackupPath(); + + try { + FileUtil.createDirectoriesSafe(path); + } catch (IOException e) { + throw new RuntimeException(e); + } + + Util.getPlatform().openFile(path.toFile()); + } ).bounds(this.width / 2 + 4, this.height - 52, 150, 20).build()); this.deleteButton = addRenderableWidget(Button.builder( diff --git a/src/main/java/ir/mehradn/rollback/mixin/SelectWorldScreenMixin.java b/src/main/java/ir/mehradn/rollback/mixin/SelectWorldScreenMixin.java index fdb25ed..948c7fc 100644 --- a/src/main/java/ir/mehradn/rollback/mixin/SelectWorldScreenMixin.java +++ b/src/main/java/ir/mehradn/rollback/mixin/SelectWorldScreenMixin.java @@ -40,7 +40,7 @@ private Button hideButton(Button btn) { return btn; } - @Inject(method = "init", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screens/worldselection/SelectWorldScreen;updateButtonStatus(Z)V")) + @Inject(method = "init", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screens/worldselection/SelectWorldScreen;updateButtonStatus(ZZ)V")) private void addButton(CallbackInfo ci) { if (RollbackConfig.replaceReCreateButton()) { this.rollbackButton = addRenderableWidget(Button.builder( @@ -51,7 +51,8 @@ private void addButton(CallbackInfo ci) { } @Inject(method = "updateButtonStatus", at = @At("RETURN")) - private void onUpdateButtonStatus(boolean active, CallbackInfo ci) { - this.rollbackButton.active = active; + private void onUpdateButtonStatus(boolean isPlayable, boolean isSelectable , CallbackInfo ci) { + if (RollbackConfig.replaceReCreateButton()) + this.rollbackButton.active = isPlayable; } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e053a9b..2a38d9b 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,10 +26,10 @@ "rollback.mixins.json" ], "depends": { - "fabricloader": ">=0.14.14", - "minecraft": "~1.19.3", + "fabricloader": ">=0.14.17", + "minecraft": "~1.19.4", "java": ">=17", - "fabric-api": ">=0.74.0+1.19.3", - "midnightlib": ">=1.1.0-fabric" + "fabric-api": ">=0.76.0+1.19.4", + "midnightlib": ">=1.2.1-fabric" } } \ No newline at end of file