Skip to content

Commit

Permalink
CustomModelData exsample
Browse files Browse the repository at this point in the history
  • Loading branch information
MORIMORI0317 committed Apr 8, 2023
1 parent f21ca15 commit 0dd3aa5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/dev/felnull/smlexample/SMLExampleItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

public class SMLExampleItems {
public static final Item OBJ_MODEL_ITEM = new Item(new FabricItemSettings());
public static final Item OBJ_MODEL_ITEM2 = new Item(new FabricItemSettings());
public static final Item CUSTOM_MODEL_DATA_OBJ_MODEL_ITEM = new Item(new FabricItemSettings());

public static void init() {
register("obj_model_item", OBJ_MODEL_ITEM);
register("obj_model_item2", OBJ_MODEL_ITEM2);
register("custom_model_data_obj_model_item", CUSTOM_MODEL_DATA_OBJ_MODEL_ITEM);

ItemGroupEvents.MODIFY_ENTRIES_ALL.register((group, entries) -> {
if (group == CreativeModeTabs.BUILDING_BLOCKS) {
entries.accept(OBJ_MODEL_ITEM);
entries.accept(OBJ_MODEL_ITEM2);

entries.accept(CUSTOM_MODEL_DATA_OBJ_MODEL_ITEM);

ItemStack customModelDataItem = new ItemStack(CUSTOM_MODEL_DATA_OBJ_MODEL_ITEM);
customModelDataItem.getOrCreateTag().putInt("CustomModelData", 1);
entries.accept(customModelDataItem);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"parent": "item/generated",
"textures": {
"layer0": "item/apple"
},
"overrides": [
{
"predicate": {
"custom_model_data": 1
},
"model": "smlexample:item/obj_model_item"
}
]
}

0 comments on commit 0dd3aa5

Please sign in to comment.