Compare commits

...
2 Commits
Author SHA1 Message Date
Jottyfan 312e73f184 added pig food 2026-10-24 16:50:12 +02:00
Jottyfan 5c9dbe95e5 added food 2026-10-24 16:33:09 +02:00
9 changed files with 54 additions and 3 deletions

No files matched your search

@@ -0,0 +1,17 @@
package de.jottyfan.minecraft.item;
import net.minecraft.world.food.FoodProperties;
public enum Food {
GINGERBREAD(new FoodProperties.Builder().nutrition(1).saturationModifier(0.1f).build());
private final FoodProperties properties;
private Food(FoodProperties properties) {
this.properties = properties;
}
public FoodProperties get() {
return properties;
}
}
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Item.Properties;
/**
*
@@ -17,6 +18,7 @@ public class ModItems extends ModItemsRegistrator {
public static final Item STUB = registerItem("stub", StubItem::new);
public static final Item TIN_INGOT = registerItem("tin_ingot");
public static final Item TIN_DUST = registerItem("tin_dust");
public static final Item GINGERBREAD = registerItem("gingerbread", new Properties().food(Food.GINGERBREAD.get()));
public static final List<Item> registerItems() {
List<Item> registeredItems = new ArrayList<>();
@@ -26,6 +28,7 @@ public class ModItems extends ModItemsRegistrator {
registeredItems.add(RAW_TIN);
registeredItems.add(TIN_INGOT);
registeredItems.add(TIN_DUST);
registeredItems.add(GINGERBREAD);
return registeredItems;
}
}
@@ -32,7 +32,18 @@ public abstract class ModItemsRegistrator {
* register a new item with the name and its item class
*
* @param name the name
* @param function the item class
* @param properties the properties; create it with <code style="color: gray">new Item.Properties();</code>
* @return the registered item
*/
public static final Item registerItem(String name, Properties properties) {
return registerItem(name, properties, Item::new);
}
/**
* register a new item with the name and its properties
*
* @param name the name
* @param function the function; create it with <code style="color: gray">Item::new</code>
* @return the registered item
*/
public static final Item registerItem(String name, Function<Item.Properties, Item> function) {
@@ -43,8 +54,8 @@ public abstract class ModItemsRegistrator {
* register a new item with the name, the properties and the Item class reference
*
* @param name the name of the item
* @param the properties; create it with <code style="color: gray">new Item.Properties();</code>
* @param the function; create it with <code style="color: gray">Item::new</code>
* @param properties the properties; create it with <code style="color: gray">new Item.Properties();</code>
* @param function the function; create it with <code style="color: gray">Item::new</code>
* @return the registered item
*/
public static final Item registerItem(String name, Properties properties, Function<Item.Properties, Item> function) {
@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "mfmd2627:item/gingerbread"
}
}
@@ -1,4 +1,5 @@
{
"item.mfmd2627.gingerbread": "Lebkuchen",
"item.mfmd2627.stub": "Stummel",
"item.mfmd2627.raw_tin": "Zinn",
"item.mfmd2627.ruby": "Rubin",
@@ -1,4 +1,5 @@
{
"item.mfmd2627.gingerbread": "Gingerbread",
"item.mfmd2627.stub": "Stub",
"item.mfmd2627.raw_tin": "Tin",
"item.mfmd2627.ruby": "Ruby",
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "mfmd2627:item/gingerbread"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"mfmd2627:gingerbread"
]
}