Search in sources :

Example 1 with IDrawRenderTypeBuffer

use of hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer in project AstralSorcery by HellFirePvP.

the class FXCrystal method renderNow.

@Override
public <T extends EntityVisualFX & EntityDynamicFX> void renderNow(BatchRenderContext<T> ctx, MatrixStack renderStack, IDrawRenderTypeBuffer drawBuffer, float pTicks) {
    if (this.alternativeTexture != null) {
        this.alternativeTexture.bindTexture();
    }
    int alpha = this.getAlpha(pTicks);
    Color c = this.getColor(pTicks);
    Vector3 vec = this.getRenderPosition(pTicks).subtract(RenderingVectorUtils.getStandardTranslationRemovalVector(pTicks));
    float scale = this.getScale(pTicks);
    if (this.lightRayColor != null) {
        long seed = 0x515F1EB654AB915EL;
        renderStack.push();
        renderStack.translate(vec.getX(), vec.getY(), vec.getZ());
        RenderingDrawUtils.renderLightRayFan(renderStack, drawBuffer, this.lightRayColor, seed, 5, 1F, 50);
        renderStack.pop();
        drawBuffer.draw();
    }
    renderStack.push();
    renderStack.translate(vec.getX(), vec.getY() - 0.05F, vec.getZ());
    renderStack.scale(scale, scale, scale);
    renderStack.rotate(Vector3f.XP.rotationDegrees((float) rotation.getX()));
    renderStack.rotate(Vector3f.YP.rotationDegrees((float) rotation.getY()));
    renderStack.rotate(Vector3f.ZP.rotationDegrees((float) rotation.getZ()));
    BufferDecoratorBuilder.withColor((r, g, b, a) -> new int[] { c.getRed(), c.getGreen(), c.getBlue(), alpha }).decorate(drawBuffer.getBuffer(ctx.getRenderType()), decorated -> ObjModelRender.renderCrystal(renderStack, decorated, drawBuffer::draw));
    renderStack.pop();
    if (this.alternativeTexture != null) {
        ctx.getSprite().bindTexture();
    }
}
Also used : EntityDynamicFX(hellfirepvp.astralsorcery.client.effect.EntityDynamicFX) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) TextureQuery(hellfirepvp.astralsorcery.client.resource.query.TextureQuery) ObjModelRender(hellfirepvp.astralsorcery.client.render.ObjModelRender) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder) RenderingDrawUtils(hellfirepvp.astralsorcery.client.util.RenderingDrawUtils) BufferDecoratorBuilder(hellfirepvp.observerlib.client.util.BufferDecoratorBuilder) java.awt(java.awt) IDrawRenderTypeBuffer(hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer) Vector3f(net.minecraft.util.math.vector.Vector3f) AbstractRenderableTexture(hellfirepvp.astralsorcery.client.resource.AbstractRenderableTexture) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) EntityVisualFX(hellfirepvp.astralsorcery.client.effect.EntityVisualFX) RenderingVectorUtils(hellfirepvp.astralsorcery.client.util.RenderingVectorUtils) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) BatchRenderContext(hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3)

Example 2 with IDrawRenderTypeBuffer

use of hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer in project AstralSorcery by HellFirePvP.

the class EffectHandler method render.

public void render(MatrixStack renderStack, float pTicks) {
    if (this.orderedEffects == null || AssetLibrary.isReloading()) {
        return;
    }
    IDrawRenderTypeBuffer drawBuffer = IDrawRenderTypeBuffer.defaultBuffer();
    this.acceptsNewEffects = false;
    for (BatchRenderContext<?> ctx : this.orderedEffects) {
        List<PendingEffect> effects = this.effectMap.get(ctx);
        if (!effects.isEmpty()) {
            ctx.renderAll(effects, renderStack, drawBuffer, pTicks);
        }
    }
    this.acceptsNewEffects = true;
}
Also used : IDrawRenderTypeBuffer(hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer)

Example 3 with IDrawRenderTypeBuffer

use of hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer in project AstralSorcery by HellFirePvP.

the class BatchRenderContext method renderAll.

