diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/dynamic_resources/BlockModelShaperMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/dynamic_resources/BlockModelShaperMixin.java index c5c70db9..3f737e53 100644 --- a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/dynamic_resources/BlockModelShaperMixin.java +++ b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/dynamic_resources/BlockModelShaperMixin.java @@ -3,6 +3,7 @@ package org.embeddedt.modernfix.common.mixin.perf.dynamic_resources; import net.minecraft.client.renderer.block.BlockModelShaper; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.ModelManager; +import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.world.level.block.state.BlockState; import org.embeddedt.modernfix.annotation.ClientOnlyMixin; import org.embeddedt.modernfix.dynamicresources.ModelLocationCache; @@ -37,9 +38,14 @@ public class BlockModelShaperMixin { public void rebuildCache() { } + /** + * @author embeddedt + * @reason get the model from the dynamic model provider + */ @Overwrite public BakedModel getBlockModel(BlockState state) { - BakedModel model = modelManager.getModel(ModelLocationCache.get(state)); + ModelResourceLocation mrl = ModelLocationCache.get(state); + BakedModel model = mrl == null ? null : modelManager.getModel(mrl); if (model == null) { model = modelManager.getMissingModel(); } diff --git a/common/src/main/java/org/embeddedt/modernfix/dynamicresources/ModelLocationCache.java b/common/src/main/java/org/embeddedt/modernfix/dynamicresources/ModelLocationCache.java index 7370d58a..2d737bbd 100644 --- a/common/src/main/java/org/embeddedt/modernfix/dynamicresources/ModelLocationCache.java +++ b/common/src/main/java/org/embeddedt/modernfix/dynamicresources/ModelLocationCache.java @@ -31,6 +31,8 @@ public class ModelLocationCache { }); public static ModelResourceLocation get(BlockState state) { + if(state == null) + return null; try { return blockLocationCache.get(state); } catch(ExecutionException e) { @@ -39,6 +41,8 @@ public class ModelLocationCache { } public static ModelResourceLocation get(Item item) { + if(item == null) + return null; try { return itemLocationCache.get(item); } catch(ExecutionException e) {