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) {
|
public void add(TagKey<Biome> tagID, ResourceKey<Biome>... elements) {
|
||||||
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||||
Set<TagEntry> set = getSetForTag(tagID);
|
synchronized (this) {
|
||||||
for (ResourceKey<Biome> element : elements) {
|
Set<TagEntry> set = getSetForTag(tagID);
|
||||||
ResourceLocation id = element.location();
|
for (ResourceKey<Biome> element : elements) {
|
||||||
|
ResourceLocation id = element.location();
|
||||||
|
|
||||||
//only add if the set doesn't already contain the element
|
//only add if the set doesn't already contain the element
|
||||||
for (TagEntry tagEntry : set) {
|
for (TagEntry tagEntry : set) {
|
||||||
if (!tagEntry.elementOrTag().tag() && tagEntry.elementOrTag().id().equals(id)) {
|
if (!tagEntry.elementOrTag().tag() && tagEntry.elementOrTag().id().equals(id)) {
|
||||||
id = null;
|
id = null;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (id != null) {
|
||||||
|
set.add(TagEntry.element(id));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (id != null) {
|
|
||||||
set.add(TagEntry.element(id));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue