aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm/shsupercm/fabric/citresewn/pack
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2021-08-22 20:38:54 +0300
committerSHsuperCM <shsupercm@gmail.com>2021-08-22 20:38:54 +0300
commit69a8dd26d808c49c865575486849ee9093c82e0e (patch)
tree921f7d1ece5391600fddf25d03e4675f6e2a7ec6 /src/main/java/shcm/shsupercm/fabric/citresewn/pack
parent38c7261feca5e3a054109d58794dc62615a09557 (diff)
downloadCITResewn-69a8dd26d808c49c865575486849ee9093c82e0e.tar.gz
CITResewn-69a8dd26d808c49c865575486849ee9093c82e0e.tar.bz2
CITResewn-69a8dd26d808c49c865575486849ee9093c82e0e.zip
Started work on baking CITItem and started item mixin
Diffstat (limited to 'src/main/java/shcm/shsupercm/fabric/citresewn/pack')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITItem.java49
1 files changed, 49 insertions, 0 deletions
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 7a7e963..a7d0c10 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
@@ -1,13 +1,62 @@
package shcm.shsupercm.fabric.citresewn.pack.cits;
+import net.minecraft.client.render.model.BakedModel;
import net.minecraft.util.Identifier;
+import shcm.shsupercm.fabric.citresewn.CITResewn;
import shcm.shsupercm.fabric.citresewn.ex.CITParseException;
import shcm.shsupercm.fabric.citresewn.pack.CITPack;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
public class CITItem extends CIT {
+ private BakedModel bakedModel = null;
+ private HashMap<String, BakedModel> subItems = null;
+
public CITItem(CITPack pack, Identifier identifier, Properties properties) throws CITParseException {
super(pack, identifier, properties);
+ try {
+ Identifier modelIdentifier = resolvePath(identifier, properties.getProperty("model"), ".json", pack.resourcePack);
+ Map<String, Identifier> subIdentifiers = new HashMap<>();
+
+ for (Object o : properties.keySet())
+ if (o instanceof String property && property.startsWith("model.")) {
+ Identifier subIdentifier = resolvePath(identifier, properties.getProperty(property), ".json", pack.resourcePack);
+ if (subIdentifier == null)
+ throw new Exception("Cannot resolve path for " + property);
+ subIdentifiers.put(property.substring(5), subIdentifier);
+ }
+
+ if (modelIdentifier == null && subIdentifiers.size() == 0) {
+ Identifier textureIdentifier = resolvePath(identifier, properties.getProperty("texture"), ".png", pack.resourcePack);
+
+ for (Object o : properties.keySet())
+ if (o instanceof String property && property.startsWith("texture.")) {
+ Identifier subIdentifier = resolvePath(identifier, properties.getProperty(property), ".png", pack.resourcePack);
+ if (subIdentifier == null)
+ throw new Exception("Cannot resolve path for " + property);
+ subIdentifiers.put(property.substring(5), subIdentifier);
+ }
+
+ if (textureIdentifier == null && subIdentifiers.size() == 0)
+ throw new Exception("Cannot resolve path for model/texture");
+
+ // load textures
+ }
+
+ // load models
+ } catch (Exception e) {
+ throw new CITParseException(pack.resourcePack, identifier, (e.getClass() == Exception.class ? "" : e.getClass().getSimpleName() + ": ") + e.getMessage());
+ }
+ }
+
+ public BakedModel getBakedModel(BakedModel originalModel) {
+
+ String subItemName;
+ if (originalModel == null || (subItemName = CITResewn.INSTANCE.bakedOverridesCache.get(originalModel)) == null)
+ return this.bakedModel;
+
+ return this.subItems == null ? this.bakedModel : this.subItems.getOrDefault(subItemName, this.bakedModel);
}
}