6262public class ItemModels {
6363 public static final TagKey <Item > NO_INSTANCING = TagKey .create (Registries .ITEM , Vanillin .rl ("no_instancing" ));
6464
65+ private static final Model EMPTY_MODEL = new SimpleModel (List .of ());
6566 private static final RendererReloadCache <BakedMeshKey , Mesh > MESH_CACHE = new RendererReloadCache <>(key -> bakeMesh (key .model (), key .displayContext ()));
6667 private static final RendererReloadCache <BakedModelKey , Model > MODEL_CACHE = new RendererReloadCache <>(key -> bakeModel (key .model (), key .displayContext (), key .material (), key .foil ()));
6768
@@ -106,11 +107,10 @@ public static BakedModel getModel(ItemStack stack) {
106107 .getItemModel (stack );
107108 }
108109
110+ @ Nullable
109111 public static BakedModel getActualBakedModel (@ Nullable ClientLevel clientLevel , ItemStack itemStack , ItemDisplayContext displayContext ) {
110112 if (itemStack .isEmpty ()) {
111- return Minecraft .getInstance ()
112- .getModelManager ()
113- .getMissingModel ();
113+ return null ;
114114 }
115115
116116 var baseModel = getModel (itemStack );
@@ -123,9 +123,7 @@ public static BakedModel getActualBakedModel(@Nullable ClientLevel clientLevel,
123123
124124 boolean notEquipped = displayContext == ItemDisplayContext .GUI || displayContext == ItemDisplayContext .GROUND || displayContext == ItemDisplayContext .FIXED ;
125125 if (model .isCustomRenderer () || itemStack .is (Items .TRIDENT ) && !notEquipped ) {
126- return Minecraft .getInstance ()
127- .getModelManager ()
128- .getMissingModel ();
126+ return null ;
129127 }
130128
131129 if (notEquipped ) {
@@ -191,6 +189,10 @@ public static Model get(Level level, ItemStack itemStack, ItemDisplayContext dis
191189
192190 BakedModel model = getActualBakedModel (clientLevel , itemStack , displayContext );
193191
192+ if (model == null ) {
193+ return EMPTY_MODEL ;
194+ }
195+
194196 return MODEL_CACHE .get (new BakedModelKey (model , displayContext , material , itemStack .hasFoil ()));
195197 }
196198
0 commit comments