package com.minelittlepony.unicopia.util; import java.util.stream.Stream; import com.mojang.serialization.Lifecycle; import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder; import net.minecraft.tag.TagKey; import net.minecraft.util.Identifier; import net.minecraft.util.registry.*; import net.minecraft.world.World; public interface Registries { static Registry createSimple(Identifier id) { return FabricRegistryBuilder.from(new SimpleRegistry(RegistryKey.ofRegistry(id), Lifecycle.stable(), null)).buildAndRegister(); } static Registry createDefaulted(Identifier id, String def) { return FabricRegistryBuilder.from(new DefaultedRegistry(def, RegistryKey.ofRegistry(id), Lifecycle.stable(), null)).buildAndRegister(); } static RegistryEntryList entriesForTag(World world, TagKey key) { return world.getRegistryManager().get(key.registry()).getOrCreateEntryList(key); } static Stream valuesForTag(World world, TagKey key) { return entriesForTag(world, key).stream().map(RegistryEntry::value); } }