diff options
6 files changed, 31 insertions, 36 deletions
diff --git a/gradle.properties b/gradle.properties index 117cb75..668c8a5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.17.1 yarn_mappings=1.17.1+build.39 loader_version=0.11.6 # Mod Properties -mod_version=0.4.2 +mod_version=0.4.3 maven_group=shcm.shsupercm.fabric archives_base_name=CITResewn diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/IdentifierMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/IdentifierMixin.java deleted file mode 100644 index 49a0eb9..0000000 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/IdentifierMixin.java +++ /dev/null @@ -1,17 +0,0 @@ -package shcm.shsupercm.fabric.citresewn.mixin; - -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(Identifier.class) -public class IdentifierMixin { - /*//todo remove - @Inject(method = "isPathValid(Ljava/lang/String;)Z", cancellable = true, at = @At("HEAD")) - private static void isPathValid(String path, CallbackInfoReturnable<Boolean> ci) { - if(path.startsWith("textures/block") || path.startsWith("block") || path.startsWith("optifine")) - ci.setReturnValue(true); return; - }*/ -} 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 07f08fd..78e1a69 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelLoaderMixin.java @@ -135,19 +135,26 @@ public abstract class ModelLoaderMixin { ((JsonUnbakedModelAccessor) json).getTextureMap().replaceAll((layer, original) -> { Optional<SpriteIdentifier> left = original.left(); - if (left.isPresent() && left.get().getTextureId().getPath().startsWith("./")) { - Identifier resolvedIdentifier = CIT.resolvePath(id, left.get().getTextureId().getPath(), ".png", null); - if (resolvedIdentifier != null) - return Either.left(new SpriteIdentifier(left.get().getAtlasId(), new ResewnTextureIdentifier(resolvedIdentifier))); + if (left.isPresent()) { + String originalPath = left.get().getTextureId().getPath(); + String[] split = originalPath.split("/"); + if (originalPath.startsWith("./") || (split.length > 2 && split[1].equals("cit"))) { + Identifier resolvedIdentifier = CIT.resolvePath(id, originalPath, ".png", null); + if (resolvedIdentifier != null) + return Either.left(new SpriteIdentifier(left.get().getAtlasId(), new ResewnTextureIdentifier(resolvedIdentifier))); + } } return original; }); Identifier parentId = ((JsonUnbakedModelAccessor) json).getParentId(); - if (parentId.getPath().startsWith("./")) { - parentId = CIT.resolvePath(id, parentId.getPath(), ".json", null); - if (parentId != null) - ((JsonUnbakedModelAccessor) json).setParentId(new ResewnItemModelIdentifier(parentId)); + if (parentId != null) { + String[] parentIdPathSplit = parentId.getPath().split("/"); + if (parentId.getPath().startsWith("./") || (parentIdPathSplit.length > 2 && parentIdPathSplit[1].equals("cit"))) { + parentId = CIT.resolvePath(id, parentId.getPath(), ".json", null); + if (parentId != null) + ((JsonUnbakedModelAccessor) json).setParentId(new ResewnItemModelIdentifier(parentId)); + } } cir.setReturnValue(json); diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java index 3df4006..44b7e80 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java @@ -178,7 +178,6 @@ public abstract class CIT { final Pattern pattern = Pattern.compile(matchProperty); match = s -> pattern.matcher(caseSensitive ? s : s.toLowerCase()).matches(); } else { - matchProperty = caseSensitive ? matchProperty.substring(5) : matchProperty.substring(6).toLowerCase(Locale.ENGLISH); if ((path[path.length - 1].equals("Name") || path[path.length - 1].equals("Lore")) && !matchProperty.startsWith("{")) matchProperty = "{\"text\":\"" + matchProperty + "\"}"; final String pattern = matchProperty; diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITItem.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITItem.java index 6464863..280e8c1 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITItem.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITItem.java @@ -156,19 +156,26 @@ public class CITItem extends CIT { ((JsonUnbakedModelAccessor) json).getTextureMap().replaceAll((layer, original) -> { Optional<SpriteIdentifier> left = original.left(); - if (left.isPresent() && left.get().getTextureId().getPath().startsWith("./")) { - Identifier resolvedIdentifier = resolvePath(identifier, left.get().getTextureId().getPath(), ".png", pack.resourcePack); - if (resolvedIdentifier != null) - return Either.left(new SpriteIdentifier(left.get().getAtlasId(), new ResewnTextureIdentifier(resolvedIdentifier))); + if (left.isPresent()) { + String originalPath = left.get().getTextureId().getPath(); + String[] split = originalPath.split("/"); + if (originalPath.startsWith("./") || (split.length > 2 && split[1].equals("cit"))) { + Identifier resolvedIdentifier = CIT.resolvePath(identifier, originalPath, ".png", pack.resourcePack); + if (resolvedIdentifier != null) + return Either.left(new SpriteIdentifier(left.get().getAtlasId(), new ResewnTextureIdentifier(resolvedIdentifier))); + } } return original; }); Identifier parentId = ((JsonUnbakedModelAccessor) json).getParentId(); - if (parentId.getPath().startsWith("./")) { - parentId = resolvePath(identifier, parentId.getPath(), ".json", pack.resourcePack); - if (parentId != null) - ((JsonUnbakedModelAccessor) json).setParentId(new ResewnItemModelIdentifier(parentId)); + if (parentId != null) { + String[] parentIdPathSplit = parentId.getPath().split("/"); + if (parentId.getPath().startsWith("./") || (parentIdPathSplit.length > 2 && parentIdPathSplit[1].equals("cit"))) { + parentId = resolvePath(identifier, parentId.getPath(), ".json", pack.resourcePack); + if (parentId != null) + ((JsonUnbakedModelAccessor) json).setParentId(new ResewnItemModelIdentifier(parentId)); + } } return json; diff --git a/src/main/resources/citresewn.mixins.json b/src/main/resources/citresewn.mixins.json index 30fd412..4c6a140 100644 --- a/src/main/resources/citresewn.mixins.json +++ b/src/main/resources/citresewn.mixins.json @@ -6,7 +6,6 @@ "mixins": [ "ArmorFeatureRendererMixin", "ElytraFeatureRendererMixin", - "IdentifierMixin", "ItemRendererMixin", "JsonUnbakedModelAccessor", "ModelLoaderMixin", |