mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
Update to 1.18.2
Co-authored-by: sciwhiz12 <[email protected]> Co-authored-by: Marc Hermans <[email protected]> Co-authored-by: LexManos <[email protected]> Co-authored-by: Curle <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
34291c1fb2
commit
425eff39ff
234 files changed
+2175
-3226
No files matched your search
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge - Forge Development LLC
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.TagCollection;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ReverseTagWrapper<T>
|
||||
{
|
||||
private final T target;
|
||||
private final Supplier<TagCollection<T>> colSupplier;
|
||||
|
||||
//This map is immutable we track its identity change.
|
||||
private Map<ResourceLocation, Tag<T>> colCache;
|
||||
private Set<ResourceLocation> cache = null;
|
||||
|
||||
public ReverseTagWrapper(T target, Supplier<TagCollection<T>> colSupplier)
|
||||
{
|
||||
this.target = target;
|
||||
this.colSupplier = colSupplier;
|
||||
}
|
||||
|
||||
public Set<ResourceLocation> getTagNames()
|
||||
{
|
||||
TagCollection<T> collection = colSupplier.get();
|
||||
if (cache == null || colCache != collection.getAllTags()) // Identity equals.
|
||||
{
|
||||
this.cache = Collections.unmodifiableSet(new HashSet<>(collection.getMatchingTags(target)));
|
||||
this.colCache = collection.getAllTags();
|
||||
}
|
||||
return this.cache;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user