Search in sources :

Example 1 with PlayerPerkData

use of hellfirepvp.astralsorcery.common.data.research.PlayerPerkData in project AstralSorcery by HellFirePvP.

the class PerkExperienceRenderer method onRenderOverlay.

private void onRenderOverlay(RenderGameOverlayEvent.Post event) {
    if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) {
        return;
    }
    if (this.visibilityReveal <= 0) {
        return;
    }
    if (!ResearchHelper.getClientProgress().isAttuned()) {
        return;
    }
    MatrixStack renderStack = event.getMatrixStack();
    PlayerEntity player = Minecraft.getInstance().player;
    float frameHeight = 128F;
    float frameWidth = 32F;
    float frameOffsetX = 0F;
    float frameOffsetY = 5F;
    RenderSystem.enableBlend();
    RenderSystem.disableAlphaTest();
    TexturesAS.TEX_OVERLAY_EXP_FRAME.bindTexture();
    RenderingUtils.draw(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX, buf -> {
        RenderingGuiUtils.rect(buf, renderStack, frameOffsetX, frameOffsetY, 10, frameWidth, frameHeight).color(1F, 1F, 1F, visibilityReveal * 0.9F).draw();
    });
    PlayerPerkData perkData = ResearchHelper.getClientProgress().getPerkData();
    float perc = perkData.getPercentToNextLevel(player, LogicalSide.CLIENT);
    float expHeight = 78F * perc;
    float expWidth = 32F;
    float expOffsetX = 0F;
    float expOffsetY = 27.5F + (1F - perc) * 78F;
    TexturesAS.TEX_OVERLAY_EXP_BAR.bindTexture();
    RenderingUtils.draw(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX, buf -> {
        RenderingGuiUtils.rect(buf, renderStack, expOffsetX, expOffsetY, 10, expWidth, expHeight).color(1F, 0.9F, 0F, visibilityReveal * 0.9F).tex(0, 0, 1, 1 - perc).draw();
    });
    String strLevel = String.valueOf(perkData.getPerkLevel(player, LogicalSide.CLIENT));
    StringTextComponent txtLevel = new StringTextComponent(strLevel);
    int strLength = Minecraft.getInstance().fontRenderer.getStringPropertyWidth(txtLevel);
    renderStack.push();
    renderStack.translate(15 - (strLength / 2F), 94, 20);
    renderStack.scale(1.2F, 1.2F, 1F);
    int c = 0x00DDDDDD;
    c |= ((int) (255F * visibilityReveal)) << 24;
    if (visibilityReveal > 0.1E-4) {
        RenderingDrawUtils.renderStringAt(txtLevel, renderStack, null, c, true);
    }
    renderStack.pop();
    BlockAtlasTexture.getInstance().bindTexture();
}
Also used : MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) PlayerPerkData(hellfirepvp.astralsorcery.common.data.research.PlayerPerkData) StringTextComponent(net.minecraft.util.text.StringTextComponent) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 2 with PlayerPerkData

use of hellfirepvp.astralsorcery.common.data.research.PlayerPerkData in project AstralSorcery by HellFirePvP.

the class ScreenJournalPerkTree method mouseReleased.

