diff options
author | SHsuperCM <shsupercm@gmail.com> | 2021-08-31 05:36:05 +0300 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2021-08-31 05:36:05 +0300 |
commit | 2f618648c014fc75d3708cc91f8a1663004fc22d (patch) | |
tree | ef36f34e04ccdc2feb165183f6c185697647b527 /src/main/java | |
parent | 4d3a6afd39fbd3a2e48d9ac3f3af5a58b80bb6e7 (diff) | |
download | CITResewn-2f618648c014fc75d3708cc91f8a1663004fc22d.tar.gz CITResewn-2f618648c014fc75d3708cc91f8a1663004fc22d.tar.bz2 CITResewn-2f618648c014fc75d3708cc91f8a1663004fc22d.zip |
v0.4.3: Fixed full cit paths not recognized in json models, fixed nbt exact match bug
Diffstat (limited to 'src/main/java')
4 files changed, 30 insertions, 34 deletions
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; |