use of net.minecraft.client.gui.ScaledResolution in project Guide-API by TeamAmeriFrance.
the class InfoRendererDescription method drawInformation.
@Override
public void drawInformation(Book book, World world, BlockPos pos, IBlockState state, RayTraceResult rayTrace, EntityPlayer player) {
if (tiny) {
GlStateManager.pushMatrix();
GlStateManager.scale(0.5F, 0.5F, 0.5F);
}
ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft());
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
int scaleMulti = tiny ? 2 : 1;
GuiHelper.drawItemStack(stack, (resolution.getScaledWidth() / 2 + 55) * scaleMulti, ((resolution.getScaledHeight() / 2 - (tiny ? 20 : 30)) + yOffset) * scaleMulti);
int y = 0;
String toDraw = StringEscapeUtils.unescapeJava(description.getFormattedText()).replaceAll("\\t", " ");
String[] lines = toDraw.split("\n");
for (String line : lines) {
List<String> cutLines = fontRenderer.listFormattedStringToWidth(line, 100 * scaleMulti);
for (String cut : cutLines) {
fontRenderer.drawStringWithShadow(cut, (resolution.getScaledWidth() / 2 + 20) * scaleMulti, (((resolution.getScaledHeight() / 2 - 10) - y) * scaleMulti) + yOffset, Color.WHITE.getRGB());
y -= 10 / scaleMulti;
}
}
if (tiny)
GlStateManager.popMatrix();
}
use of net.minecraft.client.gui.ScaledResolution in project Witchworks by Um-Mitternacht.
the class EnergyHUD method renderOverlay.
@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR && renderTime > 0) {
Minecraft mc = Minecraft.getMinecraft();
Optional<IEnergy> optional = EnergyHandler.getEnergy(mc.player);
if (optional.isPresent()) {
IEnergy energy = optional.get();
ScaledResolution res = event.getResolution();
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
float filled = (float) energy.get() / (float) energy.getMax();
int heightEnd = ENERGY_HUD.heightEnd;
int heightStart = ENERGY_HUD.heightStart;
int width = ENERGY_HUD.width;
int heightUsed = heightEnd - heightStart;
int heightFilled = (int) ((heightUsed - 28) * filled);
int posX = ENERGY_HUD.x;
int posY = res.getScaledHeight() - ENERGY_HUD.y;
int startPosX = posX - heightEnd;
if (ENERGY_HUD.hide)
GlStateManager.color(1F, 1F, 1F, visible);
mc.getTextureManager().bindTexture(ResourceLocations.ENERGY_BACKGROUND[0]);
Gui.drawModalRectWithCustomSizedTexture(startPosX - 4, posY + 14, 0F, heightUsed - 28, width, heightFilled, width, heightUsed - 28);
GlStateManager.pushMatrix();
GlStateManager.color(1F, 1F, 1F, visible == 1F ? barAlpha : visible);
mc.getTextureManager().bindTexture(ResourceLocations.ENERGY_BACKGROUND[1]);
Gui.drawModalRectWithCustomSizedTexture(startPosX - 4, posY + 14, 0F, heightUsed - 28, width, heightFilled, width, heightUsed - 28);
GlStateManager.popMatrix();
if (ENERGY_HUD.hide)
GlStateManager.color(1F, 1F, 1F, visible);
mc.getTextureManager().bindTexture(ResourceLocations.ENERGY);
Gui.drawModalRectWithCustomSizedTexture(startPosX - 4, posY, 0F, 0F, width, heightUsed, width, heightUsed);
int textColor = 0x990066;
if (ENERGY_HUD.hide) {
int alpha = (int) (visible * 255);
textColor = alpha << 24 | 0x990066;
}
mc.fontRenderer.drawStringWithShadow("E: " + energy.get(), startPosX, posY - 15, textColor);
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}
}
use of net.minecraft.client.gui.ScaledResolution in project LogisticsPipes by RS485.
the class DisconnectionConfigurationPopup method drawGuiContainerForegroundLayer.
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY, float partialTick) {
drawRect(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, 0xff000000);
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int vpx = bounds.x * scaledresolution.getScaleFactor();
int vpy = (bounds.y + 10) * scaledresolution.getScaleFactor();
int w = bounds.width * scaledresolution.getScaleFactor();
int h = (bounds.height - 1) * scaledresolution.getScaleFactor();
mc.fontRenderer.drawString(StringUtils.translate(PREFIX + "disconnectTitle"), guiLeft + 8, guiTop + 8, logisticspipes.utils.Color.getValue(logisticspipes.utils.Color.DARKER_GREY), false);
configDisplay.drawScreen(mouseX, mouseY, partialTick, new Rectangle(vpx, vpy, w, h), bounds);
}
use of net.minecraft.client.gui.ScaledResolution in project LogisticsPipes by RS485.
the class SneakyConfigurationPopup method drawGuiContainerForegroundLayer.
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY, float partialTick) {
drawRect(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, 0xff000000);
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int vpx = bounds.x * scaledresolution.getScaleFactor();
int vpy = (bounds.y + 10) * scaledresolution.getScaleFactor();
int w = bounds.width * scaledresolution.getScaleFactor();
int h = (bounds.height - 1) * scaledresolution.getScaleFactor();
mc.fontRenderer.drawString(StringUtils.translate(PREFIX + "sneakyTitle"), guiLeft + 8, guiTop + 8, Color.getValue(Color.DARKER_GREY), false);
configDisplay.drawScreen(mouseX, mouseY, partialTick, new Rectangle(vpx, vpy, w, h), bounds);
}
use of net.minecraft.client.gui.ScaledResolution in project malmo by Microsoft.
the class ScreenHelper method onRenderTick.
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev) {
purgeExpiredFragments(null);
if (Minecraft.getMinecraft().currentScreen != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu))
return;
int displayWidth = Minecraft.getMinecraft().displayWidth;
int displayHeight = Minecraft.getMinecraft().displayHeight;
ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft(), displayWidth, displayHeight);
int width = res.getScaledWidth();
int height = res.getScaledHeight();
float rx = (float) width / 1000f;
float ry = (float) height / 1000f;
synchronized (this.fragments) {
for (TextCategory cat : TextCategory.values()) {
TextCategoryAttributes atts = this.attributes.get(cat);
if (atts != null && (!atts.flashing || ((System.currentTimeMillis() / 500) % 3 != 0)) && shouldDisplay(atts.displayLevel)) {
int x = Math.round(rx * (float) atts.xOrg);
int y = Math.round(ry * (float) atts.yOrg);
ArrayList<TextFragment> frags = this.fragments.get(cat);
if (frags != null && !frags.isEmpty()) {
for (TextFragment frag : frags) {
drawText(frag.text, x, y, atts.colour);
y += 10;
}
}
}
}
}
}
Aggregations