Search in sources :

Example 1 with BakedModel

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);
}
Also used : BakedModel(net.minecraft.client.resources.model.BakedModel) ParticleRenderType(net.minecraft.client.particle.ParticleRenderType)

Example 2 with BakedModel

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;
}
Also used : BakedModel(net.minecraft.client.resources.model.BakedModel) Predicate(java.util.function.Predicate)

Example 3 with BakedModel

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;
}
Also used : ModelLoaderErrorMessage(net.minecraftforge.logging.ModelLoaderErrorMessage) ResourceLocation(net.minecraft.resources.ResourceLocation) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) BakedModel(net.minecraft.client.resources.model.BakedModel) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) Map(java.util.Map)

Example 4 with BakedModel

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;
}
Also used : BakedModel(net.minecraft.client.resources.model.BakedModel) ModelState(net.minecraft.client.resources.model.ModelState)

Aggregations

BakedModel (net.minecraft.client.resources.model.BakedModel)4 Map (java.util.Map)1 Predicate (java.util.function.Predicate)1 ParticleRenderType (net.minecraft.client.particle.ParticleRenderType)1 ModelResourceLocation (net.minecraft.client.resources.model.ModelResourceLocation)1 ModelState (net.minecraft.client.resources.model.ModelState)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 ModelLoaderErrorMessage (net.minecraftforge.logging.ModelLoaderErrorMessage)1