From ef224bd2b87338459c2629f4b9d392e96da7fd9a Mon Sep 17 00:00:00 2001 From: Jonathing Date: Wed, 12 Feb 2025 20:02:52 -0500 Subject: [PATCH] Fix ModelDiscovery using Item components early (#10418) --- .../client/resources/model/ModelDiscovery.java.patch | 12 ++++++++++++ .../net/minecraft/world/item/Item.java.patch | 12 +++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch new file mode 100644 index 0000000000..518c9a7508 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelDiscovery.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/client/resources/model/ModelDiscovery.java ++++ b/net/minecraft/client/resources/model/ModelDiscovery.java +@@ -37,7 +_,8 @@ + private static Set listMandatoryModels() { + Set set = new HashSet<>(); + BuiltInRegistries.ITEM.listElements().forEach(p_368638_ -> { +- ResourceLocation resourcelocation = p_368638_.value().components().get(DataComponents.ITEM_MODEL); ++ // Forge: Force use vanilla components without gathering mod components in the event ++ ResourceLocation resourcelocation = p_368638_.value().vanillaComponents().get(DataComponents.ITEM_MODEL); + if (resourcelocation != null) { + set.add(ModelResourceLocation.inventory(resourcelocation)); + } diff --git a/patches/minecraft/net/minecraft/world/item/Item.java.patch b/patches/minecraft/net/minecraft/world/item/Item.java.patch index 6e59375416..4cb3f23c8b 100644 --- a/patches/minecraft/net/minecraft/world/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Item.java.patch @@ -28,7 +28,7 @@ } @Deprecated -@@ -123,17 +_,25 @@ +@@ -123,17 +_,35 @@ return this.builtInRegistryHolder; } @@ -42,6 +42,16 @@ + } + + return builtComponents; ++ } ++ ++ /** ++ * Forge: Hack fix used in ++ * {@link net.minecraft.client.resources.model.ModelDiscovery#listMandatoryModels ModelBakery.listMandatoryModels}, ++ * during mod loading, before the Forge event bus is ready. ++ */ ++ @org.jetbrains.annotations.ApiStatus.Internal ++ public DataComponentMap vanillaComponents() { ++ return components; } public int getDefaultMaxStackSize() {