aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-02-15 12:21:57 +0200
committerSHsuperCM <shsupercm@gmail.com>2022-02-15 12:28:36 +0200
commit972e6c330d03f205ab738ed28c4e47496f30e92d (patch)
treec90360cb169cdb53b608ede798020ae2ac20d85e /src/main/java/shcm
parent32caf009812501e9e9a8f9d835726f12723c4a17 (diff)
downloadCITResewn-972e6c330d03f205ab738ed28c4e47496f30e92d.tar.gz
CITResewn-972e6c330d03f205ab738ed28c4e47496f30e92d.tar.bz2
CITResewn-972e6c330d03f205ab738ed28c4e47496f30e92d.zip
Ported item type (missing asset resolution)
Diffstat (limited to 'src/main/java/shcm')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITContext.java3
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java2
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITType.java6
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/ex/CITParsingException.java2
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/pack/format/PropertyGroup.java6
5 files changed, 14 insertions, 5 deletions
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 99cdbf0..b2dd2cd 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITContext.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITContext.java
@@ -1,5 +1,6 @@
package shcm.shsupercm.fabric.citresewn.cit;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@@ -13,7 +14,7 @@ public class CITContext {
public CITContext(ItemStack stack, World world, LivingEntity entity) {
this.stack = stack;
- this.world = world;
+ this.world = world == null ? MinecraftClient.getInstance().world : world;
this.entity = entity;
}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java
index 33f6367..fb0f793 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITRegistry.java
@@ -55,7 +55,7 @@ public class CITRegistry {
public static CITType parseType(PropertyGroup properties) throws CITParsingException {
Identifier type = new Identifier("citresewn", "item");
- PropertyValue propertiesType = properties.getLast("citresewn", "type");
+ PropertyValue propertiesType = properties.getLastWithoutMetadata("citresewn", "type");
if (propertiesType != null) {
String value = propertiesType.value();
if (!value.contains(":"))
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITType.java b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITType.java
index abbe755..b618dde 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITType.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/cit/CITType.java
@@ -1,10 +1,16 @@
package shcm.shsupercm.fabric.citresewn.cit;
+import shcm.shsupercm.fabric.citresewn.CITResewn;
import shcm.shsupercm.fabric.citresewn.ex.CITParsingException;
import shcm.shsupercm.fabric.citresewn.pack.format.PropertyGroup;
+import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue;
import java.util.List;
public abstract class CITType {
public abstract void load(List<? extends CITCondition> conditions, PropertyGroup properties) throws CITParsingException;
+
+ protected void warn(String message, PropertyValue value, PropertyGroup properties) {
+ CITResewn.logWarnLoading("Warning: " + CITParsingException.descriptionOf(message, properties, value.position()));
+ }
}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/ex/CITParsingException.java b/src/main/java/shcm/shsupercm/fabric/citresewn/ex/CITParsingException.java
index 964b58d..384014b 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/ex/CITParsingException.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/ex/CITParsingException.java
@@ -8,6 +8,6 @@ public class CITParsingException extends Exception {
}
public static String descriptionOf(String message, PropertyGroup propertyGroup, int position) {
- return message + " at " + position + " in " + propertyGroup.identifier.toString() + " from " + propertyGroup.packName;
+ return message + (position != -1 ? " line " + position : "") + " in " + propertyGroup.identifier.toString() + " from " + propertyGroup.packName;
}
}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/format/PropertyGroup.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/format/PropertyGroup.java
index 6955ac1..b2806a2 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/format/PropertyGroup.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/format/PropertyGroup.java
@@ -40,9 +40,11 @@ public abstract class PropertyGroup {
return values;
}
- public PropertyValue getLast(String namespace, String... pathAliases) {
+ public PropertyValue getLastWithoutMetadata(String namespace, String... pathAliases) {
PropertyValue value = null;
- for (Iterator<PropertyValue> iterator = get(namespace, pathAliases).iterator(); iterator.hasNext(); value = iterator.next());
+ for (PropertyValue next : get(namespace, pathAliases))
+ if (next.keyMetadata() == null)
+ value = next;
return value;
}