MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a basic mode called foodmod and a custom food item, register the food item to the foodmod"
/* First, create a new mod called FoodMod. In the main class of your mod, add the following code: */ @Mod("foodmod") public class FoodMod { public static final String MOD_ID = "foodmod"; public static final ItemGroup FOODMOD_GROUP = new ItemGroup("foodmod_group") { @Override public ItemStack makeIcon() { return new ItemStack(ItemInit.CUSTOM_FOOD_ITEM.get()); } }; public FoodMod() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); ItemInit.ITEMS.register(modEventBus); } } /* Next, create a new class called ItemInit to register your custom food item: */ public class ItemInit { public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, FoodMod.MOD_ID); public static final RegistryObject<Item> CUSTOM_FOOD_ITEM = ITEMS.register("custom_food_item", () -> new Item(new Item.Properties().tab(FoodMod.FOODMOD_GROUP).food(new Food.Builder().nutrition(4).saturationMod(0.3f).build()))); } /* This will create a custom food item with a nutrition value of 4 and a saturation modifier of 0.3, and register it to the FoodMod in Minecraft Forge. */