public void renderAll(List<EffectHandler.PendingEffect> effects, MatrixStack renderStack, IDrawRenderTypeBuffer drawBuffer, float pTicks) {
    // Erase type due to impossible typing
    BatchRenderContext blankCtx = this;
    effects.stream().filter(effect -> effect.getEffect() instanceof EntityDynamicFX).forEach(effect -> ((EntityDynamicFX) effect.getEffect()).renderNow(blankCtx, renderStack, drawBuffer, pTicks));
    RenderType drawType = this.getRenderType();
    if (this.drawWithTexture) {
        drawType = RenderTypeDecorator.wrapSetup(this.getRenderType(), () -> {
            RenderSystem.enableTexture();
            this.getSprite().bindTexture();
        }, () -> {
            BlockAtlasTexture.getInstance().bindTexture();
            RenderSystem.disableTexture();
        });
    }
    IVertexBuilder buf = drawBuffer.getBuffer(drawType);
    effects.forEach(effect -> effect.getEffect().render(this, renderStack, buf, pTicks));
    this.drawBatched(buf, drawBuffer);
}
Also used : EntityDynamicFX(hellfirepvp.astralsorcery.client.effect.EntityDynamicFX) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) EffectHandler(hellfirepvp.astralsorcery.client.effect.handler.EffectHandler) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BiFunction(java.util.function.BiFunction) RenderTypeDecorator(hellfirepvp.observerlib.client.util.RenderTypeDecorator) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder) RenderType(net.minecraft.client.renderer.RenderType) SpriteSheetResource(hellfirepvp.astralsorcery.client.resource.SpriteSheetResource) OrderSortable(hellfirepvp.astralsorcery.common.util.order.OrderSortable) IDrawRenderTypeBuffer(hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer) Vector3d(net.minecraft.util.math.vector.Vector3d) List(java.util.List) AbstractRenderableTexture(hellfirepvp.astralsorcery.client.resource.AbstractRenderableTexture) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) EntityVisualFX(hellfirepvp.astralsorcery.client.effect.EntityVisualFX) BlockAtlasTexture(hellfirepvp.astralsorcery.client.resource.BlockAtlasTexture) GL11(org.lwjgl.opengl.GL11) RenderInfo(hellfirepvp.astralsorcery.client.util.draw.RenderInfo) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) EntityDynamicFX(hellfirepvp.astralsorcery.client.effect.EntityDynamicFX) RenderType(net.minecraft.client.renderer.RenderType) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Aggregations

IDrawRenderTypeBuffer (hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer)3 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)2 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)2 EntityDynamicFX (hellfirepvp.astralsorcery.client.effect.EntityDynamicFX)2 EntityVisualFX (hellfirepvp.astralsorcery.client.effect.EntityVisualFX)2 AbstractRenderableTexture (hellfirepvp.astralsorcery.client.resource.AbstractRenderableTexture)2 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)2 BatchRenderContext (hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext)1 EffectHandler (hellfirepvp.astralsorcery.client.effect.handler.EffectHandler)1 ObjModelRender (hellfirepvp.astralsorcery.client.render.ObjModelRender)1 BlockAtlasTexture (hellfirepvp.astralsorcery.client.resource.BlockAtlasTexture)1 SpriteSheetResource (hellfirepvp.astralsorcery.client.resource.SpriteSheetResource)1 TextureQuery (hellfirepvp.astralsorcery.client.resource.query.TextureQuery)1 RenderingDrawUtils (hellfirepvp.astralsorcery.client.util.RenderingDrawUtils)1 RenderingVectorUtils (hellfirepvp.astralsorcery.client.util.RenderingVectorUtils)1 RenderInfo (hellfirepvp.astralsorcery.client.util.draw.RenderInfo)1 OrderSortable (hellfirepvp.astralsorcery.common.util.order.OrderSortable)1 BufferDecoratorBuilder (hellfirepvp.observerlib.client.util.BufferDecoratorBuilder)1 RenderTypeDecorator (hellfirepvp.observerlib.client.util.RenderTypeDecorator)1