Search in sources :

Example 1 with RenderTypeDecorator

use of hellfirepvp.observerlib.client.util.RenderTypeDecorator in project AstralSorcery by HellFirePvP.

the class RenderingUtils method renderTranslucentItemStackModelGround.

public static void renderTranslucentItemStackModelGround(ItemStack stack, MatrixStack renderStack, Color overlayColor, Blending blendMode, int alpha) {
    IBakedModel bakedModel = getItemModel(stack);
    ForgeHooksClient.handleCameraTransforms(renderStack, bakedModel, ItemCameraTransforms.TransformType.GROUND, false);
    TextureManager textureManager = Minecraft.getInstance().getTextureManager();
    textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
    textureManager.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
    IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
    renderItemModelWithColor(stack, ItemCameraTransforms.TransformType.GROUND, bakedModel, renderStack, (renderType) -> {
        RenderTypeDecorator decorated = RenderTypeDecorator.wrapSetup(renderType, () -> {
            RenderSystem.enableBlend();
            blendMode.apply();
        }, () -> {
            Blending.DEFAULT.apply();
            RenderSystem.disableBlend();
        });
        return buffer.getBuffer(decorated);
    }, LightmapUtil.getPackedFullbrightCoords(), OverlayTexture.NO_OVERLAY, overlayColor, alpha);
    buffer.finish();
}
Also used : IBakedModel(net.minecraft.client.renderer.model.IBakedModel) RenderTypeDecorator(hellfirepvp.observerlib.client.util.RenderTypeDecorator)

Example 2 with RenderTypeDecorator

use of hellfirepvp.observerlib.client.util.RenderTypeDecorator in project AstralSorcery by HellFirePvP.

the class FXFacingSprite method renderNow.

@Override
public <T extends EntityVisualFX & EntityDynamicFX> void renderNow(BatchRenderContext<T> ctx, MatrixStack renderStack, IDrawRenderTypeBuffer drawBuffer, float pTicks) {
    SpriteSheetResource ssr = this.sprite != null ? this.sprite : ctx.getSprite();
    Tuple<Float, Float> uvOffset = ssr.getUVOffset(this, pTicks, spriteDisplayFactor);
    int alpha = this.getAlpha(pTicks);
    Color col = this.getColor(pTicks);
    Vector3 vec = this.getRenderPosition(pTicks);
    float scale = this.getScale(pTicks);
    RenderTypeDecorator decorated = RenderTypeDecorator.wrapSetup(ctx.getRenderType(), ssr::bindTexture, BlockAtlasTexture.getInstance()::bindTexture);
    IVertexBuilder buf = drawBuffer.getBuffer(decorated);
    RenderingDrawUtils.renderFacingQuadVB(buf, renderStack, vec.getX(), vec.getY(), vec.getZ(), scale, 0F, uvOffset.getA(), uvOffset.getB(), ssr.getULength(), ssr.getVLength(), col.getRed(), col.getGreen(), col.getBlue(), alpha);
    drawBuffer.draw();
}
Also used : SpriteSheetResource(hellfirepvp.astralsorcery.client.resource.SpriteSheetResource) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) RenderTypeDecorator(hellfirepvp.observerlib.client.util.RenderTypeDecorator) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Example 3 with RenderTypeDecorator

use of hellfirepvp.observerlib.client.util.RenderTypeDecorator in project AstralSorcery by HellFirePvP.

the class FXSpritePlane method renderNow.

@Override
public <T extends EntityVisualFX & EntityDynamicFX> void renderNow(BatchRenderContext<T> ctx, MatrixStack renderStack, IDrawRenderTypeBuffer drawBuffer, float pTicks) {
    SpriteSheetResource ssr = this.sprite != null ? this.sprite : ctx.getSprite();
    Tuple<Float, Float> uvOffset = ssr.getUVOffset(this, pTicks, spriteDisplayFactor);
    Vector3 vec = this.getRenderPosition(pTicks);
    vec.subtract(RenderingVectorUtils.getStandardTranslationRemovalVector(pTicks));
    float scale = this.getScale(pTicks);
    int alpha = this.getAlpha(pTicks);
    Color color = this.getColor(pTicks);
    Vector3 axis = this.axis.clone();
    float deg;
    if (ticksPerFullRot >= 0) {
        float anglePercent = ((float) (getAge())) / ((float) ticksPerFullRot);
        deg = anglePercent * 360F;
        deg = RenderingVectorUtils.interpolateRotation(lastRenderDegree, deg, pTicks);
        this.lastRenderDegree = deg;
    } else {
        deg = fixDegree;
    }
    RenderTypeDecorator decorated = RenderTypeDecorator.wrapSetup(ctx.getRenderType(), ssr::bindTexture, () -> BlockAtlasTexture.getInstance().bindTexture());
    IVertexBuilder buf = drawBuffer.getBuffer(decorated);
    RenderingDrawUtils.renderAngleRotatedTexturedRectVB(buf, renderStack, vec, axis, (float) Math.toRadians(deg), scale, uvOffset.getA(), uvOffset.getB(), ssr.getULength(), ssr.getVLength(), color.getRed(), color.getGreen(), color.getBlue(), alpha);
    drawBuffer.draw();
}
Also used : SpriteSheetResource(hellfirepvp.astralsorcery.client.resource.SpriteSheetResource) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) RenderTypeDecorator(hellfirepvp.observerlib.client.util.RenderTypeDecorator) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Example 4 with RenderTypeDecorator

use of hellfirepvp.observerlib.client.util.RenderTypeDecorator in project AstralSorcery by HellFirePvP.

the class RenderTileFakedState method render.

@Override
public void render(TileFakedState tile, float pTicks, MatrixStack renderStack, IRenderTypeBuffer renderTypeBuffer, int combinedLight, int combinedOverlay) {
    BlockState fakedState = tile.getFakedState();
    if (fakedState.getBlock() instanceof AirBlock) {
        return;
    }
    Color blendColor = tile.getOverlayColor();
    int[] color = new int[] { blendColor.getRed(), blendColor.getGreen(), blendColor.getBlue(), 128 };
    RenderType type = RenderTypeLookup.func_239221_b_(fakedState);
    RenderTypeDecorator decorated = RenderTypeDecorator.wrapSetup(type, () -> {
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();
        RenderSystem.depthMask(false);
    }, () -> {
        RenderSystem.depthMask(true);
        RenderSystem.defaultBlendFunc();
        RenderSystem.disableBlend();
    });
    BufferDecoratorBuilder decorator = BufferDecoratorBuilder.withColor(((r, g, b, a) -> color));
    IVertexBuilder buf = renderTypeBuffer.getBuffer(decorated);
    RenderingUtils.renderSimpleBlockModel(fakedState, renderStack, decorator.decorate(buf), tile.getPos(), tile, true);
}
Also used : AirBlock(net.minecraft.block.AirBlock) RenderTypeDecorator(hellfirepvp.observerlib.client.util.RenderTypeDecorator) IRenderTypeBuffer(net.minecraft.client.renderer.IRenderTypeBuffer) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder) RenderType(net.minecraft.client.renderer.RenderType) TileFakedState(hellfirepvp.astralsorcery.common.tile.base.TileFakedState) TileEntityRendererDispatcher(net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher) RenderingUtils(hellfirepvp.astralsorcery.client.util.RenderingUtils) BufferDecoratorBuilder(hellfirepvp.observerlib.client.util.BufferDecoratorBuilder) java.awt(java.awt) RenderTypeLookup(net.minecraft.client.renderer.RenderTypeLookup) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) BlockState(net.minecraft.block.BlockState) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) BufferDecoratorBuilder(hellfirepvp.observerlib.client.util.BufferDecoratorBuilder) BlockState(net.minecraft.block.BlockState) AirBlock(net.minecraft.block.AirBlock) RenderTypeDecorator(hellfirepvp.observerlib.client.util.RenderTypeDecorator) RenderType(net.minecraft.client.renderer.RenderType) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Aggregations

RenderTypeDecorator (hellfirepvp.observerlib.client.util.RenderTypeDecorator)4 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)3 SpriteSheetResource (hellfirepvp.astralsorcery.client.resource.SpriteSheetResource)2 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 RenderingUtils (hellfirepvp.astralsorcery.client.util.RenderingUtils)1 TileFakedState (hellfirepvp.astralsorcery.common.tile.base.TileFakedState)1 BufferDecoratorBuilder (hellfirepvp.observerlib.client.util.BufferDecoratorBuilder)1 java.awt (java.awt)1 AirBlock (net.minecraft.block.AirBlock)1 BlockState (net.minecraft.block.BlockState)1 IRenderTypeBuffer (net.minecraft.client.renderer.IRenderTypeBuffer)1 RenderType (net.minecraft.client.renderer.RenderType)1 RenderTypeLookup (net.minecraft.client.renderer.RenderTypeLookup)1 IBakedModel (net.minecraft.client.renderer.model.IBakedModel)1 TileEntityRendererDispatcher (net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher)1