diff --git a/src/main/java/cn/shidux/chinesefoods/item/JiangXi/NanChangFoods.java b/src/main/java/cn/shidux/chinesefoods/item/JiangXi/NanChangFoods.java new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/cn/shidux/chinesefoods/item/ModFoodComponents.java b/src/main/java/cn/shidux/chinesefoods/item/ModFoodComponents.java index 7081dc0..cf1c512 100644 --- a/src/main/java/cn/shidux/chinesefoods/item/ModFoodComponents.java +++ b/src/main/java/cn/shidux/chinesefoods/item/ModFoodComponents.java @@ -5,6 +5,7 @@ import net.minecraft.item.FoodComponent; public class ModFoodComponents { + //食用后恢复6点饥饿值,0.25的饱和度修正值。 public static final FoodComponent DOUZHIR = new FoodComponent.Builder() .hunger(6) .saturationModifier(0.25f) diff --git a/src/main/java/cn/shidux/chinesefoods/item/ModItemGroups.java b/src/main/java/cn/shidux/chinesefoods/item/ModItemGroups.java index 0cce47a..a27a290 100644 --- a/src/main/java/cn/shidux/chinesefoods/item/ModItemGroups.java +++ b/src/main/java/cn/shidux/chinesefoods/item/ModItemGroups.java @@ -1,19 +1,23 @@ package cn.shidux.chinesefoods.item; -import cn.shidux.chinesefoods.ChineseFoods; -import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; +import cn.shidux.chinesefoods.ChineseFoods; // 引入自定义模组的包和类 +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; // 引入Fabric API的ItemGroup构建器 +import net.minecraft.item.ItemGroup; // 引入Minecraft的ItemGroup接口 +import net.minecraft.item.ItemStack; // 引入Minecraft的ItemStack类,用于表示物品栈 +import net.minecraft.registry.Registries; // 引入Minecraft的注册表管理类 +import net.minecraft.registry.Registry; // 引入Minecraft的注册表类 +import net.minecraft.text.Text; // 引入Minecraft的文本类 +import net.minecraft.util.Identifier; // 引入Minecraft的标识符类 public class ModItemGroups { + public static final ItemGroup CHINESE_FOODS_GROUP = Registry.register(Registries.ITEM_GROUP, - new Identifier(ChineseFoods.MOD_ID, "chinesefoods"), - FabricItemGroup.builder().displayName(Text.translatable("itemgroup.chinesefoods")) - .icon(() -> new ItemStack(ModItems.DOUZHIR)).entries((displayContext, entries) -> { + new Identifier(ChineseFoods.MOD_ID, "chinesefoods"), // 使用模组的ID和物品组的名称创建标识符 + FabricItemGroup.builder() // 使用Fabric的ItemGroup构建器开始构建 + .displayName(Text.translatable("itemgroup.chinesefoods")) // 设置物品组的可翻译显示名称 + .icon(() -> new ItemStack(ModItems.DOUZHIR)) // 设置物品组的图标为豆汁儿 + .entries((displayContext, entries) -> { // 设置物品组中应包含的物品 + // 添加所有食物和相关物品到物品组中 entries.add(ModItems.DOUZHIR); entries.add(ModItems.FRIED_RING); entries.add(ModItems.SALTED_VEGETABLE); @@ -23,15 +27,21 @@ public class ModItemGroups { entries.add(ModItems.ROUGAMO); entries.add(ModItems.PITA_BREAD_SOAKED_IN_LAMB_SOUP); + // 添加食材和种子 entries.add(ModItems.MUNG_BEANS); entries.add(ModItems.RUTABAGA); entries.add(ModItems.MUNGBEAN_SEEDS); entries.add(ModItems.RUTABAGA_SEEDS); + // 如果有其他需要添加到物品组的物品,也可以在这里添加 + // entries.add(ModItems.item); + + // 添加一碗水作为示例 entries.add(ModItems.A_BOWL_OF_WATER); - }).build()); + }).build()); // 完成构建并返回ItemGroup实例 + public static void registerItemGroups() { - ChineseFoods.LOGGER.info("Registering Item Groups for " + ChineseFoods.MOD_ID); + ChineseFoods.LOGGER.info("Registering Item Groups for " + ChineseFoods.MOD_ID); // 记录日志信息 } -} +} \ No newline at end of file diff --git a/src/main/java/cn/shidux/chinesefoods/item/ModItems.java b/src/main/java/cn/shidux/chinesefoods/item/ModItems.java index 8c2a279..1b97956 100644 --- a/src/main/java/cn/shidux/chinesefoods/item/ModItems.java +++ b/src/main/java/cn/shidux/chinesefoods/item/ModItems.java @@ -9,7 +9,7 @@ import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; - +//这个类包含了所有由中国传统食品模组定义的食物和材料的物品注册。 public class ModItems { public static final Item DOUZHIR = registerItem("douzhir", new Item(new FabricItemSettings() .food(ModFoodComponents.DOUZHIR)));