From 8823e77b989ab1035fa8813120177dd3a95ce863 Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Sun, 13 Feb 2022 07:49:24 +0200 Subject: Item type storage --- .../fabric/citresewn/defaults/cit/types/TypeItem.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'defaults') 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 58460aa..02c09d6 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 @@ -1,14 +1,16 @@ package shcm.shsupercm.fabric.citresewn.defaults.cit.types; import io.shcm.shsupercm.fabric.fletchingtable.api.Entrypoint; +import net.minecraft.item.Item; import shcm.shsupercm.fabric.citresewn.api.CITTypeContainer; +import shcm.shsupercm.fabric.citresewn.defaults.cit.conditions.ConditionItems; import shcm.shsupercm.fabric.citresewn.ex.CITParsingException; import shcm.shsupercm.fabric.citresewn.pack.cit.CIT; import shcm.shsupercm.fabric.citresewn.pack.cit.CITCondition; import shcm.shsupercm.fabric.citresewn.pack.cit.CITType; import shcm.shsupercm.fabric.citresewn.pack.format.PropertyGroup; -import java.util.List; +import java.util.*; public class TypeItem extends CITType { @Entrypoint(CITTypeContainer.ENTRYPOINT) @@ -24,13 +26,21 @@ public class TypeItem extends CITType { super(TypeItem.class, TypeItem::new, "item"); } + public Map> loaded = new IdentityHashMap<>(); + @Override public void load(List parsedCITs) { + for (CIT cit : parsedCITs) + for (CITCondition condition : cit.conditions) + if (condition instanceof ConditionItems items) + for (Item item : items.items) + if (item != null) + loaded.computeIfAbsent(item, i -> new LinkedHashSet<>()).add(cit); } @Override public void dispose() { - + loaded.clear(); } } } \ No newline at end of file -- cgit