From 429b299266e9633e325e4d57e2a582fde1666e7a Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Fri, 18 Feb 2022 08:52:52 +0200 Subject: Fixed item name from properties file name --- .../citresewn/defaults/cit/conditions/ConditionItems.java | 5 +++++ .../fabric/citresewn/defaults/cit/types/TypeItem.java | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'defaults/src/main/java/shcm/shsupercm/fabric') diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionItems.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionItems.java index 73b79e0..117aa47 100644 --- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionItems.java +++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/conditions/ConditionItems.java @@ -26,6 +26,11 @@ public class ConditionItems extends ListCondition super(ItemCondition.class, ItemCondition::new); } + public ConditionItems(Item... items) { + this(); + this.items = items; + } + @Override public void load(PropertyValue value, PropertyGroup properties) throws CITParsingException { super.load(value, properties); 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 02a2bf1..aaca882 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 @@ -68,7 +68,16 @@ public class TypeItem extends CITType { items.addAll(Arrays.asList(conditionItems.items)); if (this.items.size() == 0) - throw new CITParsingException("Not targeting any item type", properties, -1); + try { + Identifier propertiesName = new Identifier(properties.stripName()); + if (!Registry.ITEM.containsId(propertiesName)) + throw new Exception(); + Item item = Registry.ITEM.get(propertiesName); + conditions.add(new ConditionItems(item)); + this.items.add(item); + } catch (Exception ignored) { + throw new CITParsingException("Not targeting any item type", properties, -1); + } Identifier assetIdentifier; PropertyValue modelProp = properties.getLastWithoutMetadata("citresewn", "model"); -- cgit