use of net.minecraft.client.resources.model.BakedModel in project MinecraftForge by MinecraftForge.
the class ForgeHooksClient method drawItemLayered.
public static void drawItemLayered(ItemRenderer renderer, BakedModel modelIn, ItemStack itemStackIn, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn, boolean fabulous) {
for (com.mojang.datafixers.util.Pair<BakedModel, RenderType> layerModel : modelIn.getLayerModels(itemStackIn, fabulous)) {
BakedModel layer = layerModel.getFirst();
RenderType rendertype = layerModel.getSecond();
// neded for compatibility with MultiLayerModels
net.minecraftforge.client.ForgeHooksClient.setRenderType(rendertype);
VertexConsumer ivertexbuilder;
if (fabulous) {
ivertexbuilder = ItemRenderer.getFoilBufferDirect(bufferIn, rendertype, true, itemStackIn.hasFoil());
} else {
ivertexbuilder = ItemRenderer.getFoilBuffer(bufferIn, rendertype, true, itemStackIn.hasFoil());
}
renderer.renderModelLists(layer, itemStackIn, combinedLightIn, combinedOverlayIn, matrixStackIn, ivertexbuilder);
}
net.minecraftforge.client.ForgeHooksClient.setRenderType(null);
}
use of net.minecraft.client.resources.model.BakedModel in project MinecraftForge by MinecraftForge.
the class MultipartModelData method create.
public static IModelData create(List<Pair<Predicate<BlockState>, BakedModel>> selectors, BlockAndTintGetter world, BlockPos pos, BlockState state, IModelData tileData) {
MultipartModelData multipartData = new MultipartModelData(tileData);
for (Pair<Predicate<BlockState>, BakedModel> selector : selectors) {
if (selector.getLeft().test(state)) {
BakedModel part = selector.getRight();
IModelData partData = part.getModelData(world, pos, state, tileData);
multipartData.setPartData(part, partData);
}
}
return multipartData;
}
use of net.minecraft.client.resources.model.BakedModel in project MinecraftForge by MinecraftForge.
the class ForgeModelBakery method onPostBakeEvent.
/**
* Internal, do not use.
*/
public void onPostBakeEvent(Map<ResourceLocation, BakedModel> modelRegistry) {
BakedModel missingModel = modelRegistry.get(MISSING_MODEL_LOCATION);
for (Map.Entry<ResourceLocation, Exception> entry : loadingExceptions.entrySet()) {
// ignoring pure ResourceLocation arguments, all things we care about pass ModelResourceLocation
if (entry.getKey() instanceof ModelResourceLocation) {
LOGGER.debug(MODELLOADING, () -> new ModelLoaderErrorMessage((ModelResourceLocation) entry.getKey(), entry.getValue()));
final ModelResourceLocation location = (ModelResourceLocation) entry.getKey();
final BakedModel model = modelRegistry.get(location);
if (model == null) {
modelRegistry.put(location, missingModel);
}
}
}
loadingExceptions.clear();
isLoading = false;
}
use of net.minecraft.client.resources.model.BakedModel in project MinecraftForge by MinecraftForge.
the class ModelLoaderRegistry method bakeHelper.
public static BakedModel bakeHelper(BlockModel blockModel, ModelBakery modelBakery, BlockModel otherModel, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation, boolean guiLight3d) {
BakedModel model;
IModelGeometry<?> customModel = blockModel.customData.getCustomGeometry();
ModelState customModelState = blockModel.customData.getCustomModelState();
if (customModelState != null)
modelTransform = new CompositeModelState(modelTransform, customModelState, modelTransform.isUvLocked());
if (customModel != null)
model = customModel.bake(blockModel.customData, modelBakery, spriteGetter, modelTransform, blockModel.getOverrides(modelBakery, otherModel, spriteGetter), modelLocation);
else {
// handle vanilla item models here, since vanilla has a shortcut for them
if (blockModel.getRootModel() == ModelBakery.GENERATION_MARKER) {
model = ITEM_MODEL_GENERATOR.generateBlockModel(spriteGetter, blockModel).bake(modelBakery, blockModel, spriteGetter, modelTransform, modelLocation, guiLight3d);
} else {
model = blockModel.bakeVanilla(modelBakery, otherModel, spriteGetter, modelTransform, modelLocation, guiLight3d);
}
}
if (customModelState != null && !model.doesHandlePerspectives())
model = new PerspectiveMapWrapper(model, customModelState);
return model;
}
Aggregations