Tags
Wyck models Minecraft tags with two types:
TagKey: a named reference to a tag, likeminecraft:logs. It points at a tag and does not carry its contents.TagSet: a group of entries that is either an explicit set of elements or a reference to a named tag.
TagSet wraps vanilla’s HolderSet and TagKey, which is either an inline list, or a tag. Anywhere worldgen accepts a
group of blocks, it accepts either form.
Tag Keys
Section titled “Tag Keys”A TagKey is a ResourceKey
plus the registry the tag lives in.
import dev.wyck.tags.TagKey;
import dev.wyck.keys.ResourceKey;
import org.bukkit.Tag;
// Reference a vanilla tag by identifier.
TagKey logs = TagKey.blocks(ResourceKey.of("minecraft:logs"));
// Or reuse a Bukkit tag constant.
TagKey leaves = TagKey.blocks(Tag.LEAVES); Tag Sets
Section titled “Tag Sets”A TagSet holds one of two things, and
isBlockSet() or isTag()
tell you which:
- A set of elements: listed explicitly, e.g. stone and dirt.
- A tag reference: a
TagKeypointing at a named tag.
import dev.wyck.tags.TagSet;
import dev.wyck.keys.ResourceKey;
import org.bukkit.Material;
// An explicit set of blocks — no name, so it cannot be registered.
TagSet<Material> ores = TagSet.ofBlocks(Material.IRON_ORE, Material.GOLD_ORE);
// A reference to a tag that already exists.
TagSet<Material> logs = TagSet.ofBlockTag(ResourceKey.of("minecraft:logs")); Registering a Tag Set
Section titled “Registering a Tag Set”register() binds a named set of elements into the registry as a new
tag, afterwards the tag behaves like any other tag.
import dev.wyck.tags.TagSet;
import dev.wyck.keys.ResourceKey;
import org.bukkit.Material;
TagSet.ofBlocks(ResourceKey.of("wyck:test_tag"), Material.STONE, Material.DIRT)
.register();
// Now referenceable like any other tag.
TagSet<Material> reference = TagSet.ofBlockTag(ResourceKey.of("wyck:test_tag")); Here’s an example of creating (and registering) a TagSet with a builder:
import dev.wyck.tags.TagSet;
import dev.wyck.keys.ResourceKey;
import org.bukkit.Material;
TagSet<Material> tag = TagSet.blocks()
.resourceKey(ResourceKey.of("wyck:my_tag"))
.values(Material.STONE, Material.DIRT)
.register(); // Use #build() instead if you don't want to register it!