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();
}
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;
}
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));
}
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;
}
}
}
}
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;
}
Aggregations