diff --git a/CHANGELOG.md b/CHANGELOG.md index 14ddabb..9063833 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,10 @@ and this project adheres to [Semantic Versioning]. ## Unreleased +- added better logging for cases where items are assigned to multiple unification tags - fixed crash when runtime isn't loaded ([#101](https://github.com/AlmostReliable/almostunified/issues/101)) - fixed newly created custom tags not being considered for unification +- fixed runtime not being available when items are assigned to multiple unification tags ## [1.2.0] - 2024-10-06 diff --git a/Common/src/main/java/com/almostreliable/unified/unification/UnificationLookupImpl.java b/Common/src/main/java/com/almostreliable/unified/unification/UnificationLookupImpl.java index e7041cd..991489a 100644 --- a/Common/src/main/java/com/almostreliable/unified/unification/UnificationLookupImpl.java +++ b/Common/src/main/java/com/almostreliable/unified/unification/UnificationLookupImpl.java @@ -7,6 +7,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; +import com.almostreliable.unified.AlmostUnifiedCommon; import com.almostreliable.unified.api.unification.ModPriorities; import com.almostreliable.unified.api.unification.StoneVariants; import com.almostreliable.unified.api.unification.TagSubstitutions; @@ -117,15 +118,22 @@ public final class UnificationLookupImpl implements UnificationLookup { public static class Builder { - private final Set> createdEntries = new HashSet<>(); + private final Map, TagKey> entriesToTags = new HashMap<>(); private final Map, Set>> tagsToEntries = new HashMap<>(); private void put(TagKey tag, UnificationEntry entry) { - if (createdEntries.contains(entry)) { - throw new IllegalStateException("entry " + entry + " already created"); + if (entriesToTags.containsKey(entry)) { + var boundTag = entriesToTags.get(entry); + AlmostUnifiedCommon.LOGGER.error( + "Unification entry for item '{}' with tag '#{}' is already part of tag '#{}'.", + entry.id(), + tag.location(), + boundTag.location() + ); + return; } - createdEntries.add(entry); + entriesToTags.put(entry, tag); tagsToEntries.computeIfAbsent(tag, $ -> new HashSet<>()).add(entry); }