/* * Decompiled with CFR 0.152. */ package net.minecraft.core; import java.util.Optional; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; import net.minecraft.tags.TagKey; import net.minecraft.util.RandomSource; public interface HolderGetter { public Optional> get(ResourceKey var1); default public Holder.Reference getOrThrow(ResourceKey id) { return this.get(id).orElseThrow(() -> new IllegalStateException("Missing element " + String.valueOf(id))); } public Optional> get(TagKey var1); default public HolderSet.Named getOrThrow(TagKey id) { return this.get(id).orElseThrow(() -> new IllegalStateException("Missing tag " + String.valueOf(id))); } default public Optional> getRandomElementOf(TagKey tag, RandomSource random) { return this.get(tag).flatMap(holderSet -> holderSet.getRandomElement(random)); } public static interface Provider { public Optional> lookup(ResourceKey> var1); default public HolderGetter lookupOrThrow(ResourceKey> key) { return this.lookup(key).orElseThrow(() -> new IllegalStateException("Registry " + String.valueOf(key.identifier()) + " not found")); } default public Optional> get(ResourceKey id) { return this.lookup(id.registryKey()).flatMap(l -> l.get(id)); } default public Holder.Reference getOrThrow(ResourceKey id) { return (Holder.Reference)this.lookup(id.registryKey()).flatMap(l -> l.get(id)).orElseThrow(() -> new IllegalStateException("Missing element " + String.valueOf(id))); } } }