Search in sources :

Example 1 with BatchPerkContext

use of hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext in project AstralSorcery by HellFirePvP.

the class PerkTreeConstellation method renderPerkAtBatch.

@Nullable
@Override
@OnlyIn(Dist.CLIENT)
public Rectangle.Float renderPerkAtBatch(BatchPerkContext drawCtx, MatrixStack renderStack, AllocationStatus status, long spriteOffsetTick, float pTicks, float x, float y, float zLevel, float scale) {
    SpriteSheetResource tex = status.getPerkTreeHaloSprite();
    BatchPerkContext.TextureObjectGroup grp = PerkPointHaloRenderGroup.INSTANCE.getGroup(tex);
    if (grp == null) {
        return new Rectangle.Float();
    }
    BufferContext buf = drawCtx.getContext(grp);
    float haloSize = perkSpriteSize * scale;
    if (status.isAllocated()) {
        haloSize *= 1.3F;
    }
    Tuple<Float, Float> frameUV = tex.getUVOffset(spriteOffsetTick);
    RenderingGuiUtils.rect(buf, renderStack, x - haloSize, y - haloSize, zLevel, haloSize * 2F, haloSize * 2F).color(1F, 1F, 1F, 0.85F).tex(frameUV.getA(), frameUV.getB(), tex.getULength(), tex.getVLength()).draw();
    super.renderPerkAtBatch(drawCtx, renderStack, status, spriteOffsetTick, pTicks, x, y, zLevel, scale);
    float actualSize = perkSpriteSize * scale;
    return new Rectangle.Float(-actualSize, -actualSize, actualSize * 2, actualSize * 2);
}
Also used : SpriteSheetResource(hellfirepvp.astralsorcery.client.resource.SpriteSheetResource) BatchPerkContext(hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext) BufferContext(hellfirepvp.astralsorcery.client.util.draw.BufferContext) Nullable(javax.annotation.Nullable) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 2 with BatchPerkContext

use of hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext in project AstralSorcery by HellFirePvP.

the class PerkTreeGem method renderPerkAtBatch.

@Nullable
@Override
@OnlyIn(Dist.CLIENT)
public Rectangle.Float renderPerkAtBatch(BatchPerkContext drawCtx, MatrixStack renderStack, AllocationStatus status, long spriteOffsetTick, float pTicks, float x, float y, float zLevel, float scale) {
    SpriteSheetResource tex = status.getPerkTreeHaloSprite();
    BatchPerkContext.TextureObjectGroup grp = PerkPointHaloRenderGroup.INSTANCE.getGroup(tex);
    if (grp == null) {
        return new Rectangle.Float();
    }
    BufferContext buf = drawCtx.getContext(grp);
    float haloSize = getRenderSize() * 0.8F * scale;
    if (status.isAllocated()) {
        haloSize *= 1.5;
    }
    Tuple<Float, Float> frameUV = tex.getUVOffset(spriteOffsetTick);
    RenderingGuiUtils.rect(buf, renderStack, x - haloSize, y - haloSize, zLevel, haloSize * 2F, haloSize * 2F).color(1F, 1F, 1F, 0.85F).tex(frameUV.getA(), frameUV.getB(), tex.getULength(), tex.getVLength()).draw();
    super.renderPerkAtBatch(drawCtx, renderStack, status, spriteOffsetTick, pTicks, x, y, zLevel, scale);
    float actualSize = getRenderSize() * scale;
    return new Rectangle.Float(-actualSize, -actualSize, actualSize * 2, actualSize * 2);
}
Also used : SpriteSheetResource(hellfirepvp.astralsorcery.client.resource.SpriteSheetResource) BatchPerkContext(hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext) BufferContext(hellfirepvp.astralsorcery.client.util.draw.BufferContext) Nullable(javax.annotation.Nullable) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 3 with BatchPerkContext

use of hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext in project AstralSorcery by HellFirePvP.

the class PerkTreeMajor method renderPerkAtBatch.

