use of net.minecraft.client.font.TextRenderer in project Skyblocker by LifeIsAParadox.
the class DummyInventory method renderPreview.
public static boolean renderPreview(MatrixStack matrices, int index, int mouseX, int mouseY) {
if (index >= 9 && index < 18)
index -= 9;
else if (index >= 27 && index < 45)
index -= 18;
else
return false;
if (storage[index] == null)
return false;
int rows = (storage[index].size() - 9) / 9;
Screen screen = MinecraftClient.getInstance().currentScreen;
int x = mouseX + 184 >= screen.width ? mouseX - 188 : mouseX + 8;
int y = Math.max(0, mouseY - 16);
RenderSystem.disableDepthTest();
RenderSystem.setShaderTexture(0, TEXTURE);
instance.drawTexture(matrices, x, y, 0, 0, 176, 7);
for (int i = 0; i < rows; ++i) instance.drawTexture(matrices, x, y + i * 18 + 7, 0, 7, 176, 18);
instance.drawTexture(matrices, x, y + rows * 18 + 7, 0, 25, 176, 7);
RenderSystem.enableDepthTest();
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
for (int i = 9; i < storage[index].size(); ++i) {
int itemX = x + (i - 9) % 9 * 18 + 8;
int itemY = y + (i - 9) / 9 * 18 + 8;
itemRenderer.zOffset = 200.0F;
itemRenderer.renderInGui(storage[index].getStack(i), itemX, itemY);
itemRenderer.renderGuiItemOverlay(textRenderer, storage[index].getStack(i), itemX, itemY);
itemRenderer.zOffset = 0.0F;
}
return true;
}
use of net.minecraft.client.font.TextRenderer in project Skyblocker by LifeIsAParadox.
the class FancyStatusBars method renderText.
private void renderText(MatrixStack matrices, int value, int left, int top, int color) {
TextRenderer textRenderer = client.textRenderer;
String text = Integer.toString(value);
int x = left + (33 - textRenderer.getWidth(text)) / 2;
int y = top - 3;
// for i in [-1, 1]
for (int i = -1; i < 2; i += 2) {
textRenderer.draw(matrices, text, (float) (x + i), (float) y, 0);
textRenderer.draw(matrices, text, (float) x, (float) (y + i), 0);
}
textRenderer.draw(matrices, text, (float) x, (float) y, color);
}
use of net.minecraft.client.font.TextRenderer in project jGui by ReplayMod.
the class AbstractGuiDropdownMenu method draw.
@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
super.draw(renderer, size, renderInfo);
TextRenderer fontRenderer = MCVer.getFontRenderer();
if (renderInfo.layer == 0) {
int width = size.getWidth();
int height = size.getHeight();
// Draw box
renderer.drawRect(0, 0, width, height, OUTLINE_COLOR);
renderer.drawRect(1, 1, width - 2, height - 2, ReadableColor.BLACK);
renderer.drawRect(width - height, 0, 1, height, OUTLINE_COLOR);
// Draw triangle
int base = height - 6;
int tHeight = base / 2;
int x = width - 3 - base / 2;
int y = height / 2 - 2;
for (int layer = tHeight; layer > 0; layer--) {
renderer.drawRect(x - layer, y + (tHeight - layer), layer * 2 - 1, 1, OUTLINE_COLOR);
}
renderer.drawString(3, height / 2 - fontRenderer.fontHeight / 2, ReadableColor.WHITE, toString.apply(getSelectedValue()));
} else if (renderInfo.layer == 1) {
ReadablePoint offsetPoint = new Point(0, size.getHeight());
ReadableDimension offsetSize = new Dimension(size.getWidth(), (fontRenderer.fontHeight + 5) * values.length);
OffsetGuiRenderer offsetRenderer = new OffsetGuiRenderer(renderer, offsetPoint, offsetSize);
offsetRenderer.startUsing();
try {
dropdown.draw(offsetRenderer, offsetSize, renderInfo.offsetMouse(0, offsetPoint.getY()).layer(0));
} finally {
offsetRenderer.stopUsing();
}
}
}
use of net.minecraft.client.font.TextRenderer in project jGui by ReplayMod.
the class AbstractGuiDropdownMenu method calcMinSize.
@Override
protected ReadableDimension calcMinSize() {
TextRenderer fontRenderer = MCVer.getFontRenderer();
int maxWidth = 0;
for (V value : values) {
int width = fontRenderer.getWidth(toString.apply(value));
if (width > maxWidth) {
maxWidth = width;
}
}
return new Dimension(11 + maxWidth + fontRenderer.fontHeight, fontRenderer.fontHeight + 4);
}
use of net.minecraft.client.font.TextRenderer in project jGui by ReplayMod.
the class AbstractGuiDropdownMenu method layout.
@Override
public void layout(ReadableDimension size, RenderInfo renderInfo) {
super.layout(size, renderInfo);
TextRenderer fontRenderer = MCVer.getFontRenderer();
if (renderInfo.layer == 1) {
ReadablePoint offsetPoint = new Point(0, size.getHeight());
ReadableDimension offsetSize = new Dimension(size.getWidth(), (fontRenderer.fontHeight + 5) * values.length);
dropdown.layout(offsetSize, renderInfo.offsetMouse(0, offsetPoint.getY()).layer(0));
}
}
Aggregations