@Override
public boolean mouseReleased(double mouseX, double mouseY, int state) {
    if (super.mouseReleased(mouseX, mouseY, state)) {
        return true;
    }
    PlayerEntity player = Minecraft.getInstance().player;
    if (!this.mouseSealStack.isEmpty()) {
        this.mouseSealStack = ItemStack.EMPTY;
        if (Minecraft.getInstance().player == null) {
            return false;
        }
        PlayerPerkData perkData = ResearchHelper.getClientProgress().getPerkData();
        for (Map.Entry<AbstractPerk, Rectangle.Float> rctPerk : this.thisFramePerks.entrySet()) {
            if (rctPerk.getValue().contains(mouseX, mouseY) && this.guiBox.isInBox(mouseX - guiLeft, mouseY - guiTop)) {
                if (perkData.hasPerkEffect(rctPerk.getKey()) && !perkData.isPerkSealed(rctPerk.getKey()) && ItemPerkSeal.useSeal(player, true)) {
                    PktRequestPerkSealAction pkt = new PktRequestPerkSealAction(rctPerk.getKey(), true);
                    PacketChannel.CHANNEL.sendToServer(pkt);
                    return true;
                }
            }
        }
    }
    if (this.unlockPrimed == null) {
        return false;
    }
    for (Map.Entry<AbstractPerk, Rectangle.Float> rctPerk : this.thisFramePerks.entrySet()) {
        if (this.unlockPrimed.equals(rctPerk.getKey()) && rctPerk.getValue().contains(mouseX, mouseY) && this.guiBox.isInBox(mouseX - guiLeft, mouseY - guiTop)) {
            AbstractPerk perk = rctPerk.getKey();
            PlayerProgress prog = ResearchHelper.getClientProgress();
            PlayerPerkData perkData = prog.getPerkData();
            if (!perkData.hasPerkAllocation(perk) && perk.mayUnlockPerk(prog, player)) {
                PktUnlockPerk pkt = new PktUnlockPerk(false, rctPerk.getKey());
                PacketChannel.CHANNEL.sendToServer(pkt);
                break;
            }
        }
    }
    this.unlockPrimed = null;
    return true;
}
Also used : PktUnlockPerk(hellfirepvp.astralsorcery.common.network.play.client.PktUnlockPerk) PlayerPerkData(hellfirepvp.astralsorcery.common.data.research.PlayerPerkData) PktRequestPerkSealAction(hellfirepvp.astralsorcery.common.network.play.client.PktRequestPerkSealAction) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 3 with PlayerPerkData

use of hellfirepvp.astralsorcery.common.data.research.PlayerPerkData in project AstralSorcery by HellFirePvP.

the class ScreenJournalPerkTree method drawPerkTree.

private void drawPerkTree(MatrixStack renderStack, float partialTicks) {
    PlayerEntity player = Minecraft.getInstance().player;
    PlayerProgress progress = ResearchHelper.getClientProgress();
    PlayerPerkData perkData = progress.getPerkData();
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    TexturesAS.TEX_GUI_LINE_CONNECTION.bindTexture();
    RenderingUtils.draw(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX, buf -> {
        for (Tuple<AbstractPerk, AbstractPerk> perkConnection : PerkTree.PERK_TREE.getConnections()) {
            if (!perkConnection.getA().isVisible(progress, player) || !perkConnection.getB().isVisible(progress, player)) {
                continue;
            }
            AllocationStatus status;
            int alloc = 0;
            if (perkData.hasPerkAllocation(perkConnection.getA(), PerkAllocationType.UNLOCKED)) {
                alloc++;
            }
            if (perkData.hasPerkAllocation(perkConnection.getB(), PerkAllocationType.UNLOCKED)) {
                alloc++;
            }
            if (alloc == 2) {
                status = AllocationStatus.ALLOCATED;
            } else if (alloc == 1 && progress.getPerkData().hasFreeAllocationPoint(player, LogicalSide.CLIENT)) {
                status = AllocationStatus.UNLOCKABLE;
            } else {
                status = AllocationStatus.UNALLOCATED;
            }
            Point.Float offsetOne = perkConnection.getA().getPoint().getOffset();
            Point.Float offsetTwo = perkConnection.getB().getPoint().getOffset();
            drawConnection(buf, renderStack, status, offsetOne, offsetTwo, ClientScheduler.getClientTick() + (int) offsetOne.x + (int) offsetOne.y + (int) offsetTwo.x + (int) offsetTwo.y);
        }
    });
    RenderSystem.disableBlend();
    drawBuffer.beginDrawingPerks();
    List<Runnable> renderDynamic = Lists.newArrayList();
    for (PerkTreePoint<?> perkPoint : PerkTree.PERK_TREE.getPerkPoints(LogicalSide.CLIENT)) {
        AbstractPerk perk = perkPoint.getPerk();
        if (!perk.isVisible(progress, player)) {
            continue;
        }
        Point.Float offset = perkPoint.getOffset();
        Rectangle.Float perkRect = drawPerk(drawBuffer, renderStack, perkPoint, partialTicks, ClientScheduler.getClientTick() + (int) offset.x + (int) offset.y, perkData.isPerkSealed(perk), renderDynamic);
        if (perkRect != null) {
            this.thisFramePerks.put(perk, perkRect);
        }
    }
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    drawBuffer.draw();
    RenderSystem.disableBlend();
    renderDynamic.forEach(Runnable::run);
    this.unlockEffects.keySet().removeIf(perk -> !drawPerkUnlock(perk, renderStack, this.unlockEffects.get(perk)));
    this.breakEffects.keySet().removeIf(perk -> !drawPerkSealBreak(perk, renderStack, this.breakEffects.get(perk), partialTicks));
}
Also used : PlayerPerkData(hellfirepvp.astralsorcery.common.data.research.PlayerPerkData) ScalingPoint(hellfirepvp.astralsorcery.client.screen.helper.ScalingPoint) PerkTreePoint(hellfirepvp.astralsorcery.common.perk.tree.PerkTreePoint) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) ScalingPoint(hellfirepvp.astralsorcery.client.screen.helper.ScalingPoint) PerkTreePoint(hellfirepvp.astralsorcery.common.perk.tree.PerkTreePoint) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 4 with PlayerPerkData

