Return missing model for null BlockState
This commit is contained in:
parent
54759008e5
commit
b430b67052
|
|
@ -3,6 +3,7 @@ package org.embeddedt.modernfix.common.mixin.perf.dynamic_resources;
|
||||||
import net.minecraft.client.renderer.block.BlockModelShaper;
|
import net.minecraft.client.renderer.block.BlockModelShaper;
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.client.resources.model.ModelManager;
|
import net.minecraft.client.resources.model.ModelManager;
|
||||||
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||||
import org.embeddedt.modernfix.dynamicresources.ModelLocationCache;
|
import org.embeddedt.modernfix.dynamicresources.ModelLocationCache;
|
||||||
|
|
@ -37,9 +38,14 @@ public class BlockModelShaperMixin {
|
||||||
public void rebuildCache() {
|
public void rebuildCache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author embeddedt
|
||||||
|
* @reason get the model from the dynamic model provider
|
||||||
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public BakedModel getBlockModel(BlockState state) {
|
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) {
|
if (model == null) {
|
||||||
model = modelManager.getMissingModel();
|
model = modelManager.getMissingModel();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ public class ModelLocationCache {
|
||||||
});
|
});
|
||||||
|
|
||||||
public static ModelResourceLocation get(BlockState state) {
|
public static ModelResourceLocation get(BlockState state) {
|
||||||
|
if(state == null)
|
||||||
|
return null;
|
||||||
try {
|
try {
|
||||||
return blockLocationCache.get(state);
|
return blockLocationCache.get(state);
|
||||||
} catch(ExecutionException e) {
|
} catch(ExecutionException e) {
|
||||||
|
|
@ -39,6 +41,8 @@ public class ModelLocationCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ModelResourceLocation get(Item item) {
|
public static ModelResourceLocation get(Item item) {
|
||||||
|
if(item == null)
|
||||||
|
return null;
|
||||||
try {
|
try {
|
||||||
return itemLocationCache.get(item);
|
return itemLocationCache.get(item);
|
||||||
} catch(ExecutionException e) {
|
} catch(ExecutionException e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user