package net.minecraft.client.searchtree; import com.google.common.collect.ImmutableList; import java.util.Comparator; import java.util.List; import java.util.function.Function; import java.util.function.ToIntFunction; import java.util.stream.Stream; import net.minecraft.Util; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class IdSearchTree implements SearchTree { protected final Comparator additionOrder; protected final ResourceLocationSearchTree resourceLocationSearchTree; public IdSearchTree(Function> p_235167_, List p_235168_) { ToIntFunction tointfunction = Util.createIndexLookup(p_235168_); this.additionOrder = Comparator.comparingInt(tointfunction); this.resourceLocationSearchTree = ResourceLocationSearchTree.create(p_235168_, p_235167_); } @Override public List search(String p_235173_) { int i = p_235173_.indexOf(58); return i == -1 ? this.searchPlainText(p_235173_) : this.searchResourceLocation(p_235173_.substring(0, i).trim(), p_235173_.substring(i + 1).trim()); } protected List searchPlainText(String p_235169_) { return this.resourceLocationSearchTree.searchPath(p_235169_); } protected List searchResourceLocation(String p_235170_, String p_235171_) { List list = this.resourceLocationSearchTree.searchNamespace(p_235170_); List list1 = this.resourceLocationSearchTree.searchPath(p_235171_); return ImmutableList.copyOf(new IntersectionIterator<>(list.iterator(), list1.iterator(), this.additionOrder)); } }