Search in sources :

Example 1 with CollectedQuadBakedBlockModel

use of crazypants.enderio.base.render.model.CollectedQuadBakedBlockModel in project EnderIO by SleepyTrousers.

the class BlockStateWrapperBase method bakeModel.

@Override
public void bakeModel() {
    long start = Profiler.instance.start();
    QuadCollector quads = null;
    QuadCollector overlayQuads = null;
    @Nonnull QuadCollector paintQuads = new QuadCollector();
    boolean hasPaintRendered = false;
    String cacheResult;
    if (block instanceof IBlockPaintableBlock && (!(block instanceof IWrenchHideablePaint) || !getYetaDisplayMode().isHideFacades())) {
        hasPaintRendered = PaintWrangler.wrangleBakedModel(world, pos, ((IBlockPaintableBlock) block).getPaintSource(state, world, pos), paintQuads);
    }
    boolean fromCache = doCaching && MinecraftForgeClient.getRenderLayer() != null;
    if (!hasPaintRendered || renderMapper instanceof IRenderMapper.IBlockRenderMapper.IRenderLayerAware.IPaintAware) {
        if (fromCache) {
            quads = getFromCache();
            cacheResult = quads == null ? "miss" : "hit";
        } else {
            cacheResult = "not cachable";
        }
        if (quads == null) {
            quads = new QuadCollector();
            bakeBlockLayer(quads);
            if (fromCache) {
                putIntoCache(quads);
            }
        }
    } else {
        cacheResult = "paint only";
    }
    overlayQuads = OverlayHolder.getOverlay(renderMapper.mapOverlayLayer(this, world, pos, hasPaintRendered));
    model = new CollectedQuadBakedBlockModel(paintQuads.combine(overlayQuads).combine(quads));
    Profiler.instance.stop(start, state.getBlock().getLocalizedName() + " (bake, cache=" + cacheResult + ")");
}
Also used : IWrenchHideablePaint(crazypants.enderio.base.paint.IPaintable.IWrenchHideablePaint) QuadCollector(crazypants.enderio.base.render.util.QuadCollector) Nonnull(javax.annotation.Nonnull) IRenderMapper(crazypants.enderio.base.render.IRenderMapper) IBlockPaintableBlock(crazypants.enderio.base.paint.IPaintable.IBlockPaintableBlock) CollectedQuadBakedBlockModel(crazypants.enderio.base.render.model.CollectedQuadBakedBlockModel)

Example 2 with CollectedQuadBakedBlockModel

use of crazypants.enderio.base.render.model.CollectedQuadBakedBlockModel in project EnderIO by SleepyTrousers.

the class BlockStateWrapperRelay method bakeModel.

@Override
public void bakeModel() {
    long start = Profiler.instance.start();
    @Nonnull QuadCollector paintQuads = new QuadCollector();
    boolean hasPaintRendered = false;
    String cacheResult;
    if (block instanceof IBlockPaintableBlock && (!(block instanceof IWrenchHideablePaint) || !getYetaDisplayMode().isHideFacades())) {
        hasPaintRendered = PaintWrangler.wrangleBakedModel(world, pos, ((IBlockPaintableBlock) block).getPaintSource(state, world, pos), paintQuads);
    }
    if (!hasPaintRendered) {
        if (MinecraftForgeClient.getRenderLayer() == null || MinecraftForgeClient.getRenderLayer() == block.getBlockLayer()) {
            model = null;
            cacheResult = "relaying";
        } else {
            model = NULL;
            cacheResult = "none";
        }
    } else {
        model = new CollectedQuadBakedBlockModel(paintQuads);
        cacheResult = "paint only";
    }
    Profiler.instance.stop(start, state.getBlock().getLocalizedName() + " (bake, cache=" + cacheResult + ")");
}
Also used : IWrenchHideablePaint(crazypants.enderio.base.paint.IPaintable.IWrenchHideablePaint) Nonnull(javax.annotation.Nonnull) QuadCollector(crazypants.enderio.base.render.util.QuadCollector) IBlockPaintableBlock(crazypants.enderio.base.paint.IPaintable.IBlockPaintableBlock) CollectedQuadBakedBlockModel(crazypants.enderio.base.render.model.CollectedQuadBakedBlockModel)

Aggregations

IBlockPaintableBlock (crazypants.enderio.base.paint.IPaintable.IBlockPaintableBlock)2 IWrenchHideablePaint (crazypants.enderio.base.paint.IPaintable.IWrenchHideablePaint)2 CollectedQuadBakedBlockModel (crazypants.enderio.base.render.model.CollectedQuadBakedBlockModel)2 QuadCollector (crazypants.enderio.base.render.util.QuadCollector)2 Nonnull (javax.annotation.Nonnull)2 IRenderMapper (crazypants.enderio.base.render.IRenderMapper)1