Search in sources :

Example 1 with DyeColor

use of net.minecraft.world.item.DyeColor in project MinecraftForge by MinecraftForge.

the class ForgeItemTagsProvider method addColored.

private void addColored(Consumer<Tag.Named<Item>> consumer, Tag.Named<Item> group, String pattern) {
    String prefix = group.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
    for (DyeColor color : DyeColor.values()) {
        ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getName()));
        Tag.Named<Item> tag = getForgeItemTag(prefix + color.getName());
        Item item = ForgeRegistries.ITEMS.getValue(key);
        if (item == null || item == Items.AIR)
            throw new IllegalStateException("Unknown vanilla item: " + key.toString());
        tag(tag).add(item);
        consumer.accept(tag);
    }
}
Also used : Item(net.minecraft.world.item.Item) ResourceLocation(net.minecraft.resources.ResourceLocation) Tag(net.minecraft.tags.Tag) DyeColor(net.minecraft.world.item.DyeColor)

Example 2 with DyeColor

use of net.minecraft.world.item.DyeColor in project MinecraftForge by MinecraftForge.

the class ForgeItemTagsProvider method copyColored.

private void copyColored(Tag.Named<Block> blockGroup, Tag.Named<Item> itemGroup) {
    String blockPre = blockGroup.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
    String itemPre = itemGroup.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
    for (DyeColor color : DyeColor.values()) {
        Tag.Named<Block> from = getForgeBlockTag(blockPre + color.getName());
        Tag.Named<Item> to = getForgeItemTag(itemPre + color.getName());
        copy(from, to);
    }
    copy(getForgeBlockTag(blockPre + "colorless"), getForgeItemTag(itemPre + "colorless"));
}
Also used : Item(net.minecraft.world.item.Item) Block(net.minecraft.world.level.block.Block) Tag(net.minecraft.tags.Tag) DyeColor(net.minecraft.world.item.DyeColor)

Example 3 with DyeColor

use of net.minecraft.world.item.DyeColor in project MinecraftForge by MinecraftForge.

the class ForgeBlockTagsProvider method addColored.

private void addColored(Consumer<Block> consumer, Tag.Named<Block> group, String pattern) {
    String prefix = group.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
    for (DyeColor color : DyeColor.values()) {
        ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getName()));
        Tag.Named<Block> tag = getForgeTag(prefix + color.getName());
        Block block = ForgeRegistries.BLOCKS.getValue(key);
        if (block == null || block == Blocks.AIR)
            throw new IllegalStateException("Unknown vanilla block: " + key.toString());
        tag(tag).add(block);
        consumer.accept(block);
    }
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) Block(net.minecraft.world.level.block.Block) Tag(net.minecraft.tags.Tag) DyeColor(net.minecraft.world.item.DyeColor)

Aggregations

Tag (net.minecraft.tags.Tag)3 DyeColor (net.minecraft.world.item.DyeColor)3 ResourceLocation (net.minecraft.resources.ResourceLocation)2 Item (net.minecraft.world.item.Item)2 Block (net.minecraft.world.level.block.Block)2