aboutsummaryrefslogtreecommitdiff
path: root/defaults
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-07-01 09:54:52 +0300
committerSHsuperCM <shsupercm@gmail.com>2022-07-01 09:54:52 +0300
commit9ff75d0c4622e830366b3818366618f6c4b9a8c7 (patch)
treefb40ae8e76db9328803d82cedfa3668fa85186f5 /defaults
parenta11cb51ed936edab28369fa661d167c912abc5cd (diff)
downloadCITResewn-9ff75d0c4622e830366b3818366618f6c4b9a8c7.tar.gz
CITResewn-9ff75d0c4622e830366b3818366618f6c4b9a8c7.tar.bz2
CITResewn-9ff75d0c4622e830366b3818366618f6c4b9a8c7.zip
Removed usage of ResewnTextureIdentifier
Could possibly help with #149
Diffstat (limited to 'defaults')
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeItem.java15
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/common/ResewnTextureIdentifier.java12
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ModelLoaderMixin.java4
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/SpriteAtlasTextureMixin.java9
4 files changed, 14 insertions, 26 deletions
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 d442559..f7ccbf4 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
@@ -23,7 +23,6 @@ import shcm.shsupercm.fabric.citresewn.api.CITTypeContainer;
import shcm.shsupercm.fabric.citresewn.cit.*;
import shcm.shsupercm.fabric.citresewn.defaults.cit.conditions.ConditionItems;
import shcm.shsupercm.fabric.citresewn.defaults.common.ResewnItemModelIdentifier;
-import shcm.shsupercm.fabric.citresewn.defaults.common.ResewnTextureIdentifier;
import shcm.shsupercm.fabric.citresewn.defaults.mixin.types.item.JsonUnbakedModelAccessor;
import shcm.shsupercm.fabric.citresewn.ex.CITParsingException;
import shcm.shsupercm.fabric.citresewn.pack.format.PropertyGroup;
@@ -130,7 +129,7 @@ public class TypeItem extends CITType {
if (textureProp != null) {
assetIdentifier = resolveAsset(properties.identifier, textureProp, "textures", ".png", resourceManager);
if (assetIdentifier != null)
- textureOverrideMap.put(null, Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new ResewnTextureIdentifier(assetIdentifier))));
+ textureOverrideMap.put(null, Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, assetIdentifier)));
else
throw new CITParsingException("Cannot resolve path", properties, textureProp.position());
}
@@ -141,7 +140,7 @@ public class TypeItem extends CITType {
if (subIdentifier == null)
throw new CITParsingException("Cannot resolve path", properties, property.position());
- textureOverrideMap.put(property.keyMetadata(), Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new ResewnTextureIdentifier(subIdentifier))));
+ textureOverrideMap.put(property.keyMetadata(), Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, subIdentifier)));
}
}
@@ -159,9 +158,9 @@ public class TypeItem extends CITType {
textureOverrideMap.replaceAll((layerName, originalTextureEither) -> {
Identifier textureIdentifier = assetIdentifiers.remove(originalTextureEither.map(SpriteIdentifier::getTextureId, Identifier::new));
if (textureIdentifier != null)
- return Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new ResewnTextureIdentifier(textureIdentifier)));
+ return Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, textureIdentifier));
if (defaultAsset != null)
- return Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new ResewnTextureIdentifier(defaultAsset)));
+ return Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, defaultAsset));
return null;
});
@@ -313,7 +312,7 @@ public class TypeItem extends CITType {
if (left.isPresent()) {
Identifier resolvedIdentifier = resolveAsset(identifier, left.get().getTextureId().getPath(), "textures", ".png", resourceManager);
if (resolvedIdentifier != null)
- return Either.left(new SpriteIdentifier(left.get().getAtlasId(), new ResewnTextureIdentifier(resolvedIdentifier)));
+ return Either.left(new SpriteIdentifier(left.get().getAtlasId(), resolvedIdentifier));
}
return original;
});
@@ -368,7 +367,7 @@ public class TypeItem extends CITType {
} else if (identifier.getPath().endsWith(".png")) {
json = getModelForFirstItemType(resourceManager);
if (json == null)
- json = new JsonUnbakedModel(new Identifier("minecraft", "item/generated"), new ArrayList<>(), ImmutableMap.of("layer0", Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new ResewnTextureIdentifier(identifier)))), true, JsonUnbakedModel.GuiLight.ITEM, ModelTransformation.NONE, new ArrayList<>());
+ json = new JsonUnbakedModel(new Identifier("minecraft", "item/generated"), new ArrayList<>(), ImmutableMap.of("layer0", Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, identifier))), true, JsonUnbakedModel.GuiLight.ITEM, ModelTransformation.NONE, new ArrayList<>());
json.getOverrides().clear();
json.id = identifier.toString();
json.id = json.id.substring(0, json.id.length() - 4);
@@ -380,7 +379,7 @@ public class TypeItem extends CITType {
textureOverride = textureOverrideMap.get(null);
return textureOverride == null ? originalTextureEither : textureOverride;
} else
- return Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new ResewnTextureIdentifier(identifier)));
+ return Either.left(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, identifier));
});
return json;
}
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/common/ResewnTextureIdentifier.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/common/ResewnTextureIdentifier.java
deleted file mode 100644
index a6dd2ef..0000000
--- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/common/ResewnTextureIdentifier.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package shcm.shsupercm.fabric.citresewn.defaults.common;
-
-import net.minecraft.util.Identifier;
-
-/**
- * Marks path identifiers as forced literal texture paths.
- */
-public class ResewnTextureIdentifier extends Identifier {
- public ResewnTextureIdentifier(Identifier identifier) {
- super(identifier.getNamespace(), identifier.getPath());
- }
-}
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 333ad6c..a1e8e54 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
@@ -5,7 +5,6 @@ import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.json.JsonUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverride;
import net.minecraft.client.util.SpriteIdentifier;
-import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import org.apache.commons.io.IOUtils;
@@ -17,7 +16,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import shcm.shsupercm.fabric.citresewn.cit.CITType;
import shcm.shsupercm.fabric.citresewn.defaults.common.ResewnItemModelIdentifier;
-import shcm.shsupercm.fabric.citresewn.defaults.common.ResewnTextureIdentifier;
import shcm.shsupercm.fabric.citresewn.defaults.mixin.types.item.JsonUnbakedModelAccessor;
import java.io.InputStream;
@@ -48,7 +46,7 @@ public class ModelLoaderMixin {
if (originalPath.startsWith("./") || (split.length > 2 && split[1].equals("cit"))) {
Identifier resolvedIdentifier = CITType.resolveAsset(id, originalPath, "textures", ".png", resourceManager);
if (resolvedIdentifier != null)
- return Either.left(new SpriteIdentifier(left.get().getAtlasId(), new ResewnTextureIdentifier(resolvedIdentifier)));
+ return Either.left(new SpriteIdentifier(left.get().getAtlasId(), resolvedIdentifier));
}
}
return original;
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/SpriteAtlasTextureMixin.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/SpriteAtlasTextureMixin.java
index 61eff5c..0e05a42 100644
--- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/SpriteAtlasTextureMixin.java
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/SpriteAtlasTextureMixin.java
@@ -2,17 +2,20 @@ package shcm.shsupercm.fabric.citresewn.defaults.mixin.common;
import net.minecraft.client.texture.SpriteAtlasTexture;
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.defaults.common.ResewnTextureIdentifier;
@Mixin(SpriteAtlasTexture.class)
public class SpriteAtlasTextureMixin {
+ @Shadow @Final private static String PNG_EXTENSION;
+
@Inject(method = "getTexturePath", cancellable = true, at = @At("HEAD"))
- public void forceLiteralResewnTextureIdentifier(Identifier id, CallbackInfoReturnable<Identifier> cir) {
- if (id instanceof ResewnTextureIdentifier)
+ public void citresewn$forceAbsoluteTextureIdentifier(Identifier id, CallbackInfoReturnable<Identifier> cir) {
+ if (id.getPath().endsWith(PNG_EXTENSION))
cir.setReturnValue(id);
}
}