use of net.minecraft.client.renderer.texture.DynamicTexture in project IDEProgram by Itay2805.
the class GLCanvas method render.
@Override
public void render(Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) {
ByteBuffer buffer = ByteBuffer.allocate(width * height * 3);
gl.readPixels(0, 0, width, height, GL.RGB, GL.BYTE, buffer);
image.getRaster().setDataElements(0, 0, width, height, buffer.array());
rc = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("opengl11_context_image", new DynamicTexture(image));
mc.getRenderManager().renderEngine.bindTexture(rc);
drawRectWithFullTexture(x, y, 0, 0, width, height);
}
use of net.minecraft.client.renderer.texture.DynamicTexture in project Hyperium by HyperiumClient.
the class PlayerStatsGui method drawScreen.
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
if (!texturesImage.isEmpty()) {
texturesImage.forEach((s, value) -> {
if (!logos.containsKey(s))
logos.put(s, new DynamicTexture(value));
});
}
super.drawScreen(mouseX, mouseY, partialTicks);
ScaledResolution current = ResolutionUtil.current();
HypixelApiGuild guild = player.getGuild();
if (guild == null) {
GeneralChatHandler.instance().sendMessage("Player not found!");
mc.displayGuiScreen(null);
return;
}
boolean isInGuild = guild.isLoaded() && guild.isValid();
drawScaledText(player.getDisplayString() + (isInGuild ? " " + guild.getFormatedTag() : ""), current.getScaledWidth() / 2, 30, 2, -1, true, true);
if (focused == null) {
final int blockWidth = 64 + 32;
int blocksPerLine = (int) (current.getScaledWidth() / (1.2D * blockWidth));
if (blocksPerLine % 2 == 1) {
blocksPerLine--;
}
final int startX = ResolutionUtil.current().getScaledWidth() / 2 - (blocksPerLine * blockWidth / 2);
int x = -1;
int y = 0;
hovered = null;
for (AbstractHypixelStats field : fields) {
DynamicTexture dynamicTexture = logos.get(field);
x++;
if (x > blocksPerLine) {
x = 0;
y++;
}
if (dynamicTexture != null) {
int y1 = 100 + y * blockWidth - 10 - offset;
if (y1 < 70)
continue;
GlStateManager.pushMatrix();
GlStateManager.resetColor();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
int y2 = 100 + y * blockWidth - offset;
int x1 = startX + x * blockWidth;
GuiBlock value = new GuiBlock(x1, x1 + blockWidth / 2, y2, y2 + blockWidth / 2);
if (value.isMouseOver(mouseX, mouseY)) {
hovered = field;
}
location.put(field, value);
GlStateManager.translate(x1, y2, 0);
GlStateManager.bindTexture(dynamicTexture.getGlTextureId());
GlStateManager.scale(.2, .2, .2);
drawTexturedModalRect(0, 0, 0, 0, 128 * 2, 128 * 2);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
GlStateManager.translate(startX + x * blockWidth + 24, y1, 0);
drawScaledText(field.getName(), 0, 0, 1.0, Color.RED.getRGB(), true, true);
GlStateManager.popMatrix();
}
}
if (hovered != null) {
List<StatsDisplayItem> preview = hovered.getPreview(player);
int width = 0;
int height = 0;
for (StatsDisplayItem statsDisplayItem : preview) {
width = Math.max(width, statsDisplayItem.width);
height += statsDisplayItem.height;
}
GuiBlock block = location.get(hovered);
int xOffset = 0;
int yRenderOffset = 16;
int rightSide = block.getRight() + (width + yRenderOffset) * 2;
if (rightSide > current.getScaledWidth()) {
xOffset = rightSide - current.getScaledWidth();
}
float scale = 1.0F;
GlStateManager.scale(scale, scale, scale);
int left = block.getRight() - xOffset + yRenderOffset - 8;
int top = block.getTop();
int printY = 0;
if (top + height * 2 > current.getScaledHeight()) {
top = current.getScaledHeight() - height * 2 - 50;
}
RenderUtils.drawRect((left - 3) / scale, (top - 3) / scale, (left + (width + 3) * scale) / scale, (top + (height + 3) * scale) / scale, new Color(0, 0, 0, 220).getRGB());
for (StatsDisplayItem statsDisplayItem : preview) {
statsDisplayItem.draw((int) (left / scale), (int) ((top) / scale) + printY);
printY += statsDisplayItem.height;
}
GlStateManager.scale(1 / scale, 1 / scale, 1 / scale);
}
} else {
DynamicTexture dynamicTexture = logos.get(focused);
GlStateManager.resetColor();
GlStateManager.pushMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.bindTexture(dynamicTexture.getGlTextureId());
GlStateManager.translate((current.getScaledWidth() >> 1) - 24, 80, 0);
GlStateManager.scale(.2, .2, .2);
drawTexturedModalRect(0, 0, 0, 0, 128 * 2, 128 * 2);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
drawScaledText(focused.getName(), current.getScaledWidth() / 2, 60, 2.0, Color.RED.getRGB(), true, true);
Icons.EXTENSION.bind();
GlStateModifier.INSTANCE.reset();
Icons.EXIT.bind();
float scale = 2.0F;
GlStateManager.scale(scale, scale, scale);
GlStateManager.translate(current.getScaledWidth() / 2F / scale - 90 / scale, (73) / scale, 0);
GlStateManager.rotate(180, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(-16, -16, 0);
drawScaledCustomSizeModalRect(0, 0, 0, 0, 64, 64, 16, 16, 64, 64);
GlStateManager.popMatrix();
}
}
use of net.minecraft.client.renderer.texture.DynamicTexture in project Hyperium by HyperiumClient.
the class GuiHyperiumCredits method fetch.
private static void fetch(int tries) {
try {
String content = IOUtils.toString(URI.create("https://api.github.com/repos/HyperiumClient/Hyperium/stats/contributors"), StandardCharsets.UTF_8);
JsonParser parser = new JsonParser();
JsonArray a = parser.parse(content).getAsJsonArray();
StreamSupport.stream(a.spliterator(), false).map(JsonElement::getAsJsonObject).filter(o -> o.has("total") & o.get("total").getAsInt() > 20).sorted(Comparator.comparingLong(o -> ((JsonObject) o).get("total").getAsInt()).reversed()).forEach(o -> {
JsonObject con = o.get("author").getAsJsonObject();
try {
BufferedImage bi = ImageIO.read(new URL(con.get("avatar_url").getAsString() + "&size=64"));
Minecraft.getMinecraft().addScheduledTask(() -> {
DynamicTexture tx = new DynamicTexture(bi);
try {
tx.loadTexture(Minecraft.getMinecraft().getResourceManager());
contributors.put(con.get("login").getAsString(), tx);
commits.put(con.get("login").getAsString(), o.get("total").getAsInt());
} catch (IOException e) {
e.printStackTrace();
}
}).get();
} catch (IOException | InterruptedException | ExecutionException e) {
e.printStackTrace();
}
});
} catch (Exception e) {
e.printStackTrace();
if (tries < 5)
fetch(tries + 1);
else
err = e.getMessage();
}
}
Aggregations