use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.
the class ScreenRefractionTable method render.
@Override
public void render(MatrixStack renderStack, int mouseX, int mouseY, float pTicks) {
RenderSystem.enableDepthTest();
super.render(renderStack, mouseX, mouseY, pTicks);
this.mapRenderedConstellations.clear();
if (this.getTile().hasParchment()) {
this.drawWHRect(renderStack, TexturesAS.TEX_GUI_REFRACTION_TABLE_PARCHMENT);
} else {
this.drawWHRect(renderStack, TexturesAS.TEX_GUI_REFRACTION_TABLE_EMPTY);
}
if (DayTimeHelper.getCurrentDaytimeDistribution(this.getTile().getWorld()) <= 0.05 || !this.getTile().hasParchment()) {
this.currentlyDrawnConstellations.clear();
this.dragging = null;
}
List<ITextProperties> tooltip = new ArrayList<>();
FontRenderer tooltipRenderer = Minecraft.getInstance().fontRenderer;
tooltipRenderer = this.renderTileItems(renderStack, mouseX, mouseY, tooltip, tooltipRenderer);
this.renderConstellationOptions(renderStack, mouseX, mouseY, tooltip);
this.renderRunningHalo(renderStack);
this.renderInputItem(renderStack);
this.renderDrawnConstellations(renderStack, mouseX, mouseY, tooltip);
this.renderDraggedConstellations(renderStack);
this.renderDragging(renderStack, mouseX, mouseY);
if (!tooltip.isEmpty()) {
this.setBlitOffset(510);
RenderingDrawUtils.renderBlueTooltipComponents(renderStack, mouseX, mouseY, this.getGuiZLevel(), tooltip, tooltipRenderer, true);
this.setBlitOffset(0);
}
}
use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.
the class ScreenRefractionTable method renderConstellationOptions.
private void renderConstellationOptions(MatrixStack renderStack, int mouseX, int mouseY, List<ITextProperties> tooltip) {
ItemStack glass = this.getTile().getGlassStack();
if (glass.isEmpty()) {
return;
}
World world = this.getTile().getWorld();
float nightPerc = DayTimeHelper.getCurrentDaytimeDistribution(world);
WorldContext ctx = SkyHandler.getContext(world, LogicalSide.CLIENT);
if (ctx == null || !this.getTile().doesSeeSky() || nightPerc <= 0.05F) {
return;
}
List<IConstellation> cstList = ctx.getActiveCelestialsHandler().getActiveConstellations().stream().filter(c -> ResearchHelper.getClientProgress().hasConstellationDiscovered(c)).collect(Collectors.toList());
Random rand = new Random(WorldSeedCache.getSeedIfPresent(world.getDimensionKey()).orElse(0x515F1EB654AB915EL));
for (int i = 0; i < ctx.getConstellationHandler().getLastTrackedDay(); i++) {
rand.nextLong();
}
Collections.shuffle(cstList, rand);
for (int i = 0; i < Math.min(cstList.size(), 12); i++) {
IConstellation cst = cstList.get(i);
int offsetX = guiLeft + (i % 2 == 0 ? 8 : 232);
int offsetY = guiTop + (40 + (i / 2) * 23);
Rectangle rct = new Rectangle(offsetX, offsetY, 16, 16);
this.mapRenderedConstellations.put(rct, cst);
RenderSystem.enableBlend();
Blending.DEFAULT.apply();
RenderingConstellationUtils.renderConstellationIntoGUI(Color.WHITE, cst, renderStack, offsetX, offsetY, this.getGuiZLevel(), 16, 16, 0.5, () -> DayTimeHelper.getCurrentDaytimeDistribution(world), true, false);
RenderSystem.disableBlend();
if (rct.contains(mouseX, mouseY)) {
tooltip.add(cst.getConstellationName());
}
}
}
use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.
the class ScreenJournalConstellationDetail method buildRitualText.
private void buildRitualText() {
if (this.constellation instanceof IMinorConstellation) {
if (ResearchHelper.getClientProgress().getTierReached().isThisLaterOrEqual(ProgressionTier.TRAIT_CRAFT)) {
ITextComponent txtRitual = ((IMinorConstellation) this.constellation).getInfoTraitEffect();
ITextProperties headTxt = new TranslationTextComponent("astralsorcery.journal.constellation.ritual.trait");
locTextRitual.add(localize(headTxt));
locTextRitual.add(IReorderingProcessor.field_242232_a);
List<IReorderingProcessor> lines = new LinkedList<>();
for (String segment : txtRitual.getString().split("<NL>")) {
lines.addAll(font.trimStringToWidth(new StringTextComponent(segment), JournalPage.DEFAULT_WIDTH));
lines.add(IReorderingProcessor.field_242232_a);
}
locTextRitual.addAll(lines);
}
} else if (this.constellation instanceof IWeakConstellation) {
if (ResearchHelper.getClientProgress().getTierReached().isThisLaterOrEqual(ProgressionTier.ATTUNEMENT)) {
ITextComponent txtRitual = ((IWeakConstellation) this.constellation).getInfoRitualEffect();
ITextProperties headTxt = new TranslationTextComponent("astralsorcery.journal.constellation.ritual");
locTextRitual.add(localize(headTxt));
locTextRitual.add(IReorderingProcessor.field_242232_a);
List<IReorderingProcessor> lines = new LinkedList<>();
for (String segment : txtRitual.getString().split("<NL>")) {
lines.addAll(font.trimStringToWidth(new StringTextComponent(segment), JournalPage.DEFAULT_WIDTH));
lines.add(IReorderingProcessor.field_242232_a);
}
locTextRitual.addAll(lines);
locTextRitual.add(IReorderingProcessor.field_242232_a);
}
if (ResearchHelper.getClientProgress().getTierReached().isThisLaterOrEqual(ProgressionTier.TRAIT_CRAFT)) {
ITextComponent txtCorruptedRitual = ((IWeakConstellation) this.constellation).getInfoCorruptedRitualEffect();
ITextProperties headTxt = new TranslationTextComponent("astralsorcery.journal.constellation.corruption");
locTextRitual.add(localize(headTxt));
locTextRitual.add(IReorderingProcessor.field_242232_a);
List<IReorderingProcessor> lines = new LinkedList<>();
for (String segment : txtCorruptedRitual.getString().split("<NL>")) {
lines.addAll(font.trimStringToWidth(new StringTextComponent(segment), JournalPage.DEFAULT_WIDTH));
lines.add(IReorderingProcessor.field_242232_a);
}
locTextRitual.addAll(lines);
locTextRitual.add(IReorderingProcessor.field_242232_a);
}
}
}
use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.
the class ScreenJournalConstellationDetail method drawPageExtendedInformation.
private void drawPageExtendedInformation(MatrixStack renderStack) {
ITextProperties info = this.getConstellation().getConstellationTag();
if (!detailed) {
info = new TranslationTextComponent("astralsorcery.journal.constellation.unknown");
}
int width = font.getStringPropertyWidth(info);
float chX = 305 - (width / 2F);
renderStack.push();
renderStack.translate(guiLeft + chX, guiTop + 44, this.getGuiZLevel());
RenderingDrawUtils.renderStringAt(font, renderStack, info, 0xFFCCCCCC);
renderStack.pop();
if (detailed && !locTextMain.isEmpty()) {
int offsetX = 220, offsetY = 77;
renderStack.push();
renderStack.translate(guiLeft + offsetX, guiTop + offsetY, this.getGuiZLevel());
for (IReorderingProcessor line : locTextMain) {
RenderingDrawUtils.renderStringAt(font, renderStack, line, 0xFFCCCCCC);
renderStack.translate(0, 13, 0);
}
renderStack.pop();
}
}
use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.
the class RenderingDrawUtils method renderTooltip.
public static void renderTooltip(MatrixStack renderStack, float x, float y, float zLevel, List<Tuple<ItemStack, ITextProperties>> tooltipData, FontRenderer fontRenderer, boolean isFirstLineHeadline, int color, int colorFade, Color strColor) {
int stackBoxSize = 18;
if (!tooltipData.isEmpty()) {
boolean anyItemFound = false;
int maxWidth = 0;
for (Tuple<ItemStack, ITextProperties> toolTip : tooltipData) {
FontRenderer customFR = toolTip.getA().getItem().getFontRenderer(toolTip.getA());
if (customFR == null) {
customFR = fontRenderer;
}
int width = customFR.getStringPropertyWidth(toolTip.getB());
if (!toolTip.getA().isEmpty()) {
anyItemFound = true;
}
if (anyItemFound) {
width += stackBoxSize;
}
if (width > maxWidth) {
maxWidth = width;
}
}
if (x + 15 + maxWidth > Minecraft.getInstance().getMainWindow().getScaledWidth()) {
x -= maxWidth + 24;
}
int formatWidth = anyItemFound ? maxWidth - stackBoxSize : maxWidth;
List<Tuple<ItemStack, List<IReorderingProcessor>>> lengthLimitedToolTip = new LinkedList<>();
for (Tuple<ItemStack, ITextProperties> toolTip : tooltipData) {
FontRenderer customFR = toolTip.getA().getItem().getFontRenderer(toolTip.getA());
if (customFR == null) {
customFR = fontRenderer;
}
List<IReorderingProcessor> textLines = customFR.trimStringToWidth(toolTip.getB(), formatWidth);
if (textLines.isEmpty()) {
textLines = Collections.singletonList(IReorderingProcessor.field_242232_a);
}
lengthLimitedToolTip.add(new Tuple<>(toolTip.getA(), textLines));
}
float pX = x + 12;
float pY = y - 12;
int sumLineHeight = 0;
if (!lengthLimitedToolTip.isEmpty()) {
if (lengthLimitedToolTip.size() > 1 && isFirstLineHeadline) {
sumLineHeight += 2;
}
Iterator<Tuple<ItemStack, List<IReorderingProcessor>>> iterator = lengthLimitedToolTip.iterator();
while (iterator.hasNext()) {
Tuple<ItemStack, List<IReorderingProcessor>> toolTip = iterator.next();
int segmentHeight = 0;
if (!toolTip.getA().isEmpty()) {
segmentHeight += 2;
segmentHeight += stackBoxSize;
segmentHeight += (Math.max(toolTip.getB().size() - 1, 0)) * 10;
} else {
segmentHeight += toolTip.getB().size() * 10;
}
if (!iterator.hasNext()) {
segmentHeight -= 2;
}
sumLineHeight += segmentHeight;
}
}
drawGradientRect(renderStack, zLevel, pX - 3, pY - 4, pX + maxWidth + 3, pY - 3, color, colorFade);
drawGradientRect(renderStack, zLevel, pX - 3, pY + sumLineHeight + 3, pX + maxWidth + 3, pY + sumLineHeight + 4, color, colorFade);
drawGradientRect(renderStack, zLevel, pX - 3, pY - 3, pX + maxWidth + 3, pY + sumLineHeight + 3, color, colorFade);
drawGradientRect(renderStack, zLevel, pX - 4, pY - 3, pX - 3, pY + sumLineHeight + 3, color, colorFade);
drawGradientRect(renderStack, zLevel, pX + maxWidth + 3, pY - 3, pX + maxWidth + 4, pY + sumLineHeight + 3, color, colorFade);
int col = (color & 0x00FFFFFF) | color & 0xFF000000;
drawGradientRect(renderStack, zLevel, pX - 3, pY - 3 + 1, pX - 3 + 1, pY + sumLineHeight + 3 - 1, color, col);
drawGradientRect(renderStack, zLevel, pX + maxWidth + 2, pY - 3 + 1, pX + maxWidth + 3, pY + sumLineHeight + 3 - 1, color, col);
drawGradientRect(renderStack, zLevel, pX - 3, pY - 3, pX + maxWidth + 3, pY - 3 + 1, col, col);
drawGradientRect(renderStack, zLevel, pX - 3, pY + sumLineHeight + 2, pX + maxWidth + 3, pY + sumLineHeight + 3, color, color);
int offset = anyItemFound ? stackBoxSize : 0;
renderStack.push();
renderStack.translate(pX, pY, 0);
boolean first = true;
for (Tuple<ItemStack, List<IReorderingProcessor>> toolTip : lengthLimitedToolTip) {
int minYShift = 10;
if (!toolTip.getA().isEmpty()) {
renderStack.push();
renderStack.translate(0, 0, zLevel);
RenderingUtils.renderItemStackGUI(renderStack, toolTip.getA(), null);
renderStack.pop();
minYShift = stackBoxSize;
renderStack.translate(0, 2, 0);
}
for (IReorderingProcessor text : toolTip.getB()) {
FontRenderer customFR = toolTip.getA().getItem().getFontRenderer(toolTip.getA());
if (customFR == null) {
customFR = fontRenderer;
}
renderStack.push();
renderStack.translate(offset, 0, zLevel);
renderStringAt(text, renderStack, customFR, strColor.getRGB(), false);
renderStack.pop();
renderStack.translate(0, 10, 0);
minYShift -= 10;
}
if (minYShift > 0) {
renderStack.translate(0, minYShift, 0);
}
if (isFirstLineHeadline && first) {
renderStack.translate(0, 2, 0);
}
first = false;
}
renderStack.pop();
}
}
Aggregations