aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java2
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java17
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITType.java10
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java37
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java11
-rw-r--r--src/main/resources/fabric.mod.json2
6 files changed, 41 insertions, 38 deletions
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": "*",