1
0
mirror of https://github.com/GeyserMC/Rainbow.git synced 2025-12-19 14:59:16 +00:00

Check for conflicts when mapping items

This commit is contained in:
Eclipse
2025-06-29 12:30:52 +00:00
parent 449a9a6283
commit 3c028ee652
2 changed files with 21 additions and 1 deletions

View File

@@ -55,4 +55,20 @@ public record GeyserMapping(ResourceLocation model, ResourceLocation bedrockIden
).apply(instance, BedrockOptions::new)
);
}
public boolean conflictsWith(GeyserMapping other) {
if (!model.equals(other.model)) {
return false;
} else if (predicates.size() == other.predicates.size()) {
boolean predicatesAreEqual = true;
for (GeyserPredicate predicate : predicates) {
if (!other.predicates.contains(predicate)) {
predicatesAreEqual = false;
break;
}
}
return predicatesAreEqual;
}
return false;
}
}

View File

@@ -39,7 +39,11 @@ public class GeyserMappings {
}
public void map(Holder<Item> item, GeyserMapping mapping) {
// TODO conflict detection
for (GeyserMapping existing : mappings.get(item)) {
if (existing.conflictsWith(mapping)) {
throw new IllegalArgumentException("Mapping conflicts with existing mapping");
}
}
mappings.put(item, mapping);
}