Skip to content

Commit b430b67

Browse files
committed
Return missing model for null BlockState
1 parent 5475900 commit b430b67

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/dynamic_resources/BlockModelShaperMixin.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.minecraft.client.renderer.block.BlockModelShaper;
44
import net.minecraft.client.resources.model.BakedModel;
55
import net.minecraft.client.resources.model.ModelManager;
6+
import net.minecraft.client.resources.model.ModelResourceLocation;
67
import net.minecraft.world.level.block.state.BlockState;
78
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
89
import org.embeddedt.modernfix.dynamicresources.ModelLocationCache;
@@ -37,9 +38,14 @@ private void replaceModelMap(CallbackInfo ci) {
3738
public void rebuildCache() {
3839
}
3940

41+
/**
42+
* @author embeddedt
43+
* @reason get the model from the dynamic model provider
44+
*/
4045
@Overwrite
4146
public BakedModel getBlockModel(BlockState state) {
42-
BakedModel model = modelManager.getModel(ModelLocationCache.get(state));
47+
ModelResourceLocation mrl = ModelLocationCache.get(state);
48+
BakedModel model = mrl == null ? null : modelManager.getModel(mrl);
4349
if (model == null) {
4450
model = modelManager.getMissingModel();
4551
}

common/src/main/java/org/embeddedt/modernfix/dynamicresources/ModelLocationCache.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public ModelResourceLocation load(Item key) throws Exception {
3131
});
3232

3333
public static ModelResourceLocation get(BlockState state) {
34+
if(state == null)
35+
return null;
3436
try {
3537
return blockLocationCache.get(state);
3638
} catch(ExecutionException e) {
@@ -39,6 +41,8 @@ public static ModelResourceLocation get(BlockState state) {
3941
}
4042

4143
public static ModelResourceLocation get(Item item) {
44+
if(item == null)
45+
return null;
4246
try {
4347
return itemLocationCache.get(item);
4448
} catch(ExecutionException e) {

0 commit comments

Comments
 (0)