configList = NotEnoughUpdates.INSTANCE.config.profileViewer.pageLayout;
for (int i = 0; i < configList.size(); i++) {
ProfileViewerPage page = ProfileViewerPage.getById(configList.get(i));
if (page == null) continue;
if (page.stack == null || (page == ProfileViewerPage.BINGO && !showBingoPage)) {
ignoredTabs++;
continue;
}
int i2 = i - ignoredTabs;
int x = guiLeft + i2 * 28;
int y = guiTop - 28;
if (mouseX > x && mouseX < x + 28) {
if (mouseY > y && mouseY < y + 32) {
if (currentPage != page) Utils.playPressSound();
currentPage = page;
inventoryTextField.otherComponentClick();
playerNameTextField.otherComponentClick();
return;
}
}
}
}
if (pages.containsKey(currentPage)) {
if (pages.get(currentPage).mouseClicked(mouseX, mouseY, mouseButton)) {
return;
}
}
if (mouseX > guiLeft + sizeX - 100 && mouseX < guiLeft + sizeX) {
if (mouseY > guiTop + sizeY + 5 && mouseY < guiTop + sizeY + 25) {
playerNameTextField.mouseClicked(mouseX, mouseY, mouseButton);
inventoryTextField.otherComponentClick();
return;
}
}
if (
mouseX > guiLeft + 106 &&
mouseX < guiLeft + 106 + 100 &&
profile != null &&
!profile.getProfileNames().isEmpty() &&
profileId != null
) {
if (mouseY > guiTop + sizeY + 3 && mouseY < guiTop + sizeY + 23) {
try {
Desktop desk = Desktop.getDesktop();
desk.browse(
new URI(
"https://sky.shiiyu.moe/stats/" + profile.getHypixelProfile().get("displayname").getAsString() + "/" +
profileId
)
);
Utils.playPressSound();
return;
} catch (UnsupportedOperationException | IOException | URISyntaxException ignored) {
//no idea how this sounds, but ya know just in case
Utils.playSound(new ResourceLocation("game.player.hurt"), true);
return;
}
}
}
if (mouseX > guiLeft && mouseX < guiLeft + 100 && profile != null && !profile.getProfileNames().isEmpty()) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
if (mouseY > guiTop + sizeY + 3 && mouseY < guiTop + sizeY + 23) {
if (scaledResolution.getScaleFactor() >= 4) {
profileDropdownSelected = false;
int profileNum = 0;
for (int index = 0; index < profile.getProfileNames().size(); index++) {
if (profile.getProfileNames().get(index).equals(profileId)) {
profileNum = index;
break;
}
}
if (mouseButton == 0) {
profileNum++;
} else {
profileNum--;
}
if (profileNum >= profile.getProfileNames().size()) profileNum = 0;
if (profileNum < 0) profileNum = profile.getProfileNames().size() - 1;
String newProfileId = profile.getProfileNames().get(profileNum);
if (profileId != null && !profileId.equals(newProfileId)) {
resetCache();
}
profileId = newProfileId;
} else {
profileDropdownSelected = !profileDropdownSelected;
}
} else if (scaledResolution.getScaleFactor() < 4 && profileDropdownSelected) {
int dropdownOptionSize = scaledResolution.getScaleFactor() == 3 ? 10 : 20;
int extraY = mouseY - (guiTop + sizeY + 23);
int index = extraY / dropdownOptionSize;
if (index >= 0 && index < profile.getProfileNames().size()) {
String newProfileId = profile.getProfileNames().get(index);
if (profileId != null && !profileId.equals(newProfileId)) {
resetCache();
}
profileId = newProfileId;
}
}
playerNameTextField.otherComponentClick();
inventoryTextField.otherComponentClick();
return;
}
profileDropdownSelected = false;
playerNameTextField.otherComponentClick();
inventoryTextField.otherComponentClick();
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
if (pages.containsKey(currentPage)) {
pages.get(currentPage).keyTyped(typedChar, keyCode);
}
if (playerNameTextField.getFocus()) {
if (keyCode == Keyboard.KEY_RETURN) {
currentPage = ProfileViewerPage.LOADING;
NotEnoughUpdates.profileViewer.getProfileByName(
playerNameTextField.getText(),
profile -> { //todo: invalid name
if (profile != null) profile.resetCache();
Minecraft.getMinecraft().displayGuiScreen(new GuiProfileViewer(profile));
}
);
}
playerNameTextField.keyTyped(typedChar, keyCode);
}
}
@Override
protected void mouseReleased(int mouseX, int mouseY, int mouseButton) {
super.mouseReleased(mouseX, mouseY, mouseButton);
if (pages.containsKey(currentPage)) {
pages.get(currentPage).mouseReleased(mouseX, mouseY, mouseButton);
}
}
public void renderXpBar(
String skillName,
ItemStack stack,
int x,
int y,
int xSize,
ProfileViewer.Level levelObj,
int mouseX,
int mouseY
) {
float level = levelObj.level;
int levelFloored = (int) Math.floor(level);
Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString() + levelFloored, x + 14, y - 4, xSize - 20);
if (levelObj.maxed) {
renderGoldBar(x, y + 6, xSize);
} else {
if (skillName.contains("Catacombs") && levelObj.level >= 50) {
renderGoldBar(x, y + 6, xSize);
} else {
renderBar(x, y + 6, xSize, level % 1);
}
}
if (mouseX > x && mouseX < x + 120) {
if (mouseY > y - 4 && mouseY < y + 13) {
String levelStr;
String totalXpStr = null;
if (skillName.contains("Catacombs")) totalXpStr =
EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE +
numberFormat.format(levelObj.totalXp);
if (levelObj.maxed) {
levelStr = EnumChatFormatting.GOLD + "MAXED!";
} else {
int maxXp = (int) levelObj.maxXpForLevel;
levelStr =
EnumChatFormatting.DARK_PURPLE +
StringUtils.shortNumberFormat(Math.round((level % 1) * maxXp)) +
"/" +
StringUtils.shortNumberFormat(maxXp);
}
if (totalXpStr != null) {
tooltipToDisplay = Utils.createList(levelStr, totalXpStr);
} else {
tooltipToDisplay = Utils.createList(levelStr);
}
}
}
NBTTagCompound nbt = new NBTTagCompound(); //Adding NBT Data for Custom Resource Packs
NBTTagCompound display = new NBTTagCompound();
display.setString("Name", skillName);
nbt.setTag("display", display);
stack.setTagCompound(nbt);
GL11.glTranslatef((x), (y - 6f), 0);
GL11.glScalef(0.7f, 0.7f, 1);
Utils.drawItemStackLinear(stack, 0, 0);
GL11.glScalef(1 / 0.7f, 1 / 0.7f, 1);
GL11.glTranslatef(-(x), -(y - 6f), 0);
}
public EntityOtherPlayerMP getEntityPlayer() {
return ((BasicPage) pages.get(ProfileViewerPage.BASIC)).entityPlayer;
}
public void renderGoldBar(float x, float y, float xSize) {
if (!OpenGlHelper.areShadersSupported()) {
renderBar(x, y, xSize, 1);
return;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
ShaderManager shaderManager = ShaderManager.getInstance();
shaderManager.loadShader("make_gold");
shaderManager.loadData("make_gold", "amount", (startTime - System.currentTimeMillis()) / 10000f);
Utils.drawTexturedRect(x, y, xSize / 2f, 5, 0 / 256f, (xSize / 2f) / 256f, 79 / 256f, 84 / 256f, GL11.GL_NEAREST);
Utils.drawTexturedRect(
x + xSize / 2f,
y,
xSize / 2f,
5,
(182 - xSize / 2f) / 256f,
182 / 256f,
79 / 256f,
84 / 256f,
GL11.GL_NEAREST
);
GL20.glUseProgram(0);
}
public void renderBar(float x, float y, float xSize, float completed) {
Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
completed = Math.round(completed / 0.05f) * 0.05f;
float notCompleted = 1 - completed;
GlStateManager.color(1, 1, 1, 1);
float width;
if (completed < 0.5f) {
width = (0.5f - completed) * xSize;
Utils.drawTexturedRect(
x + xSize * completed,
y,
width,
5,
xSize * completed / 256f,
(xSize / 2f) / 256f,
74 / 256f,
79 / 256f,
GL11.GL_NEAREST
);
}
if (completed < 1f) {
width = Math.min(xSize * notCompleted, xSize / 2f);
Utils.drawTexturedRect(
x + (xSize / 2f) + Math.max(xSize * (completed - 0.5f), 0),
y,
width,
5,
(182 - (xSize / 2f) + Math.max(xSize * (completed - 0.5f), 0)) / 256f,
182 / 256f,
74 / 256f,
79 / 256f,
GL11.GL_NEAREST
);
}
if (completed > 0f) {
width = Math.min(xSize * completed, xSize / 2f);
Utils.drawTexturedRect(x, y, width, 5, 0 / 256f, width / 256f, 79 / 256f, 84 / 256f, GL11.GL_NEAREST);
}
if (completed > 0.5f) {
width = Math.min(xSize * (completed - 0.5f), xSize / 2f);
Utils.drawTexturedRect(
x + (xSize / 2f),
y,
width,
5,
(182 - (xSize / 2f)) / 256f,
(182 - (xSize / 2f) + width) / 256f,
79 / 256f,
84 / 256f,
GL11.GL_NEAREST
);
}
}
public void resetCache() {
pages.values().forEach(GuiProfileViewerPage::resetCache);
}
/**
* Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
* space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
*
* This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
* apply scales and translations manually.
*/
private Matrix4f createProjectionMatrix(int width, int height) {
Matrix4f projMatrix = new Matrix4f();
projMatrix.setIdentity();
projMatrix.m00 = 2.0F / (float) width;
projMatrix.m11 = 2.0F / (float) (-height);
projMatrix.m22 = -0.0020001999F;
projMatrix.m33 = 1.0F;
projMatrix.m03 = -1.0F;
projMatrix.m13 = 1.0F;
projMatrix.m23 = -1.0001999F;
return projMatrix;
}
private void blurBackground() {
if (!OpenGlHelper.isFramebufferEnabled()) return;
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
if (blurOutputHorz == null) {
blurOutputHorz = new Framebuffer(width, height, false);
blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
}
if (blurOutputVert == null) {
blurOutputVert = new Framebuffer(width, height, false);
blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
}
if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
blurOutputHorz.createBindFramebuffer(width, height);
blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
if (blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
blurOutputVert.createBindFramebuffer(width, height);
blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
if (blurShaderHorz == null) {
try {
blurShaderHorz =
new Shader(
Minecraft.getMinecraft().getResourceManager(),
"blur",
Minecraft.getMinecraft().getFramebuffer(),
blurOutputHorz
);
blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
} catch (Exception ignored) {
}
}
if (blurShaderVert == null) {
try {
blurShaderVert = new Shader(
Minecraft.getMinecraft().getResourceManager(),
"blur",
blurOutputHorz,
blurOutputVert
);
blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
} catch (Exception ignored) {
}
}
if (blurShaderHorz != null && blurShaderVert != null) {
if (15 != lastBgBlurFactor) {
blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float) 15);
blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float) 15);
lastBgBlurFactor = 15;
}
GL11.glPushMatrix();
blurShaderHorz.loadShader(0);
blurShaderVert.loadShader(0);
GlStateManager.enableDepth();
GL11.glPopMatrix();
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
}
/**
* Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
* Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
*/
public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
if (!OpenGlHelper.isFramebufferEnabled()) return;
float uMin = x / (float) width;
float uMax = (x + blurWidth) / (float) width;
float vMin = (height - y) / (float) height;
float vMax = (height - y - blurHeight) / (float) height;
blurOutputVert.bindFramebufferTexture();
GlStateManager.color(1f, 1f, 1f, 1f);
//Utils.setScreen(width*f, height*f, f);
Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
//Utils.setScreen(width, height, f);
blurOutputVert.unbindFramebufferTexture();
}
public enum ProfileViewerPage {
LOADING(),
INVALID_NAME(),
NO_SKYBLOCK(),
BASIC(0, Items.paper, "§9Your Skills"),
DUNGEON(1, Item.getItemFromBlock(Blocks.deadbush), "§eDungeoneering"),
EXTRA(2, Items.book, "§7Profile Stats"),
INVENTORIES(3, Item.getItemFromBlock(Blocks.ender_chest), "§bStorage"),
COLLECTIONS(4, Items.painting, "§6Collections"),
PETS(5, Items.bone, "§aPets"),
MINING(6, Items.iron_pickaxe, "§5Heart of the Mountain"),
BINGO(7, Items.filled_map, "§zBingo"),
TROPHY_FISH(8, Items.fishing_rod, "§3Trophy Fish"),
BESTIARY(9, Items.iron_sword, "§cBestiary");
public final ItemStack stack;
public final int id;
ProfileViewerPage() {
this(-1, null, null);
}
ProfileViewerPage(int id, Item item, String name) {
this.id = id;
if (item == null) {
stack = null;
} else {
stack = new ItemStack(item);
NBTTagCompound nbt = new NBTTagCompound(); //Adding NBT Data for Custom Resource Packs
NBTTagCompound display = new NBTTagCompound();
display.setString("Name", name);
nbt.setTag("display", display);
stack.setTagCompound(nbt);
}
}
public static ProfileViewerPage getById(int id) {
for (ProfileViewerPage page : values()) {
if (page.id == id) {
return page;
}
}
return null;
}
public Optional getItem() {
return Optional.ofNullable(stack);
}
}
public static class PetLevel {
public float level;
public float maxLevel;
public float currentLevelRequirement;
public float maxXP;
public float levelPercentage;
public float levelXp;
public float totalXp;
}
}