use of org.spongepowered.api.tag.TagTemplate in project SpongeCommon by SpongePowered.
the class TagTest method registerTags.
@Listener
public void registerTags(final RegisterDataPackValueEvent<@NonNull TagTemplate> event) {
this.logger.info("Adding tags.");
final TagTemplate tagRegistration = TagTemplate.builder(TagTypes.BLOCK_TYPE).key(ResourceKey.of(this.pluginContainer, "wool")).addValue(BlockTypes.GRASS).build();
event.register(tagRegistration);
final TagTemplate woolLog = TagTemplate.builder(TagTypes.BLOCK_TYPE).key(BlockTypeTags.WOOL.location()).addValue(BlockTypes.OAK_LOG).build();
event.register(woolLog);
final TagTemplate woolGrass = TagTemplate.builder(TagTypes.BLOCK_TYPE).key(ResourceKey.minecraft("wool")).addValue(BlockTypes.GRASS_BLOCK).build();
event.register(woolGrass);
final TagTemplate underwaterDiamond = TagTemplate.builder(TagTypes.BLOCK_TYPE).key(BlockTypeTags.UNDERWATER_BONEMEALS.location()).addValue(BlockTypes.DIAMOND_BLOCK).build();
event.register(underwaterDiamond);
final TagTemplate ores = TagTemplate.builder(TagTypes.BLOCK_TYPE).key(ResourceKey.of(this.pluginContainer, "ores")).addValue(BlockTypes.COAL_ORE).addValue(BlockTypes.IRON_ORE).addValue(BlockTypes.LAPIS_ORE).addValue(BlockTypes.REDSTONE_ORE).addValue(BlockTypes.EMERALD_ORE).addValue(BlockTypes.DIAMOND_ORE).addValue(BlockTypes.NETHER_QUARTZ_ORE).addChild(// Test gold ore child.
BlockTypeTags.GOLD_ORES).build();
event.register(ores);
final TagTemplate oresAndBlocks = TagTemplate.builder(TagTypes.BLOCK_TYPE).key(ResourceKey.of(this.pluginContainer, "oresandblocks")).addValue(BlockTypes.COAL_BLOCK).addValue(BlockTypes.IRON_BLOCK).addValue(BlockTypes.LAPIS_BLOCK).addValue(BlockTypes.REDSTONE_BLOCK).addValue(BlockTypes.GOLD_BLOCK).addValue(BlockTypes.EMERALD_BLOCK).addValue(BlockTypes.DIAMOND_BLOCK).addValue(BlockTypes.QUARTZ_BLOCK).addChild(// Test child TagTemplate
ores).build();
event.register(oresAndBlocks);
final ResourceKey nonExistentKey = ResourceKey.of("notrealnamespace", "notrealvalue");
final TagTemplate brokenChildTag = TagTemplate.builder(TagTypes.ITEM_TYPE).key(ResourceKey.of(this.pluginContainer, "brokenchildtag")).addChild(RegistryKey.of(RegistryTypes.ITEM_TYPE_TAGS, nonExistentKey), true).build();
event.register(brokenChildTag);
final TagTemplate brokenValueTag = TagTemplate.builder(TagTypes.ITEM_TYPE).key(ResourceKey.of(this.pluginContainer, "brokenvaluetag")).addValue(RegistryKey.of(RegistryTypes.ITEM_TYPE, nonExistentKey)).build();
event.register(brokenValueTag);
final TagTemplate stillWorkingTag = TagTemplate.builder(TagTypes.ITEM_TYPE).key(ResourceKey.of(this.pluginContainer, "stillworkingtag")).addValue(RegistryKey.of(RegistryTypes.ITEM_TYPE, nonExistentKey), false).addChild(RegistryKey.of(RegistryTypes.ITEM_TYPE_TAGS, nonExistentKey), false).addValue(ItemTypes.REDSTONE).build();
event.register(stillWorkingTag);
}
Aggregations