2020-01-29 00:40:28 +01:00
|
|
|
package de.ellpeck.naturesaura.data;
|
2020-01-23 16:05:52 +01:00
|
|
|
|
2020-09-22 03:17:02 +02:00
|
|
|
import de.ellpeck.naturesaura.NaturesAura;
|
2020-01-26 19:26:50 +01:00
|
|
|
import de.ellpeck.naturesaura.compat.Compat;
|
2020-01-23 16:05:52 +01:00
|
|
|
import de.ellpeck.naturesaura.items.ModItems;
|
2023-06-27 11:04:11 +02:00
|
|
|
import de.ellpeck.naturesaura.items.tools.*;
|
|
|
|
import de.ellpeck.naturesaura.reg.IModItem;
|
|
|
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
2020-01-23 16:05:52 +01:00
|
|
|
import net.minecraft.data.DataGenerator;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.data.tags.BlockTagsProvider;
|
2023-07-08 12:32:27 +02:00
|
|
|
import net.minecraft.data.tags.IntrinsicHolderTagsProvider;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.data.tags.ItemTagsProvider;
|
2020-01-23 16:05:52 +01:00
|
|
|
import net.minecraft.tags.BlockTags;
|
|
|
|
import net.minecraft.tags.ItemTags;
|
2022-03-04 15:59:04 +01:00
|
|
|
import net.minecraft.tags.TagKey;
|
2021-12-19 16:35:03 +01:00
|
|
|
import net.minecraft.world.item.Item;
|
2020-01-23 16:05:52 +01:00
|
|
|
import net.minecraftforge.common.Tags;
|
2020-09-22 03:17:02 +02:00
|
|
|
import net.minecraftforge.common.data.ExistingFileHelper;
|
2020-01-23 16:05:52 +01:00
|
|
|
|
2023-06-27 11:04:11 +02:00
|
|
|
import java.util.Comparator;
|
|
|
|
|
2020-01-23 16:05:52 +01:00
|
|
|
public class ItemTagProvider extends ItemTagsProvider {
|
2021-12-15 16:24:53 +01:00
|
|
|
|
|
|
|
public ItemTagProvider(DataGenerator generatorIn, BlockTagsProvider blockTagProvider, ExistingFileHelper helper) {
|
2020-09-22 03:17:02 +02:00
|
|
|
super(generatorIn, blockTagProvider, NaturesAura.MOD_ID, helper);
|
2020-01-23 16:05:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-12-15 16:24:53 +01:00
|
|
|
protected void addTags() {
|
2020-01-23 16:05:52 +01:00
|
|
|
this.copy(BlockTags.LOGS, ItemTags.LOGS);
|
|
|
|
this.copy(BlockTags.PLANKS, ItemTags.PLANKS);
|
|
|
|
this.copy(BlockTags.STAIRS, ItemTags.STAIRS);
|
|
|
|
this.copy(BlockTags.LEAVES, ItemTags.LEAVES);
|
|
|
|
this.copy(BlockTags.RAILS, ItemTags.RAILS);
|
|
|
|
this.copy(BlockTags.SLABS, ItemTags.SLABS);
|
|
|
|
|
2021-12-15 16:24:53 +01:00
|
|
|
this.tag(Tags.Items.RODS_WOODEN).add(ModItems.ANCIENT_STICK);
|
2023-06-27 11:04:11 +02:00
|
|
|
|
|
|
|
// sort these so that they don't change the json every time we run data (because it's a set)
|
|
|
|
ModRegistry.ALL_ITEMS.stream().sorted(Comparator.comparing(IModItem::getBaseName)).filter(i -> i instanceof Item).map(i -> (Item) i).forEach(i -> {
|
|
|
|
if (i instanceof ItemPickaxe) {
|
|
|
|
this.tag(ItemTags.CLUSTER_MAX_HARVESTABLES).add(i);
|
2023-07-08 12:32:27 +02:00
|
|
|
this.tag(ItemTags.PICKAXES).add(i);
|
2023-06-27 11:04:11 +02:00
|
|
|
} else if (i instanceof ItemAxe) {
|
2023-07-08 12:32:27 +02:00
|
|
|
this.tag(ItemTags.AXES).add(i);
|
2023-06-27 11:04:11 +02:00
|
|
|
} else if (i instanceof ItemHoe) {
|
2023-07-08 12:32:27 +02:00
|
|
|
this.tag(ItemTags.HOES).add(i);
|
2023-06-27 11:04:11 +02:00
|
|
|
} else if (i instanceof ItemSword) {
|
2023-07-08 12:32:27 +02:00
|
|
|
this.tag(ItemTags.SWORDS).add(i);
|
2023-06-27 11:04:11 +02:00
|
|
|
} else if (i instanceof ItemShovel) {
|
2023-07-08 12:32:27 +02:00
|
|
|
this.tag(ItemTags.SHOVELS).add(i);
|
2023-06-27 11:04:11 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-26 19:26:50 +01:00
|
|
|
|
|
|
|
Compat.addItemTags(this);
|
|
|
|
}
|
2020-09-22 16:16:25 +02:00
|
|
|
|
2021-12-19 16:35:03 +01:00
|
|
|
@Override
|
2023-07-08 12:32:27 +02:00
|
|
|
public IntrinsicHolderTagsProvider.IntrinsicTagAppender<Item> tag(TagKey<Item> tag) {
|
2021-12-19 16:35:03 +01:00
|
|
|
// super is protected, but CuriosCompat needs this
|
2023-02-17 14:21:39 +01:00
|
|
|
return super.tag(tag);
|
2021-12-19 16:35:03 +01:00
|
|
|
}
|
2020-01-23 16:05:52 +01:00
|
|
|
}
|