mirror of
https://github.com/AlmostReliable/almostunified.git
synced 2024-11-23 08:08:25 -05:00
fix runtime not being available on multiple unification tags
This commit is contained in:
parent
9769c25a1c
commit
5d76128d1b
2 changed files with 14 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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<UnificationEntry<Item>> createdEntries = new HashSet<>();
|
||||
private final Map<UnificationEntry<Item>, TagKey<Item>> entriesToTags = new HashMap<>();
|
||||
private final Map<TagKey<Item>, Set<UnificationEntry<Item>>> tagsToEntries = new HashMap<>();
|
||||
|
||||
private void put(TagKey<Item> tag, UnificationEntry<Item> 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue