From d345c58038ea569ed64091df3a0d25250acc5dbd Mon Sep 17 00:00:00 2001 From: "Joseph T. McQuigg" Date: Thu, 10 Oct 2024 21:17:49 -0400 Subject: [PATCH] Add musicDiscItem Method to ItemModelProvider --- .../client/model/generators/ItemModelProvider.java | 10 ++++++++++ .../assets/minecraft/models/item/music_disc_13.json | 6 ++++++ .../client/model/CustomItemDisplayContextTest.java | 2 ++ 3 files changed, 18 insertions(+) create mode 100644 tests/src/generated/resources/assets/minecraft/models/item/music_disc_13.json diff --git a/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelProvider.java b/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelProvider.java index 046ef31566e..2553917d82f 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelProvider.java +++ b/src/main/java/net/neoforged/neoforge/client/model/generators/ItemModelProvider.java @@ -51,6 +51,16 @@ public ItemModelBuilder spawnEggItem(ResourceLocation item) { .parent(new ModelFile.UncheckedModelFile("item/template_spawn_egg")); } + public ItemModelBuilder musicDiscItem(Item item) { + return musicDiscItem(Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(item))); + } + + public ItemModelBuilder musicDiscItem(ResourceLocation item) { + return getBuilder(item.toString()) + .parent(new ModelFile.UncheckedModelFile("item/template_music_disc")) + .texture("layer0", ResourceLocation.fromNamespaceAndPath(item.getNamespace(), "item/" + item.getPath())); + } + public ItemModelBuilder simpleBlockItem(Block block) { return simpleBlockItem(Objects.requireNonNull(BuiltInRegistries.BLOCK.getKey(block))); } diff --git a/tests/src/generated/resources/assets/minecraft/models/item/music_disc_13.json b/tests/src/generated/resources/assets/minecraft/models/item/music_disc_13.json new file mode 100644 index 00000000000..eb7eee8b77b --- /dev/null +++ b/tests/src/generated/resources/assets/minecraft/models/item/music_disc_13.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/template_music_disc", + "textures": { + "layer0": "minecraft:item/music_disc_13" + } +} \ No newline at end of file diff --git a/tests/src/main/java/net/neoforged/neoforge/oldtest/client/model/CustomItemDisplayContextTest.java b/tests/src/main/java/net/neoforged/neoforge/oldtest/client/model/CustomItemDisplayContextTest.java index 17f8a3cb3ab..5a50e860b6b 100644 --- a/tests/src/main/java/net/neoforged/neoforge/oldtest/client/model/CustomItemDisplayContextTest.java +++ b/tests/src/main/java/net/neoforged/neoforge/oldtest/client/model/CustomItemDisplayContextTest.java @@ -173,6 +173,8 @@ protected void registerModels() { spawnEggItem(Items.SHEEP_SPAWN_EGG); + musicDiscItem(Items.MUSIC_DISC_13); + simpleBlockItem(Blocks.ACACIA_PLANKS); } }