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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user