|
|
@@ -1,33 +1,50 @@
|
|
|
package top.lucason.tvhs_mc_server_mod.items;
|
|
|
|
|
|
+import com.mojang.datafixers.util.Function3;
|
|
|
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
|
|
+import net.minecraft.block.AbstractBlock;
|
|
|
+import net.minecraft.block.Block;
|
|
|
+import net.minecraft.component.type.FoodComponents;
|
|
|
import net.minecraft.item.Item;
|
|
|
import net.minecraft.item.ItemGroups;
|
|
|
+import net.minecraft.item.Items;
|
|
|
import net.minecraft.item.ToolMaterial;
|
|
|
import net.minecraft.registry.Registries;
|
|
|
import net.minecraft.registry.Registry;
|
|
|
import net.minecraft.registry.RegistryKey;
|
|
|
import net.minecraft.registry.RegistryKeys;
|
|
|
-import net.minecraft.registry.tag.BlockTags;
|
|
|
-import net.minecraft.registry.tag.TagBuilder;
|
|
|
import net.minecraft.util.Identifier;
|
|
|
import top.lucason.tvhs_mc_server_mod.TVHSMod;
|
|
|
+import top.lucason.tvhs_mc_server_mod.blocks.ModBlocks;
|
|
|
|
|
|
import java.util.function.BiFunction;
|
|
|
+import java.util.function.Function;
|
|
|
|
|
|
public class ModItems {
|
|
|
public static final Item HARDENED_BLOCKS_TOOL = register(
|
|
|
"hardened_blocks_tool",
|
|
|
HardenedBlocksModifierItem::new,
|
|
|
- new Item.Settings().pickaxe(ToolMaterial.DIAMOND, 3.0f, 1.0f)
|
|
|
+ new Item.Settings().pickaxe(ToolMaterial.DIAMOND, 0.0f, 0.0f)
|
|
|
);
|
|
|
+
|
|
|
+ public static final Item GOLDEN_HEAD = register(
|
|
|
+ "golden_head",
|
|
|
+ GoldenHeadItem::new,
|
|
|
+ new Item.Settings().food(FoodComponents.GOLDEN_APPLE)
|
|
|
+ );
|
|
|
+
|
|
|
public static void initModItems() {
|
|
|
TVHSMod.LOGGER.info("Initializing TVHS Mod Items");
|
|
|
|
|
|
ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(entries -> {
|
|
|
entries.add(ModItems.HARDENED_BLOCKS_TOOL);
|
|
|
});
|
|
|
+ ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(entries -> {
|
|
|
+ entries.add(ModItems.GOLDEN_HEAD);
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
+ // for hardened block items
|
|
|
public static Item register(String name, BiFunction<Item.Settings, Identifier, Item> itemFactory, Item.Settings settings) {
|
|
|
Identifier ID = Identifier.of(TVHSMod.MOD_ID, name);
|
|
|
RegistryKey<Item> itemKey = RegistryKey.of(RegistryKeys.ITEM, ID);
|
|
|
@@ -36,4 +53,14 @@ public class ModItems {
|
|
|
Registry.register(Registries.ITEM, itemKey, item);
|
|
|
return item;
|
|
|
}
|
|
|
+
|
|
|
+ // for normal items
|
|
|
+ public static Item register(String name, Function<Item.Settings, Item> itemFactory, Item.Settings settings){
|
|
|
+ Identifier ID = Identifier.of(TVHSMod.MOD_ID, name);
|
|
|
+ RegistryKey<Item> itemKey = RegistryKey.of(RegistryKeys.ITEM, ID);
|
|
|
+
|
|
|
+ Item item = itemFactory.apply(settings.registryKey(itemKey));
|
|
|
+ Registry.register(Registries.ITEM, itemKey, item);
|
|
|
+ return item;
|
|
|
+ }
|
|
|
}
|