diff --git a/develop/items/food.md b/develop/items/food.md index 0c7a93b78..f303f1203 100644 --- a/develop/items/food.md +++ b/develop/items/food.md @@ -17,10 +17,10 @@ Unless you're making a mod with overpowered items, you should consider: ## Adding the Food Component {#adding-the-food-component} -To add a food component to an item, we can pass it to the `FabricItemSettings` instance: +To add a food component to an item, we can pass it to the `Item.Settings` instance: ```java -new FabricItemSettings().food(new FoodComponent.Builder().build()) +new Item.Settings().food(new FoodComponent.Builder().build()) ``` Right now, this just makes the item edible and nothing more. @@ -36,12 +36,14 @@ The `FoodComponent.Builder` class has many methods that allow you to modify what | `snack` | Declares your item as a snack. | | `statusEffect` | Adds a status effect when you eat your item. Usually a status effect instance and chance is passed to this method, where chance is a decimal percentage (`1f = 100%`) | -When you've modified the builder to your liking, you can call the `build()` method to get the `FoodComponent` - -Using the example created in the [Creating Your First Item](./first-item) page, I'll be using the following options for the builder: +When you've modified the builder to your liking, you can call the `build()` method to get the `FoodComponent`. @[code transcludeWith=:::5](@/reference/latest/src/main/java/com/example/docs/item/ModItems.java) +Similar to the example in the [Creating Your First Item](./first-item) page, I'll be using the above component: + +@[code transcludeWith=:::poisonous_apple](@/reference/latest/src/main/java/com/example/docs/item/ModItems.java) + This makes the item: - Always edible, it can be eaten regardless of hunger level. diff --git a/public/assets/develop/items/food_0.webm b/public/assets/develop/items/food_0.webm index 2db10f008..8b20a9d1c 100644 Binary files a/public/assets/develop/items/food_0.webm and b/public/assets/develop/items/food_0.webm differ diff --git a/reference/latest/src/main/java/com/example/docs/item/ModItems.java b/reference/latest/src/main/java/com/example/docs/item/ModItems.java index 16b1d2b98..25d4a7d3d 100644 --- a/reference/latest/src/main/java/com/example/docs/item/ModItems.java +++ b/reference/latest/src/main/java/com/example/docs/item/ModItems.java @@ -55,7 +55,7 @@ public class ModItems { .build(); // :::9 // :::5 - public static final FoodComponent SUSPICIOUS_FOOD_COMPONENT = new FoodComponent.Builder() + public static final FoodComponent POISON_FOOD_COMPONENT = new FoodComponent.Builder() .alwaysEdible() .snack() // The duration is in ticks, 20 ticks = 1 second @@ -63,10 +63,16 @@ public class ModItems { .build(); // :::5 + // :::poisonous_apple + public static final Item POISONOUS_APPLE = register( + new Item(new Item.Settings().food(POISON_FOOD_COMPONENT)), + "poisonous_apple" + ); + // :::poisonous_apple + // :::2 public static final Item SUSPICIOUS_SUBSTANCE = register( - // Ignore the food component for now, we'll cover it later in the food section. - new Item(new Item.Settings().food(SUSPICIOUS_FOOD_COMPONENT)), + new Item(new Item.Settings()), "suspicious_substance" ); // :::2 @@ -115,6 +121,7 @@ public static void initialize() { // Register items to the custom item group. ItemGroupEvents.modifyEntriesEvent(CUSTOM_ITEM_GROUP_KEY).register(itemGroup -> { itemGroup.add(ModItems.SUSPICIOUS_SUBSTANCE); + itemGroup.add(ModItems.POISONOUS_APPLE); itemGroup.add(ModItems.GUIDITE_SWORD); itemGroup.add(ModItems.GUIDITE_HELMET); itemGroup.add(ModItems.GUIDITE_BOOTS); diff --git a/reference/latest/src/main/resources/assets/fabric-docs-reference/lang/en_us.json b/reference/latest/src/main/resources/assets/fabric-docs-reference/lang/en_us.json index 08349436b..44b72ab87 100644 --- a/reference/latest/src/main/resources/assets/fabric-docs-reference/lang/en_us.json +++ b/reference/latest/src/main/resources/assets/fabric-docs-reference/lang/en_us.json @@ -4,6 +4,7 @@ "item.minecraft.potion.effect.tater": "Tater Potion", "death.attack.tater": "%1$s died from Tater damage!", "item.fabric-docs-reference.suspicious_substance": "Suspicous Substance", + "item.fabric-docs-reference.poisonous_apple": "Poisonous Apple", "item.fabric-docs-reference.guidite_sword": "Guidite Sword", "item.fabric-docs-reference.guidite_helmet": "Guidite Helmet", "item.fabric-docs-reference.guidite_chestplate": "Guidite Chestplate", diff --git a/reference/latest/src/main/resources/assets/fabric-docs-reference/models/item/poisonous_apple.json b/reference/latest/src/main/resources/assets/fabric-docs-reference/models/item/poisonous_apple.json new file mode 100644 index 000000000..eb4dcd677 --- /dev/null +++ b/reference/latest/src/main/resources/assets/fabric-docs-reference/models/item/poisonous_apple.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "fabric-docs-reference:item/poisonous_apple" + } +} \ No newline at end of file diff --git a/reference/latest/src/main/resources/assets/fabric-docs-reference/textures/item/poisonous_apple.png b/reference/latest/src/main/resources/assets/fabric-docs-reference/textures/item/poisonous_apple.png new file mode 100644 index 000000000..2da937261 Binary files /dev/null and b/reference/latest/src/main/resources/assets/fabric-docs-reference/textures/item/poisonous_apple.png differ