diff options
13 files changed, 67 insertions, 80 deletions
diff --git a/build.gradle b/build.gradle index 31a95bc..2417fee 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ import java.nio.file.Files plugins { - id 'fabric-loom' version '0.11-SNAPSHOT' apply false + id 'fabric-loom' version '0.12-SNAPSHOT' apply false id 'io.shcm.shsupercm.fabric.fletchingtable' version '1.4' apply false id 'com.modrinth.minotaur' version '2.+' apply false id 'com.matthewprenger.cursegradle' version '1.4.0' apply false @@ -27,7 +27,7 @@ allprojects { modImplementation fabricApi.module("fabric-api-base", "${project.fabric_api}") modImplementation fabricApi.module("fabric-resource-loader-v0", "${project.fabric_api}") - modImplementation fabricApi.module("fabric-command-api-v1", "${project.fabric_api}") + modImplementation fabricApi.module("fabric-command-api-v2", "${project.fabric_api}") modCompileOnly("com.terraformersmc:modmenu:${project.modmenu}") { exclude(group: "net.fabricmc.fabric-api") @@ -100,7 +100,7 @@ modrinth { versionNumber = version versionName = "v" + version additionalFiles = [ sourcesJar.outputs.getFiles().singleFile ] - gameVersions = ["1.18", "1.18.1", "1.18.2"] + gameVersions = ["1.19"] } curseforge { @@ -114,9 +114,7 @@ curseforge { displayName = "v" + version } addGameVersion 'Fabric' - addGameVersion '1.18' - addGameVersion '1.18.1' - addGameVersion '1.18.2' + addGameVersion '1.19' } options { forgeGradleIntegration = false diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java index fe0bafb..d442559 100644 --- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java +++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java @@ -14,8 +14,6 @@ import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.client.world.ClientWorld; import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.resource.Resource; import net.minecraft.resource.ResourceManager; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -185,7 +183,7 @@ public class TypeItem extends CITType { overrideConditions.put(new Identifier(itemIdentifier.getNamespace(), "item/" + itemIdentifier.getPath()), Collections.emptyList()); Identifier itemModelIdentifier = new Identifier(itemIdentifier.getNamespace(), "models/item/" + itemIdentifier.getPath() + ".json"); - try (Resource itemModelResource = resourceManager.getResource(itemModelIdentifier); Reader resourceReader = new InputStreamReader(itemModelResource.getInputStream())) { + try (Reader resourceReader = new InputStreamReader(resourceManager.getResource(itemModelIdentifier).orElseThrow().getInputStream())) { JsonUnbakedModel itemModelJson = JsonUnbakedModel.deserialize(resourceReader); if (itemModelJson.getOverrides() != null && !itemModelJson.getOverrides().isEmpty()) @@ -263,7 +261,7 @@ public class TypeItem extends CITType { overrideConditions.put(new Identifier(itemIdentifier.getNamespace(), "item/" + itemIdentifier.getPath()), Collections.emptyList()); Identifier itemModelIdentifier = new Identifier(itemIdentifier.getNamespace(), "models/item/" + itemIdentifier.getPath() + ".json"); - try (Resource itemModelResource = resourceManager.getResource(itemModelIdentifier); Reader resourceReader = new InputStreamReader(itemModelResource.getInputStream())) { + try (Reader resourceReader = new InputStreamReader( resourceManager.getResource(itemModelIdentifier).orElseThrow().getInputStream())) { JsonUnbakedModel itemModelJson = JsonUnbakedModel.deserialize(resourceReader); if (itemModelJson.getOverrides() != null && !itemModelJson.getOverrides().isEmpty()) @@ -305,10 +303,8 @@ public class TypeItem extends CITType { } JsonUnbakedModel json; if (identifier.getPath().endsWith(".json")) { - InputStream is = null; - Resource resource = null; - try { - json = JsonUnbakedModel.deserialize(IOUtils.toString(is = (resource = resourceManager.getResource(identifier)).getInputStream(), StandardCharsets.UTF_8)); + try (InputStream is = resourceManager.getResource(identifier).orElseThrow().getInputStream()) { + json = JsonUnbakedModel.deserialize(IOUtils.toString(is, StandardCharsets.UTF_8)); json.id = assetIdentifier.toString(); json.id = json.id.substring(0, json.id.length() - 5); @@ -368,8 +364,6 @@ public class TypeItem extends CITType { }); return json; - } finally { - IOUtils.closeQuietly(is, resource); } } else if (identifier.getPath().endsWith(".png")) { json = getModelForFirstItemType(resourceManager); @@ -419,9 +413,8 @@ public class TypeItem extends CITType { private JsonUnbakedModel getModelForFirstItemType(ResourceManager resourceManager) { Identifier firstItemIdentifier = Registry.ITEM.getId(this.items.iterator().next()), firstItemModelIdentifier = new Identifier(firstItemIdentifier.getNamespace(), "models/item/" + firstItemIdentifier.getPath() + ".json"); - Resource itemModelResource = null; - try { - JsonUnbakedModel json = JsonUnbakedModel.deserialize(IOUtils.toString((itemModelResource = resourceManager.getResource(firstItemModelIdentifier)).getInputStream(), StandardCharsets.UTF_8)); + try (InputStream is = resourceManager.getResource(firstItemModelIdentifier).orElseThrow().getInputStream()) { + JsonUnbakedModel json = JsonUnbakedModel.deserialize(IOUtils.toString(is, StandardCharsets.UTF_8)); if (!GENERATED_SUB_CITS_SEEN.add(firstItemModelIdentifier)) // cit generated duplicate firstItemModelIdentifier = new Identifier(firstItemModelIdentifier.getNamespace(), GENERATED_SUB_CITS_PREFIX + GENERATED_SUB_CITS_SEEN.size() + "_" + firstItemModelIdentifier.getPath()); @@ -432,8 +425,6 @@ public class TypeItem extends CITType { return json; } catch (Exception e) { return null; - } finally { - IOUtils.closeQuietly(itemModelResource); } } diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/config/CITResewnDefaultsConfigScreenFactory.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/config/CITResewnDefaultsConfigScreenFactory.java index 95b0579..b25b773 100644 --- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/config/CITResewnDefaultsConfigScreenFactory.java +++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/config/CITResewnDefaultsConfigScreenFactory.java @@ -5,8 +5,7 @@ import me.shedaniel.clothconfig2.api.ConfigBuilder; import me.shedaniel.clothconfig2.api.ConfigCategory; import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.LiteralText; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.Text; import shcm.shsupercm.fabric.citresewn.config.CITResewnConfigScreenFactory; public class CITResewnDefaultsConfigScreenFactory { @@ -16,14 +15,14 @@ public class CITResewnDefaultsConfigScreenFactory { ConfigBuilder builder = ConfigBuilder.create() .setParentScreen(parent) - .setTitle(new TranslatableText("config.citresewn-defaults.title")) + .setTitle(Text.translatable("config.citresewn-defaults.title")) .setSavingRunnable(currentConfig::write); - ConfigCategory category = builder.getOrCreateCategory(new LiteralText("")); + ConfigCategory category = builder.getOrCreateCategory(Text.empty()); ConfigEntryBuilder entryBuilder = builder.entryBuilder(); - category.addEntry(entryBuilder.startFloatField(new TranslatableText("config.citresewn-defaults.type_enchantment_scroll_multiplier.title"), currentConfig.type_enchantment_scroll_multiplier) - .setTooltip(new TranslatableText("config.citresewn-defaults.type_enchantment_scroll_multiplier.tooltip")) + category.addEntry(entryBuilder.startFloatField(Text.translatable("config.citresewn-defaults.type_enchantment_scroll_multiplier.title"), currentConfig.type_enchantment_scroll_multiplier) + .setTooltip(Text.translatable("config.citresewn-defaults.type_enchantment_scroll_multiplier.tooltip")) .setSaveConsumer(newConfig -> currentConfig.type_enchantment_scroll_multiplier = newConfig) .setDefaultValue(defaultConfig.type_enchantment_scroll_multiplier) .build()); diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ModelLoaderMixin.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ModelLoaderMixin.java index 8ed0e20..333ad6c 100644 --- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ModelLoaderMixin.java +++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ModelLoaderMixin.java @@ -35,10 +35,8 @@ public class ModelLoaderMixin { @Inject(method = "loadModelFromJson", cancellable = true, at = @At("HEAD")) public void citresewn$forceLiteralResewnModelIdentifier(Identifier id, CallbackInfoReturnable<JsonUnbakedModel> cir) { if (id instanceof ResewnItemModelIdentifier) { - InputStream is = null; - Resource resource = null; - try { - JsonUnbakedModel json = JsonUnbakedModel.deserialize(IOUtils.toString(is = (resource = resourceManager.getResource(id)).getInputStream(), StandardCharsets.UTF_8)); + try (InputStream is = resourceManager.getResource(id).orElseThrow().getInputStream()) { + JsonUnbakedModel json = JsonUnbakedModel.deserialize(IOUtils.toString(is, StandardCharsets.UTF_8)); json.id = id.toString(); json.id = json.id.substring(0, json.id.length() - 5); @@ -79,8 +77,6 @@ public class ModelLoaderMixin { cir.setReturnValue(json); } catch (Exception ignored) { - } finally { - IOUtils.closeQuietly(is, resource); } } } diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java index 93bab6a..4a9da85 100644 --- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java +++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java @@ -89,7 +89,7 @@ public class ModelLoaderMixin { } @ModifyArg(method = "loadModelFromJson", at = - @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourceManager;getResource(Lnet/minecraft/util/Identifier;)Lnet/minecraft/resource/Resource;")) + @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourceManager;openAsReader(Lnet/minecraft/util/Identifier;)Ljava/io/BufferedReader;")) public Identifier citresewn$fixDuplicatePrefixSuffix(Identifier original) { if (CONTAINER.active() && original.getPath().startsWith("models/models/") && original.getPath().endsWith(".json.json") && original.getPath().contains("cit")) return new Identifier(original.getNamespace(), original.getPath().substring(7, original.getPath().length() - 5)); diff --git a/gradle.properties b/gradle.properties index 06dde20..4041bfc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.18.2 -minecraft_version_compat=1.18.x -yarn_mappings=1.18.2+build.1 -loader_version=0.13.3 +minecraft_version=1.19 +minecraft_version_compat=1.19.x +yarn_mappings=1.19+build.1 +loader_version=0.14.7 -fabric_api=0.47.9+1.18.2 -modmenu=3.0.1 -cloth=6.1.48 +fabric_api=0.55.3+1.19 +modmenu=4.0.0 +cloth=7.0.69 # Mod Properties mod_version=1.0.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e589..aa991fc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java index 7d4be88..f47e137 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java @@ -20,7 +20,7 @@ public class CITResewn implements ClientModInitializer { public void onInitializeClient() { CITRegistry.registerAll(); - if (FabricLoader.getInstance().isModLoaded("fabric-command-api-v1")) + if (FabricLoader.getInstance().isModLoaded("fabric-command-api-v2")) CITResewnCommand.register(); } diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java index e07a772..f87c39e 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java @@ -8,7 +8,8 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.text.Text; import shcm.shsupercm.fabric.citresewn.cit.*; @@ -20,8 +21,8 @@ import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument; -import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; import static net.minecraft.text.Text.of; /** @@ -43,8 +44,9 @@ public class CITResewnCommand { * Registers all of CIT Resewn's commands. */ public static void register() { - ClientCommandManager.DISPATCHER.register(literal("citresewn") - .executes(context -> { //citresewn + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> { + dispatcher.register( + ClientCommandManager.literal("citresewn").executes(context -> { context.getSource().sendFeedback(of("CIT Resewn v" + FabricLoader.getInstance().getModContainer("citresewn").orElseThrow().getMetadata().getVersion() + ":")); context.getSource().sendFeedback(of(" Registered: " + CITRegistry.TYPES.values().stream().distinct().count() + " types and " + CITRegistry.CONDITIONS.values().stream().distinct().count() + " conditions")); @@ -113,8 +115,9 @@ public class CITResewnCommand { }) ) ) - ) - ); + ) + ); + }); } /** diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITType.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITType.java index 65b3097..f540aa8 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITType.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITType.java @@ -55,7 +55,7 @@ public abstract class CITType { if (!path.endsWith(extension)) path = path + extension; Identifier pathIdentifier = new Identifier(rootIdentifier.getNamespace(), path); - return resourceManager.containsResource(pathIdentifier) ? pathIdentifier : null; + return resourceManager.getResource(pathIdentifier).isPresent() ? pathIdentifier: null; } Identifier pathIdentifier = new Identifier(path); @@ -68,17 +68,17 @@ public abstract class CITType { path = path.substring(2); else if (!path.contains("..")) { pathIdentifier = new Identifier(pathIdentifier.getNamespace(), path); - if (resourceManager.containsResource(pathIdentifier)) + if (resourceManager.getResource(pathIdentifier).isPresent()) return pathIdentifier; else if (path.startsWith("assets/")) { path = path.substring(7); int sep = path.indexOf('/'); pathIdentifier = new Identifier(path.substring(0, sep), path.substring(sep + 1)); - if (resourceManager.containsResource(pathIdentifier)) + if (resourceManager.getResource(pathIdentifier).isPresent()) return pathIdentifier; } pathIdentifier = new Identifier(pathIdentifier.getNamespace(), defaultedTypeDirectory + "/" + path); - if (resourceManager.containsResource(pathIdentifier)) + if (resourceManager.getResource(pathIdentifier).isPresent()) return pathIdentifier; } @@ -100,7 +100,7 @@ public abstract class CITType { pathIdentifier = new Identifier(rootIdentifier.getNamespace(), path); - return resourceManager.containsResource(pathIdentifier) ? pathIdentifier : null; + return resourceManager.getResource(pathIdentifier).isPresent() ? pathIdentifier : null; } public static Identifier resolveAsset(Identifier rootIdentifier, PropertyValue path, String defaultedTypeDirectory, String extension, ResourceManager resourceManager) { diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java index c1c35b2..d00e9b0 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java @@ -6,8 +6,7 @@ import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.LiteralText; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.Text; import net.minecraft.util.Formatting; import java.util.function.Function; @@ -33,14 +32,14 @@ public class CITResewnConfigScreenFactory { ConfigBuilder builder = ConfigBuilder.create() .setParentScreen(parent) - .setTitle(new TranslatableText("config.citresewn.title")) + .setTitle(Text.translatable("config.citresewn.title")) .setSavingRunnable(currentConfig::write); - ConfigCategory category = builder.getOrCreateCategory(new LiteralText("")); + ConfigCategory category = builder.getOrCreateCategory(Text.empty()); ConfigEntryBuilder entryBuilder = builder.entryBuilder(); - category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.enabled.title"), currentConfig.enabled) - .setTooltip(new TranslatableText("config.citresewn.enabled.tooltip")) + category.addEntry(entryBuilder.startBooleanToggle(Text.translatable("config.citresewn.enabled.title"), currentConfig.enabled) + .setTooltip(Text.translatable("config.citresewn.enabled.tooltip")) .setSaveConsumer(newConfig -> { if (currentConfig.enabled != newConfig) { currentConfig.enabled = newConfig; @@ -52,8 +51,8 @@ public class CITResewnConfigScreenFactory { if (FabricLoader.getInstance().isModLoaded("citresewn-defaults")) { class CurrentScreen { boolean prevToggle = false; } final CurrentScreen currentScreen = new CurrentScreen(); - category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn-defaults.title"), false) - .setTooltip(new TranslatableText("config.citresewn-defaults.tooltip")) + category.addEntry(entryBuilder.startBooleanToggle(Text.translatable("config.citresewn-defaults.title"), false) + .setTooltip(Text.translatable("config.citresewn-defaults.tooltip")) .setYesNoTextSupplier((b) -> { if (b != currentScreen.prevToggle) { @@ -63,30 +62,30 @@ public class CITResewnConfigScreenFactory { currentScreen.prevToggle = b; } - return new TranslatableText("config.citresewn.configure"); + return Text.translatable("config.citresewn.configure"); }) .build()); } - category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.mute_errors.title"), currentConfig.mute_errors) - .setTooltip(new TranslatableText("config.citresewn.mute_errors.tooltip")) + category.addEntry(entryBuilder.startBooleanToggle(Text.translatable("config.citresewn.mute_errors.title"), currentConfig.mute_errors) + .setTooltip(Text.translatable("config.citresewn.mute_errors.tooltip")) .setSaveConsumer(newConfig -> currentConfig.mute_errors = newConfig) .setDefaultValue(defaultConfig.mute_errors) .build()); - category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.mute_warns.title"), currentConfig.mute_warns) - .setTooltip(new TranslatableText("config.citresewn.mute_warns.tooltip")) + category.addEntry(entryBuilder.startBooleanToggle(Text.translatable("config.citresewn.mute_warns.title"), currentConfig.mute_warns) + .setTooltip(Text.translatable("config.citresewn.mute_warns.tooltip")) .setSaveConsumer(newConfig -> currentConfig.mute_warns = newConfig) .setDefaultValue(defaultConfig.mute_warns) .build()); - category.addEntry(entryBuilder.startIntSlider(new TranslatableText("config.citresewn.cache_ms.title"), currentConfig.cache_ms / 50, 0, 5 * 20) - .setTooltip(new TranslatableText("config.citresewn.cache_ms.tooltip")) + category.addEntry(entryBuilder.startIntSlider(Text.translatable("config.citresewn.cache_ms.title"), currentConfig.cache_ms / 50, 0, 5 * 20) + .setTooltip(Text.translatable("config.citresewn.cache_ms.tooltip")) .setSaveConsumer(newConfig -> currentConfig.cache_ms = newConfig * 50) .setDefaultValue(defaultConfig.cache_ms / 50) .setTextGetter(ticks -> { if (ticks <= 1) - return new TranslatableText("config.citresewn.cache_ms.ticks." + ticks).formatted(Formatting.AQUA); + return Text.translatable("config.citresewn.cache_ms.ticks." + ticks).formatted(Formatting.AQUA); Formatting color = Formatting.DARK_RED; @@ -95,12 +94,12 @@ public class CITResewnConfigScreenFactory { if (ticks <= 10) color = Formatting.DARK_GREEN; if (ticks <= 5) color = Formatting.GREEN; - return new TranslatableText("config.citresewn.cache_ms.ticks.any", ticks).formatted(color); + return Text.translatable("config.citresewn.cache_ms.ticks.any", ticks).formatted(color); }) .build()); - category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.broken_paths.title"), currentConfig.broken_paths) - .setTooltip(new TranslatableText("config.citresewn.broken_paths.tooltip")) + category.addEntry(entryBuilder.startBooleanToggle(Text.translatable("config.citresewn.broken_paths.title"), currentConfig.broken_paths) + .setTooltip(Text.translatable("config.citresewn.broken_paths.tooltip")) .setSaveConsumer(newConfig -> currentConfig.broken_paths = newConfig) .setDefaultValue(defaultConfig.broken_paths) .requireRestart() diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java index 4b5d23a..7155435 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java @@ -63,18 +63,19 @@ public final class PackParser { private PackParser() {} public static List<CIT<?>> parseCITs(ResourceManager resourceManager) { List<CIT<?>> cits = new ArrayList<>(); - for (String root : ROOTS) - for (Identifier identifier : resourceManager.findResources(root + "/cit", s -> s.endsWith(".properties"))) { + for (String root : ROOTS) { + for (Map.Entry<Identifier, Resource> entry : resourceManager.findResources(root + "/cit", s -> s.getPath().endsWith(".properties")).entrySet()) { String packName = null; - try (Resource resource = resourceManager.getResource(identifier)) { - cits.add(parseCIT(PropertyGroup.tryParseGroup(packName = resource.getResourcePackName(), identifier, resource.getInputStream()), resourceManager)); + try { + cits.add(parseCIT(PropertyGroup.tryParseGroup(packName = entry.getValue().getResourcePackName(), entry.getKey(), entry.getValue().getInputStream()), resourceManager)); } catch (CITParsingException e) { CITResewn.logErrorLoading(e.getMessage()); } catch (Exception e) { - CITResewn.logErrorLoading("Errored while loading cit: " + identifier + (packName == null ? "" : " from " + packName)); + CITResewn.logErrorLoading("Errored while loading cit: " + entry.getKey() + (packName == null ? "" : " from " + packName)); e.printStackTrace(); } } + } return cits; } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a8e2234..0822b80 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,7 +23,7 @@ "depends": { "fabric": "*", "fabricloader": "*", - "minecraft": "1.18.x" + "minecraft": "1.19.x" }, "recommends": { "modmenu": "*", |