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/api/CITGlobalProperties.java2
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITContext.java2
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasLoaderMixin.java45
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java22
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java7
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ResourceFinderMixin.java23
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/broken_paths/AbstractFileResourcePackMixin.java44
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java13
-rw-r--r--src/main/resources/assets/citresewn/lang/it_it.json19
-rw-r--r--src/main/resources/assets/citresewn/lang/pt_br.json26
-rw-r--r--src/main/resources/assets/citresewn/lang/zh_tw.json26
-rw-r--r--src/main/resources/fabric.mod.json2
12 files changed, 185 insertions, 46 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITGlobalProperties.java b/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITGlobalProperties.java
index 05495af..6a6ec22 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITGlobalProperties.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/api/CITGlobalProperties.java
@@ -2,7 +2,7 @@ package shcm.shsupercm.fabric.citresewn.api;
import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue;
-import javax.annotation.Nullable;
+import blue.endless.jankson.annotation.Nullable;
/**
* @see #globalProperty(String, PropertyValue)
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITContext.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITContext.java
index cfc10f8..0a44915 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITContext.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITContext.java
@@ -11,7 +11,7 @@ import net.minecraft.nbt.NbtElement;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
-import javax.annotation.Nullable;
+import blue.endless.jankson.annotation.Nullable;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasLoaderMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasLoaderMixin.java
new file mode 100644
index 0000000..ee5c125
--- /dev/null
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasLoaderMixin.java
@@ -0,0 +1,45 @@
+package shcm.shsupercm.fabric.citresewn.mixin;
+
+import net.minecraft.client.texture.atlas.AtlasLoader;
+import net.minecraft.client.texture.atlas.AtlasSource;
+import net.minecraft.client.texture.atlas.AtlasSourceType;
+import net.minecraft.resource.Resource;
+import net.minecraft.resource.ResourceFinder;
+import net.minecraft.resource.ResourceManager;
+import net.minecraft.util.Identifier;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import shcm.shsupercm.fabric.citresewn.pack.PackParser;
+
+import java.util.List;
+import java.util.Map;
+
+@Mixin(AtlasLoader.class)
+public class AtlasLoaderMixin {
+ @Shadow @Final private List<AtlasSource> sources;
+
+ @Inject(method = "of", at = @At("RETURN"), cancellable = true)
+ private static void citresewn$atlasSource(ResourceManager resourceManager, Identifier id, CallbackInfoReturnable<AtlasLoader> cir) {
+ if (id.getPath().equals("blocks") && id.getNamespace().equals("minecraft")) {
+ ((AtlasLoaderMixin) (Object) cir.getReturnValue()).sources.add(new AtlasSource() {
+ @Override
+ public void load(ResourceManager resourceManager, SpriteRegions regions) {
+ for (String root : PackParser.ROOTS) {
+ ResourceFinder resourceFinder = new ResourceFinder(root + "/cit", ".png");
+ for (Map.Entry<Identifier, Resource> entry : resourceFinder.findResources(resourceManager).entrySet())
+ regions.add(resourceFinder.toResourceId(entry.getKey()).withPrefixedPath(root + "/cit/"), entry.getValue());
+ }
+ }
+
+ @Override
+ public AtlasSourceType getType() {
+ return null;
+ }
+ });
+ }
+ }
+}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java
new file mode 100644
index 0000000..7a6cfa1
--- /dev/null
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java
@@ -0,0 +1,22 @@
+package shcm.shsupercm.fabric.citresewn.mixin;
+
+import net.minecraft.client.render.model.SpriteAtlasManager;
+import net.minecraft.util.Identifier;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.ModifyVariable;
+
+@Mixin(SpriteAtlasManager.AtlasPreparation.class)
+public abstract class AtlasPreparationMixin {
+
+ @ModifyVariable(method = "getSprite", argsOnly = true, at = @At("HEAD"))
+ private Identifier citresewn$unwrapTexturePaths(Identifier id) {
+ if (id.getPath().endsWith(".png")) {
+ id = id.withPath(path -> path.substring(0, path.length() - 4));
+
+ if (id.getPath().startsWith("textures/"))
+ id = id.withPath(path -> path.substring(9));
+ }
+ return id;
+ }
+}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java
index df11ac9..215c596 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java
@@ -1,5 +1,6 @@
package shcm.shsupercm.fabric.citresewn.mixin;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.resource.ResourceManager;
@@ -10,6 +11,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import shcm.shsupercm.fabric.citresewn.cit.ActiveCITs;
+import java.util.Map;
+
/**
* Initializes the (re)loading of active cits in the resource manager.
* @see ActiveCITs
@@ -21,9 +24,9 @@ public class ModelLoaderMixin {
*/
@Inject(method = "<init>", at =
@At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V"))
- private void citresewn$loadCITs(ResourceManager resourceManager, BlockColors blockColors, Profiler profiler, int i, CallbackInfo ci) {
+ private void citresewn$loadCITs(BlockColors blockColors, Profiler profiler, Map jsonUnbakedModels, Map blockStates, CallbackInfo ci) {
profiler.push("citresewn:reloading_cits");
- ActiveCITs.load(resourceManager, profiler);
+ ActiveCITs.load(MinecraftClient.getInstance().getResourceManager(), profiler);
profiler.pop();
}
}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ResourceFinderMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ResourceFinderMixin.java
new file mode 100644
index 0000000..0abdf76
--- /dev/null
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ResourceFinderMixin.java
@@ -0,0 +1,23 @@
+package shcm.shsupercm.fabric.citresewn.mixin;
+
+import net.minecraft.resource.ResourceFinder;
+import net.minecraft.util.Identifier;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(ResourceFinder.class)
+public class ResourceFinderMixin {
+
+ @Shadow @Final private String fileExtension;
+
+ @Inject(method = "toResourcePath", cancellable = true, at =
+ @At("HEAD"))
+ private void citresewn$forceAbsoluteTextureIdentifier(Identifier id, CallbackInfoReturnable<Identifier> cir) {
+ if (id.getPath().endsWith(".png") && this.fileExtension.equals(".png"))
+ cir.setReturnValue(id);
+ }
+}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/broken_paths/AbstractFileResourcePackMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/broken_paths/AbstractFileResourcePackMixin.java
index b241fff..673ddbf 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/broken_paths/AbstractFileResourcePackMixin.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/broken_paths/AbstractFileResourcePackMixin.java
@@ -1,26 +1,17 @@
package shcm.shsupercm.fabric.citresewn.mixin.broken_paths;
import net.minecraft.resource.AbstractFileResourcePack;
-import net.minecraft.resource.DirectoryResourcePack;
import net.minecraft.resource.ResourcePack;
-import net.minecraft.resource.ZipResourcePack;
+import net.minecraft.resource.ResourceType;
import net.minecraft.resource.metadata.PackResourceMetadata;
import net.minecraft.resource.metadata.ResourceMetadataReader;
-import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
-import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import shcm.shsupercm.fabric.citresewn.config.BrokenPaths;
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.zip.ZipFile;
-
/**
* Adds a resourcepack compatibility error message when broken paths are enabled and are detected in a pack.
* @see BrokenPaths
@@ -28,32 +19,17 @@ import java.util.zip.ZipFile;
*/
@Mixin(AbstractFileResourcePack.class)
public abstract class AbstractFileResourcePackMixin implements ResourcePack {
- @Shadow @Final protected File base;
- @SuppressWarnings({"unchecked", "ConstantConditions", "EqualsBetweenInconvertibleTypes"})
+ @SuppressWarnings({"unchecked"})
@Inject(method = "parseMetadata(Lnet/minecraft/resource/metadata/ResourceMetadataReader;)Ljava/lang/Object;", cancellable = true, at = @At("RETURN"))
public <T extends PackResourceMetadata> void citresewn$brokenpaths$parseMetadata(ResourceMetadataReader<T> metaReader, CallbackInfoReturnable<T> cir) {
- if (cir.getReturnValue() != null)
- try {
- if (this.getClass().equals(ZipResourcePack.class)) {
- try (ZipFile zipFile = new ZipFile(base)) {
- zipFile.stream()
- .forEach(entry -> {
- if (entry.getName().startsWith("assets") && !entry.getName().endsWith(".DS_Store"))
- new Identifier("minecraft", entry.getName());
- });
- }
- } else if (this.getClass().equals(DirectoryResourcePack.class)) {
- final Path assets = new File(base, "assets").toPath();
- Files.walk(assets)
- .forEach(fullPath -> {
- String path = assets.relativize(fullPath).toString().replace('\\', '/');
- if (!path.endsWith(".DS_Store"))
- new Identifier("minecraft", path);
- });
- }
- } catch (InvalidIdentifierException e) {
- cir.setReturnValue((T) new PackResourceMetadata(cir.getReturnValue().getDescription(), Integer.MAX_VALUE - 53));
- } catch (Exception ignored) {}
+ if (cir.getReturnValue() != null) try {
+ for (String namespace : getNamespaces(ResourceType.CLIENT_RESOURCES)) {
+ findResources(ResourceType.CLIENT_RESOURCES, namespace, "", (identifier, inputStreamInputSupplier) -> {
+ });
+ }
+ } catch (InvalidIdentifierException e) {
+ cir.setReturnValue((T) new PackResourceMetadata(cir.getReturnValue().getDescription(), Integer.MAX_VALUE - 53));
+ } catch (Exception ignored) { }
}
}
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 ffc242f..aa367b7 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/PackParser.java
@@ -1,9 +1,6 @@
package shcm.shsupercm.fabric.citresewn.pack;
-import net.minecraft.resource.Resource;
-import net.minecraft.resource.ResourceManager;
-import net.minecraft.resource.ResourcePack;
-import net.minecraft.resource.ResourceType;
+import net.minecraft.resource.*;
import net.minecraft.util.Identifier;
import shcm.shsupercm.fabric.citresewn.CITResewn;
import shcm.shsupercm.fabric.citresewn.cit.builtin.conditions.core.FallbackCondition;
@@ -18,6 +15,7 @@ import shcm.shsupercm.fabric.citresewn.pack.format.PropertyKey;
import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue;
import java.io.FileNotFoundException;
+import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
@@ -28,7 +26,7 @@ public final class PackParser { private PackParser() {}
/**
* Possible CIT roots in resourcepacks ordered in increasing order of priority.
*/
- private static final String[] ROOTS = new String[] { "mcpatcher", "optifine", "citresewn" };
+ public static final List<String> ROOTS = List.of("mcpatcher", "optifine", "citresewn");
/**
* Loads a merged global property group from loaded packs making sure to respect order.
@@ -44,8 +42,9 @@ public final class PackParser { private PackParser() {}
for (String root : ROOTS) {
Identifier identifier = new Identifier(namespace, root + "/cit.properties");
try {
- if (pack.contains(ResourceType.CLIENT_RESOURCES, identifier))
- globalProperties.load(pack.getName(), identifier, pack.open(ResourceType.CLIENT_RESOURCES, identifier));
+ InputSupplier<InputStream> citPropertiesSupplier = pack.open(ResourceType.CLIENT_RESOURCES, identifier);
+ if (citPropertiesSupplier != null)
+ globalProperties.load(pack.getName(), identifier, citPropertiesSupplier.get());
} catch (FileNotFoundException ignored) {
} catch (Exception e) {
CITResewn.logErrorLoading("Errored while loading global properties: " + identifier + " from " + pack.getName());
diff --git a/src/main/resources/assets/citresewn/lang/it_it.json b/src/main/resources/assets/citresewn/lang/it_it.json
new file mode 100644
index 0000000..debdc34
--- /dev/null
+++ b/src/main/resources/assets/citresewn/lang/it_it.json
@@ -0,0 +1,19 @@
+{
+ "config.citresewn.title": "Configurazione CIT Resewn",
+ "config.citresewn.configure": "Configura",
+ "config.citresewn.enabled.title": "Attivato",
+ "config.citresewn.enabled.tooltip": "CIT Resewn può caricare e iniettare cits dalle resourcepack?",
+ "config.citresewn.mute_errors.title": "Muta gli errori di caricamento",
+ "config.citresewn.mute_errors.tooltip": "Dovrebbe CIT Resewn mutare gli errori cit?",
+ "config.citresewn.mute_warns.title": "Muta avvisi di caricamento",
+ "config.citresewn.mute_warns.tooltip": "Muta gli avvisi di caricamento cit",
+ "config.citresewn.broken_paths.title": "Consenti percorsi non funzionanti nelle resourcepacks",
+ "config.citresewn.broken_paths.tooltip": "Permette di caricare le resourcepack non funzionanti, Potrebbe causare problemi!",
+ "config.citresewn.cache_ms.title": "Cache",
+ "config.citresewn.cache_ms.tooltip": "Quanto spesso le cache cit dovrebbero essere ricaricate.\\nValori più alti daranno più performance.\\nValori più bassi faranno caricare prima i cit.\\n\"Tempo Reale\" rimuovve le cache del tutto caricando le cits ogni frame.",
+ "config.citresewn.cache_ms.ticks.0": "TEMPO REALE",
+ "config.citresewn.cache_ms.ticks.1": "OGNI TICK",
+ "config.citresewn.cache_ms.ticks.any": "OGNI %s TICK",
+ "pack.incompatible.broken_paths": "(Contiene percorsi non funzionanti)",
+ "pack.incompatible.confirm.broken_paths": "Questo pack contiene persorsi non funzionanti e il supporto per questi potrebbe mancare in futuro. Contatta l'autore del pack per rimuovere questo avviso (~ CIT Resewn)"
+}
diff --git a/src/main/resources/assets/citresewn/lang/pt_br.json b/src/main/resources/assets/citresewn/lang/pt_br.json
new file mode 100644
index 0000000..f5a6f5b
--- /dev/null
+++ b/src/main/resources/assets/citresewn/lang/pt_br.json
@@ -0,0 +1,26 @@
+{
+ "config.citresewn.title": "Configuração Refeita CIT",
+ "config.citresewn.configure": "Configurar",
+
+ "config.citresewn.enabled.title": "Habilitado",
+ "config.citresewn.enabled.tooltip": "O CIT Resewn deve carregar e injetar citações de pacotes de recursos",
+
+ "config.citresewn.mute_errors.title": "Silenciar erros de carregamento",
+ "config.citresewn.mute_errors.tooltip": "O CIT Resewn não deve registrar erros cit",
+
+ "config.citresewn.mute_warns.title": "Silenciar avisos de carregamento",
+ "config.citresewn.mute_warns.tooltip": "O CIT Resewn não deve registrar os avisos do cit",
+
+ "config.citresewn.broken_paths.title": "Permitir caminhos quebrados em resourcepacks",
+ "config.citresewn.broken_paths.tooltip": "Permite que pacotes com caminhos de recursos ilegais sejam carregados.\nPode causar problemas!",
+
+ "config.citresewn.cache_ms.title": "Cache",
+ "config.citresewn.cache_ms.tooltip": "Com que frequência o cache cit deve ser atualizado.\nValores mais altos darão mais desempenho.\nValores mais baixos farão com que as citações sejam atualizadas mais rapidamente.\nREALTIME removerá o cache completamente,\n fazendo com que os itens verifiquem citações a cada quadro.",
+ "config.citresewn.cache_ms.ticks.0": "TEMPO REAL",
+ "config.citresewn.cache_ms.ticks.1": "CADA TICK",
+ "config.citresewn.cache_ms.ticks.any": "CADA %s TICKS",
+
+
+ "pack.incompatible.broken_paths": "(Contém caminhos quebrados)",
+ "pack.incompatible.confirm.broken_paths": "Este pacote contém caminhos quebrados e o suporte para ele pode ser descartado no futuro. Entre em contato com o autor do pacote para remover este aviso. (~ CIT Resewn)"
+ } \ No newline at end of file
diff --git a/src/main/resources/assets/citresewn/lang/zh_tw.json b/src/main/resources/assets/citresewn/lang/zh_tw.json
new file mode 100644
index 0000000..a85fbe4
--- /dev/null
+++ b/src/main/resources/assets/citresewn/lang/zh_tw.json
@@ -0,0 +1,26 @@
+{
+ "config.citresewn.title": "CIT Resewn 設定檔",
+ "config.citresewn.configure": "設定",
+
+ "config.citresewn.enabled.title": "啟用",
+ "config.citresewn.enabled.tooltip": "CIT Resewn 是否載入並注入來自資源包的自訂物品紋理",
+
+ "config.citresewn.mute_errors.title": "記錄「載入錯誤」訊息",
+ "config.citresewn.mute_errors.tooltip": "CIT Resewn 是否記錄「自訂物品紋理」的載入錯誤訊息",
+
+ "config.citresewn.mute_warns.title": "記錄「載入警告」訊息",
+ "config.citresewn.mute_warns.tooltip": "CIT Resewn 是否記錄「自訂物品紋理」的載入警告訊息",
+
+ "config.citresewn.broken_paths.title": "允許路徑損壞的資源包",
+ "config.citresewn.broken_paths.tooltip": "允許載入有違反規則路徑的資源包。\n可能會造成問題!",
+
+ "config.citresewn.cache_ms.title": "快取",
+ "config.citresewn.cache_ms.tooltip": "間隔多久刷新自訂物品紋理的快取,\n數值越高需要使用更多效能。\n即時載入將會移除整個快取,\n並在每幀下檢查自訂物品紋理。",
+ "config.citresewn.cache_ms.ticks.0": "即時",
+ "config.citresewn.cache_ms.ticks.1": "每 Tick",
+ "config.citresewn.cache_ms.ticks.any": "每 %s Ticks",
+
+
+ "pack.incompatible.broken_paths": "(包含損壞路徑)",
+ "pack.incompatible.confirm.broken_paths": "這個資源包包含了損壞路徑,未來可能移除對於它的支援。請聯繫資源包作者來移除這個警告。(~CIT Resewn)"
+} \ No newline at end of file
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 0822b80..66bd512 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -23,7 +23,7 @@
"depends": {
"fabric": "*",
"fabricloader": "*",
- "minecraft": "1.19.x"
+ "minecraft": "~1.19.3"
},
"recommends": {
"modmenu": "*",