Threadsafe biome add
This commit is contained in:
parent
2a6f62a0b9
commit
a95843d051
1 changed files with 13 additions and 11 deletions
|
@ -98,19 +98,21 @@ public class TagRegistry<T> {
|
|||
*/
|
||||
public void add(TagKey<Biome> tagID, ResourceKey<Biome>... elements) {
|
||||
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
Set<TagEntry> set = getSetForTag(tagID);
|
||||
for (ResourceKey<Biome> element : elements) {
|
||||
ResourceLocation id = element.location();
|
||||
synchronized (this) {
|
||||
Set<TagEntry> set = getSetForTag(tagID);
|
||||
for (ResourceKey<Biome> element : elements) {
|
||||
ResourceLocation id = element.location();
|
||||
|
||||
//only add if the set doesn't already contain the element
|
||||
for (TagEntry tagEntry : set) {
|
||||
if (!tagEntry.elementOrTag().tag() && tagEntry.elementOrTag().id().equals(id)) {
|
||||
id = null;
|
||||
break;
|
||||
//only add if the set doesn't already contain the element
|
||||
for (TagEntry tagEntry : set) {
|
||||
if (!tagEntry.elementOrTag().tag() && tagEntry.elementOrTag().id().equals(id)) {
|
||||
id = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (id != null) {
|
||||
set.add(TagEntry.element(id));
|
||||
}
|
||||
}
|
||||
if (id != null) {
|
||||
set.add(TagEntry.element(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue