Search in sources :

Example 1 with TileFakedState

use of hellfirepvp.astralsorcery.common.tile.base.TileFakedState 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)

Example 2 with TileFakedState

use of hellfirepvp.astralsorcery.common.tile.base.TileFakedState in project AstralSorcery by HellFirePvP.

the class BlockFakedState method playParticles.

@OnlyIn(Dist.CLIENT)
protected void playParticles(World world, BlockPos pos, Random rand) {
    if (rand.nextInt(8) == 0) {
        VFXColorFunction<?> colorFn = VFXColorFunction.WHITE;
        TileFakedState fakedState = MiscUtils.getTileAt(world, pos, TileFakedState.class, false);
        if (fakedState != null) {
            colorFn = VFXColorFunction.constant(fakedState.getOverlayColor());
        }
        EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(Vector3.random().abs().add(pos)).alpha(VFXAlphaFunction.FADE_OUT).color(colorFn).setScaleMultiplier(0.2F + rand.nextFloat() * 0.05F).setMaxAge(25 + rand.nextInt(5));
    }
}
Also used : TileFakedState(hellfirepvp.astralsorcery.common.tile.base.TileFakedState) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

TileFakedState (hellfirepvp.astralsorcery.common.tile.base.TileFakedState)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)1 RenderingUtils (hellfirepvp.astralsorcery.client.util.RenderingUtils)1 BufferDecoratorBuilder (hellfirepvp.observerlib.client.util.BufferDecoratorBuilder)1 RenderTypeDecorator (hellfirepvp.observerlib.client.util.RenderTypeDecorator)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 TileEntityRendererDispatcher (net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1