From ffc99148fe406140908abf46b3a1b55dbe7a5f78 Mon Sep 17 00:00:00 2001 From: MicrocontrollersDev Date: Fri, 18 Jul 2025 23:21:06 -0700 Subject: [PATCH 1/2] fix MC-268617 --- PATCHED.md | 1 + .../mixins/basic/mc268617/FileUtilMixin.java | 20 +++++++++++++++++++ src/main/resources/debugify.mixins.json | 1 + 3 files changed, 22 insertions(+) create mode 100644 src/main/java/dev/isxander/debugify/mixins/basic/mc268617/FileUtilMixin.java diff --git a/PATCHED.md b/PATCHED.md index 0933aac5..c850fa42 100644 --- a/PATCHED.md +++ b/PATCHED.md @@ -62,6 +62,7 @@ | Basic | [MC-224729](https://bugs.mojang.com/browse/MC-224729) | Partially generated chunks are not saved in some situations | | Basic | [MC-231743](https://bugs.mojang.com/browse/MC-231743) | minecraft.used:minecraft.POTTABLE_PLANT doesn't increase when placing plants into flower pots | | Basic | [MC-232869](https://bugs.mojang.com/browse/MC-232869) | Adult striders can spawn with saddles in peaceful mode | +| Basic | [MC-268617](https://bugs.mojang.com/browse/MC-268617) | Structures can't be saved if the game directory is named in a certain way | ## Previously patched Bugs that this mod has patched but has been superseded by a vanilla update. diff --git a/src/main/java/dev/isxander/debugify/mixins/basic/mc268617/FileUtilMixin.java b/src/main/java/dev/isxander/debugify/mixins/basic/mc268617/FileUtilMixin.java new file mode 100644 index 00000000..c0cb8f63 --- /dev/null +++ b/src/main/java/dev/isxander/debugify/mixins/basic/mc268617/FileUtilMixin.java @@ -0,0 +1,20 @@ +package dev.isxander.debugify.mixins.basic.mc268617; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.isxander.debugify.fixes.BugFix; +import dev.isxander.debugify.fixes.FixCategory; +import net.minecraft.FileUtil; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.regex.Pattern; + +@BugFix(id = "MC-268617", category = FixCategory.BASIC, env = BugFix.Env.SERVER, description = "Structures can't be saved if the game directory is named in a certain way") +@Mixin(FileUtil.class) +public class FileUtilMixin { + @WrapOperation(method = "", at = @At(value = "INVOKE", target = "Ljava/util/regex/Pattern;compile(Ljava/lang/String;I)Ljava/util/regex/Pattern;", ordinal = 1)) + private static Pattern fixWindowsReservedFilename(String regex, int flags, Operation original) { + return original.call(".*\\.|(?:CON|PRN|AUX|NUL|CLOCK\\$|CONIN\\$|CONOUT\\$|(?:COM|LPT)[¹²³0-9])(?:\\..*)?", flags); + } +} diff --git a/src/main/resources/debugify.mixins.json b/src/main/resources/debugify.mixins.json index 4b1b991a..04c0665d 100644 --- a/src/main/resources/debugify.mixins.json +++ b/src/main/resources/debugify.mixins.json @@ -30,6 +30,7 @@ "basic.mc224729.ChunkMapMixin", "basic.mc231743.FlowerPotBlockMixin", "basic.mc232869.StriderMixin", + "basic.mc268617.FileUtilMixin", "basic.mc30391.LivingEntityMixin", "basic.mc69216.ServerPlayerMixin", "basic.mc7569.RconConsoleSourceMixin", From 88f9302473d80b57737360eb2d6d0687911939b2 Mon Sep 17 00:00:00 2001 From: MicrocontrollersDev Date: Sun, 20 Jul 2025 12:10:15 -0700 Subject: [PATCH 2/2] add javadoc and explanation --- .../debugify/mixins/basic/mc268617/FileUtilMixin.java | 5 +++++ src/main/resources/assets/debugify/lang/en_us.json | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/isxander/debugify/mixins/basic/mc268617/FileUtilMixin.java b/src/main/java/dev/isxander/debugify/mixins/basic/mc268617/FileUtilMixin.java index c0cb8f63..39a54f84 100644 --- a/src/main/java/dev/isxander/debugify/mixins/basic/mc268617/FileUtilMixin.java +++ b/src/main/java/dev/isxander/debugify/mixins/basic/mc268617/FileUtilMixin.java @@ -13,6 +13,11 @@ @BugFix(id = "MC-268617", category = FixCategory.BASIC, env = BugFix.Env.SERVER, description = "Structures can't be saved if the game directory is named in a certain way") @Mixin(FileUtil.class) public class FileUtilMixin { + /** + * Updates the valid path RegEx to include more valid file paths. This new filter will properly match all reserved file names, including many undocumented by Microsoft. + * This fixes structure blocks for normal installations on old Modrinth instances or certain Linux scenarios such as Flatpak installations. + * Can be tested on Windows by naming an instance "com.example". + */ @WrapOperation(method = "", at = @At(value = "INVOKE", target = "Ljava/util/regex/Pattern;compile(Ljava/lang/String;I)Ljava/util/regex/Pattern;", ordinal = 1)) private static Pattern fixWindowsReservedFilename(String regex, int flags, Operation original) { return original.call(".*\\.|(?:CON|PRN|AUX|NUL|CLOCK\\$|CONIN\\$|CONOUT\\$|(?:COM|LPT)[¹²³0-9])(?:\\..*)?", flags); diff --git a/src/main/resources/assets/debugify/lang/en_us.json b/src/main/resources/assets/debugify/lang/en_us.json index b0d49e48..2d2769a0 100644 --- a/src/main/resources/assets/debugify/lang/en_us.json +++ b/src/main/resources/assets/debugify/lang/en_us.json @@ -76,5 +76,6 @@ "debugify.fix_explanation.mc-200418": "Dismounts baby villagers from chickens upon conversion.", "debugify.fix_explanation.mc-206922": "Items with an age less than 9 ticks are not removed from lightning strikes.", "debugify.fix_explanation.mc-215530": "Resets frozen time when the player changes to spectator.", - "debugify.fix_explanation.mc-224729": "Always saves ProtoChunks even if the chunk save predicate returns false." + "debugify.fix_explanation.mc-224729": "Always saves ProtoChunks even if the chunk save predicate returns false.", + "debugify.fix_explanation.mc-268617": "Updates the RegEx filter to include all valid path locations. This allows using structure blocks in certain launchers such as Modrinth or any Linux Flatpak launcher." }