Skip to content

Commit

Permalink
feat(game.tag): HItemTags
Browse files Browse the repository at this point in the history
axes,hoes,swords,shovels,pickaxes,food,bricks
  • Loading branch information
WakelessSloth56 committed Feb 2, 2023
1 parent b053610 commit 3fc7235
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 10 deletions.
30 changes: 30 additions & 0 deletions src/main/java/org/auioc/mcmod/arnicalib/game/tag/HItemTags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.auioc.mcmod.arnicalib.game.tag;

import org.auioc.mcmod.arnicalib.ArnicaLib;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;

public class HItemTags {

public static final TagKey<Item> AXES = create("axes");
public static final TagKey<Item> HOES = create("hoes");
public static final TagKey<Item> SWORDS = create("swords");
public static final TagKey<Item> SHOVELS = create("shovels");
public static final TagKey<Item> PICKAXES = create("pickaxes");

public static final TagKey<Item> FOOD = create("food");
public static final TagKey<Item> FOOD_MEAT = create("food/meat");
public static final TagKey<Item> FOOD_FAST = create("food/fast");
public static final TagKey<Item> FOOD_ALWAYS_EDIBLE = create("food/always_edible");

public static final TagKey<Item> BRICKS = create("bricks");

// ====================================================================== //

public static void init() {}

public static TagKey<Item> create(String _path) {
return TagCreator.item(ArnicaLib.id(_path));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.auioc.mcmod.arnicalib.mod.datagen.provider.HBlockTagsProvider;
import org.auioc.mcmod.arnicalib.mod.datagen.provider.HEntityTypeTagsProvider;
import org.auioc.mcmod.arnicalib.mod.datagen.provider.HItemTagsProvider;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
Expand All @@ -12,13 +13,14 @@ public class AHDataGenerators {
@SubscribeEvent
public static void dataGen(GatherDataEvent event) {
var generator = event.getGenerator();
var existingFileHelper = event.getExistingFileHelper();
var fileHelper = event.getExistingFileHelper();

var blockTags = new HBlockTagsProvider(generator, existingFileHelper);
var blockTags = new HBlockTagsProvider(generator, fileHelper);
generator.addProvider(blockTags);
// generator.addProvider(new HItemTagsProvider(generator, blockTags, existingFileHelper));

generator.addProvider(new HEntityTypeTagsProvider(generator, existingFileHelper));
generator.addProvider(new HItemTagsProvider(generator, blockTags, fileHelper));

generator.addProvider(new HEntityTypeTagsProvider(generator, fileHelper));
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.auioc.mcmod.arnicalib.mod.datagen.provider;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.auioc.mcmod.arnicalib.ArnicaLib;
import org.auioc.mcmod.arnicalib.game.datagen.tag.IHTagsProvider;
import org.auioc.mcmod.arnicalib.game.tag.HBlockTags;
Expand All @@ -14,8 +13,8 @@

public class HBlockTagsProvider extends BlockTagsProvider implements IHTagsProvider<Block> {

public HBlockTagsProvider(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) {
super(generator, ArnicaLib.MOD_ID, existingFileHelper);
public HBlockTagsProvider(DataGenerator generator, ExistingFileHelper fileHelper) {
super(generator, ArnicaLib.MOD_ID, fileHelper);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.auioc.mcmod.arnicalib.ArnicaLib;
import org.auioc.mcmod.arnicalib.game.datagen.tag.IHTagsProvider;
import org.auioc.mcmod.arnicalib.game.entity.EntityTypePredicates;
import org.jetbrains.annotations.Nullable;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.tags.EntityTypeTagsProvider;
import net.minecraft.world.entity.EntityType;
Expand All @@ -15,8 +14,8 @@

public class HEntityTypeTagsProvider extends EntityTypeTagsProvider implements IHTagsProvider<EntityType<?>> {

public HEntityTypeTagsProvider(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) {
super(generator, ArnicaLib.MOD_ID, existingFileHelper);
public HEntityTypeTagsProvider(DataGenerator generator, ExistingFileHelper fileHelper) {
super(generator, ArnicaLib.MOD_ID, fileHelper);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.auioc.mcmod.arnicalib.mod.datagen.provider;

import static org.auioc.mcmod.arnicalib.game.tag.HItemTags.*;
import org.auioc.mcmod.arnicalib.ArnicaLib;
import org.auioc.mcmod.arnicalib.game.datagen.tag.IHTagsProvider;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.tags.BlockTagsProvider;
import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.IForgeRegistry;

public class HItemTagsProvider extends ItemTagsProvider implements IHTagsProvider<Item> {

public HItemTagsProvider(DataGenerator generator, BlockTagsProvider blockTags, ExistingFileHelper fileHelper) {
super(generator, blockTags, ArnicaLib.MOD_ID, fileHelper);
}

@Override
public String getName() {
return "HItemsTags";
}

@Override
public IForgeRegistry<Item> getRegistry() {
return ForgeRegistries.ITEMS;
}

@Override
@SuppressWarnings("deprecation")
protected void addTags() {
tag(BRICKS).add(Items.BRICK, Items.NETHER_BRICK);

tag(AXES).add(Items.WOODEN_AXE, Items.STONE_AXE, Items.IRON_AXE, Items.GOLDEN_AXE, Items.DIAMOND_AXE, Items.NETHERITE_AXE);
tag(HOES).add(Items.WOODEN_HOE, Items.STONE_HOE, Items.IRON_HOE, Items.GOLDEN_HOE, Items.DIAMOND_HOE, Items.NETHERITE_HOE);
tag(SWORDS).add(Items.WOODEN_SWORD, Items.STONE_SWORD, Items.IRON_SWORD, Items.GOLDEN_SWORD, Items.DIAMOND_SWORD, Items.NETHERITE_SWORD);
tag(SHOVELS).add(Items.WOODEN_SHOVEL, Items.STONE_SHOVEL, Items.IRON_SHOVEL, Items.GOLDEN_SHOVEL, Items.DIAMOND_SHOVEL, Items.NETHERITE_SHOVEL);
tag(PICKAXES).add(Items.WOODEN_PICKAXE, Items.STONE_PICKAXE, Items.IRON_PICKAXE, Items.GOLDEN_PICKAXE, Items.DIAMOND_PICKAXE, Items.NETHERITE_PICKAXE);

addFromRegistry(tag(FOOD), (item) -> item.isEdible());
addFromRegistry(tag(FOOD_MEAT), (item) -> item.isEdible() && item.getFoodProperties().isMeat());
addFromRegistry(tag(FOOD_FAST), (item) -> item.isEdible() && item.getFoodProperties().isFastFood());
addFromRegistry(tag(FOOD_ALWAYS_EDIBLE), (item) -> item.isEdible() && item.getFoodProperties().canAlwaysEat());
}

}

0 comments on commit 3fc7235

Please sign in to comment.