MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a basic mod called foodmod and a custom food item, register the food item to the foodmod"
/* First, create a new mod called FoodMod by creating a new package and a main class for the mod */ package com.example.foodmod; import net.minecraftforge.fml.common.Mod; @Mod("foodmod") public class FoodMod { // Your mod code goes here } /* Next, create a new package called init and a new class called ItemInit to register the custom food item */ package com.example.foodmod.init; import net.minecraft.item.Food; import net.minecraft.item.Item; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class ItemInit { public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "foodmod"); public static final RegistryObject<Item> CUSTOM_FOOD_ITEM = ITEMS.register("custom_food_item", () -> new Item(new Item.Properties().tab(ItemGroup.TAB_FOOD).food(new Food.Builder().nutrition(4).saturationMod(0.3f).build()))); } /* Finally, register the ItemInit class in the main FoodMod class */ package com.example.foodmod; import com.example.foodmod.init.ItemInit; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @Mod("foodmod") public class FoodMod { public FoodMod() { ItemInit.ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); } }