use of hellfirepvp.astralsorcery.common.data.research.PlayerPerkData in project AstralSorcery by HellFirePvP.

the class ScreenJournalPerkTree method drawHoverTooltips.

private void drawHoverTooltips(MatrixStack renderStack, int mouseX, int mouseY) {
    PlayerEntity player = Minecraft.getInstance().player;
    for (Rectangle.Float r : this.slotsSocketMenu.keySet()) {
        if (r.contains(mouseX, mouseY)) {
            Integer slot = this.slotsSocketMenu.get(r);
            ItemStack in = player.inventory.getStackInSlot(slot);
            if (!in.isEmpty()) {
                FontRenderer fr = in.getItem().getFontRenderer(in);
                if (fr == null) {
                    fr = Minecraft.getInstance().fontRenderer;
                }
                List<ITextProperties> toolTip = new ArrayList<>();
                toolTip.addAll(this.getTooltipFromItem(in));
                RenderingDrawUtils.renderBlueTooltipComponents(renderStack, mouseX, mouseY, this.getGuiZLevel(), toolTip, fr, true);
            }
            return;
        }
    }
    if (rStatStar.contains(mouseX, mouseY)) {
        RenderingDrawUtils.renderBlueTooltipComponents(renderStack, rStatStar.x + rStatStar.width / 2F, rStatStar.y + rStatStar.height, this.getGuiZLevel(), Lists.newArrayList(new TranslationTextComponent("perk.reader.astralsorcery.infostar")), font, false);
        return;
    }
    if (!this.foundSeals.isEmpty() && rectSealBox.contains(mouseX - guiLeft, mouseY - guiTop)) {
        List<ITextProperties> toolTip = new ArrayList<>();
        toolTip.addAll(this.foundSeals.getTooltip(Minecraft.getInstance().player, Minecraft.getInstance().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL));
        toolTip.add(StringTextComponent.EMPTY);
        toolTip.add(new TranslationTextComponent("perk.info.astralsorcery.sealed.usage").mergeStyle(TextFormatting.GRAY));
        RenderingDrawUtils.renderBlueTooltipComponents(renderStack, mouseX, mouseY, this.getGuiZLevel(), toolTip, font, false);
    } else {
        for (Map.Entry<AbstractPerk, Rectangle.Float> rctPerk : this.thisFramePerks.entrySet()) {
            if (rctPerk.getValue().contains(mouseX, mouseY) && this.guiBox.isInBox(mouseX - guiLeft, mouseY - guiTop)) {
                List<ITextProperties> toolTip = new LinkedList<>();
                AbstractPerk perk = rctPerk.getKey();
                PlayerProgress prog = ResearchHelper.getClientProgress();
                PlayerPerkData perkData = prog.getPerkData();
                perk.getLocalizedTooltip().forEach(line -> {
                    Style style = line.getStyle();
                    if (style.getColor() == null) {
                        line.mergeStyle(TextFormatting.GRAY).mergeStyle(TextFormatting.ITALIC);
                    }
                    toolTip.add(line);
                });
                if (perkData.isPerkSealed(perk)) {
                    toolTip.add(new TranslationTextComponent("perk.info.astralsorcery.sealed").mergeStyle(TextFormatting.RED));
                    toolTip.add(new TranslationTextComponent("perk.info.astralsorcery.sealed.break").mergeStyle(TextFormatting.RED));
                } else if (perkData.hasPerkEffect(perk)) {
                    toolTip.add(new TranslationTextComponent("perk.info.astralsorcery.active").mergeStyle(TextFormatting.GREEN));
                } else if (perk.mayUnlockPerk(prog, player)) {
                    toolTip.add(new TranslationTextComponent("perk.info.astralsorcery.available").mergeStyle(TextFormatting.BLUE));
                } else {
                    toolTip.add(new TranslationTextComponent("perk.info.astralsorcery.locked").mergeStyle(TextFormatting.GRAY));
                }
                if (Minecraft.getInstance().gameSettings.advancedItemTooltips && perk.getCategory() != AbstractPerk.CATEGORY_BASE) {
                    toolTip.add(perk.getCategory().getName().mergeStyle(TextFormatting.GRAY).mergeStyle(TextFormatting.ITALIC));
                }
                Collection<IFormattableTextComponent> modInfo = perk.getSource();
                if (modInfo != null) {
                    for (IFormattableTextComponent cmp : modInfo) {
                        toolTip.add(cmp.mergeStyle(TextFormatting.BLUE).mergeStyle(TextFormatting.ITALIC));
                    }
                }
                if (Minecraft.getInstance().gameSettings.showDebugInfo) {
                    toolTip.add(StringTextComponent.EMPTY);
                    toolTip.add(new StringTextComponent(perk.getRegistryName().toString()).mergeStyle(TextFormatting.GRAY));
                    toolTip.add(new TranslationTextComponent("astralsorcery.misc.ctrlcopy").mergeStyle(TextFormatting.GRAY));
                }
                RenderingDrawUtils.renderBlueTooltipComponents(renderStack, mouseX, mouseY, this.getGuiZLevel(), toolTip, font, true);
                break;
            }
        }
    }
}
Also used : PlayerPerkData(hellfirepvp.astralsorcery.common.data.research.PlayerPerkData) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) PlayerEntity(net.minecraft.entity.player.PlayerEntity) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack)

