@SideOnly(Side.CLIENT)
public static String getTexture(IBlockState state, String defaultTexture) {
try {
ModelLoader loader = ModelLoader.VanillaLoader.INSTANCE.getLoader();
BlockStateMapper mapper = loader.blockModelShapes.getBlockStateMapper();
Map<IBlockState, ModelResourceLocation> map = mapper.getVariants(state.getBlock());
ModelResourceLocation stateLocation = map.get(state);
ModelBlockDefinition definition = loader.getModelBlockDefinition(stateLocation);
ResourceLocation modelLocation = definition.getVariant(stateLocation.getVariant()).getVariantList().get(0).getModelLocation();
ModelBlock modelBlock = loader.loadModel(
new ResourceLocation(modelLocation.getResourceDomain(), "models/" + modelLocation.getResourcePath()));
String texture = getTexture(modelBlock);
return ObjectUtils.firstNonNull(texture, defaultTexture);
} catch (Exception e) {
e.printStackTrace();
return defaultTexture;
}
}
WoodType.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:Alchemy
作者:
评论列表
文章目录