@Nullable
@Override
@OnlyIn(Dist.CLIENT)
public Rectangle.Float renderPerkAtBatch(BatchPerkContext drawCtx, MatrixStack renderStack, AllocationStatus status, long spriteOffsetTick, float pTicks, float x, float y, float zLevel, float scale) {
    SpriteSheetResource tex = status.getPerkTreeHaloSprite();
    BatchPerkContext.TextureObjectGroup grp = PerkPointHaloRenderGroup.INSTANCE.getGroup(tex);
    if (grp == null) {
        return new Rectangle.Float();
    }
    BufferBuilder buf = drawCtx.getContext(grp);
    float haloSize = getRenderSize() * 0.8F * scale;
    if (status.isAllocated()) {
        haloSize *= 1.5;
    }
    Tuple<Float, Float> frameUV = tex.getUVOffset(spriteOffsetTick);
    RenderingGuiUtils.rect(buf, renderStack, x - haloSize, y - haloSize, zLevel, haloSize * 2F, haloSize * 2F).color(1F, 1F, 1F, 0.85F).tex(frameUV.getA(), frameUV.getB(), tex.getULength(), tex.getVLength()).draw();
    super.renderPerkAtBatch(drawCtx, renderStack, status, spriteOffsetTick, pTicks, x, y, zLevel, scale);
    float actualSize = getRenderSize() * scale;
    return new Rectangle.Float(-actualSize, -actualSize, actualSize * 2, actualSize * 2);
}
Also used : SpriteSheetResource(hellfirepvp.astralsorcery.client.resource.SpriteSheetResource) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BatchPerkContext(hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext) Nullable(javax.annotation.Nullable) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 4 with BatchPerkContext

use of hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext in project AstralSorcery by HellFirePvP.

the class PerkTreePoint method renderPerkAtBatch.

@Nullable
@Override
@OnlyIn(Dist.CLIENT)
public Rectangle.Float renderPerkAtBatch(BatchPerkContext drawCtx, MatrixStack renderStack, AllocationStatus status, long spriteOffsetTick, float pTicks, float x, float y, float zLevel, float scale) {
    SpriteSheetResource tex = status.getPerkTreeSprite();
    BatchPerkContext.TextureObjectGroup grp = PerkPointRenderGroup.INSTANCE.getGroup(tex);
    if (grp == null) {
        return new Rectangle.Float();
    }
    BufferBuilder buf = drawCtx.getContext(grp);
    float size = renderSize * scale;
    Tuple<Float, Float> frameUV = tex.getUVOffset(spriteOffsetTick);
    RenderingGuiUtils.rect(buf, renderStack, x - size, y - size, zLevel, size * 2F, size * 2F).tex(frameUV.getA(), frameUV.getB(), tex.getULength(), tex.getVLength()).draw();
    return new Rectangle.Float(-size, -size, size * 2, size * 2);
}
Also used : SpriteSheetResource(hellfirepvp.astralsorcery.client.resource.SpriteSheetResource) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BatchPerkContext(hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext) Nullable(javax.annotation.Nullable) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 5 with BatchPerkContext

use of hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext in project AstralSorcery by HellFirePvP.

the class ScreenJournalPerkTree method initializeDrawBuffer.

public static void initializeDrawBuffer() {
    PerkTree.PERK_TREE.getVersion(LogicalSide.CLIENT).ifPresent(version -> {
        if (lastPreparedBuffer == null || version.longValue() != lastPreparedBuffer) {
            drawBuffer = new BatchPerkContext();
            searchContext = drawBuffer.addContext(SpritesAS.SPR_PERK_SEARCH, BatchPerkContext.PRIORITY_OVERLAY);
            sealContext = drawBuffer.addContext(SpritesAS.SPR_PERK_SEAL, BatchPerkContext.PRIORITY_FOREGROUND);
            List<PerkRenderGroup> groups = Lists.newArrayList();
            for (PerkTreePoint<?> p : PerkTree.PERK_TREE.getPerkPoints(LogicalSide.CLIENT)) {
                p.addGroups(groups);
            }
            for (PerkRenderGroup group : groups) {
                group.batchRegister(drawBuffer);
            }
            lastPreparedBuffer = version;
        }
    });
}
Also used : PerkRenderGroup(hellfirepvp.astralsorcery.client.screen.journal.perk.PerkRenderGroup) BatchPerkContext(hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext)

Aggregations

BatchPerkContext (hellfirepvp.astralsorcery.client.screen.journal.perk.BatchPerkContext)5 SpriteSheetResource (hellfirepvp.astralsorcery.client.resource.SpriteSheetResource)4 Nullable (javax.annotation.Nullable)4 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)4 BufferContext (hellfirepvp.astralsorcery.client.util.draw.BufferContext)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 PerkRenderGroup (hellfirepvp.astralsorcery.client.screen.journal.perk.PerkRenderGroup)1