Example 5 with PlayerPerkData

use of hellfirepvp.astralsorcery.common.data.research.PlayerPerkData in project AstralSorcery by HellFirePvP.

the class AbstractPerk method getPerkStatus.

public AllocationStatus getPerkStatus(@Nullable PlayerEntity player, LogicalSide side) {
    if (player == null) {
        return AllocationStatus.UNALLOCATED;
    }
    PlayerProgress progress = ResearchHelper.getProgress(player, side);
    if (!progress.isValid()) {
        return AllocationStatus.UNALLOCATED;
    }
    PlayerPerkData perkData = progress.getPerkData();
    if (perkData.hasPerkAllocation(this, PerkAllocationType.UNLOCKED)) {
        return AllocationStatus.ALLOCATED;
    }
    if (perkData.hasPerkAllocation(this)) {
        return AllocationStatus.GRANTED;
    }
    return mayUnlockPerk(progress, player) ? AllocationStatus.UNLOCKABLE : AllocationStatus.UNALLOCATED;
}
Also used : PlayerPerkData(hellfirepvp.astralsorcery.common.data.research.PlayerPerkData) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress)

Aggregations

PlayerPerkData (hellfirepvp.astralsorcery.common.data.research.PlayerPerkData)9 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)8 PlayerEntity (net.minecraft.entity.player.PlayerEntity)6 ItemStack (net.minecraft.item.ItemStack)3 ScalingPoint (hellfirepvp.astralsorcery.client.screen.helper.ScalingPoint)2 PktRequestPerkSealAction (hellfirepvp.astralsorcery.common.network.play.client.PktRequestPerkSealAction)2 AbstractPerk (hellfirepvp.astralsorcery.common.perk.AbstractPerk)2 PerkTreePoint (hellfirepvp.astralsorcery.common.perk.tree.PerkTreePoint)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)2 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 ScreenJournalOverlayPerkStatistics (hellfirepvp.astralsorcery.client.screen.journal.overlay.ScreenJournalOverlayPerkStatistics)1 PktPerkGemModification (hellfirepvp.astralsorcery.common.network.play.client.PktPerkGemModification)1 PktUnlockPerk (hellfirepvp.astralsorcery.common.network.play.client.PktUnlockPerk)1 GemSocketPerk (hellfirepvp.astralsorcery.common.perk.node.socket.GemSocketPerk)1 ArrayList (java.util.ArrayList)1 Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1