1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/*
* Copyright (C) 2023 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
* NotEnoughUpdates is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* NotEnoughUpdates is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
*/
package io.github.moulberry.notenoughupdates.profileviewer.level;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.profileviewer.BasicPage;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewerPage;
import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.CoreTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.DungeonTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.EssenceTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.EventTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.GuiTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.MiscTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.SkillRelatedTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.SlayingTaskLevel;
import io.github.moulberry.notenoughupdates.profileviewer.level.task.StoryTaskLevel;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class LevelPage extends GuiProfileViewerPage {
private static final ResourceLocation pv_levels = new ResourceLocation("notenoughupdates:pv_levels.png");
private final BasicPage basicPage;
private final JsonObject constant;
private final List<GuiTaskLevel> tasks = new ArrayList<>();
public LevelPage(GuiProfileViewer instance, BasicPage basicPage) {
super(instance);
this.basicPage = basicPage;
constant = Constants.SBLEVELS;
tasks.add(new CoreTaskLevel(this));
tasks.add(new DungeonTaskLevel(this));
tasks.add(new EssenceTaskLevel(this));
tasks.add(new MiscTaskLevel(this));
tasks.add(new SkillRelatedTaskLevel(this));
tasks.add(new SlayingTaskLevel(this));
tasks.add(new StoryTaskLevel(this));
tasks.add(new EventTaskLevel(this));
}
public void drawPage(int mouseX, int mouseY, float partialTicks) {
int guiLeft = GuiProfileViewer.getGuiLeft();
int guiTop = GuiProfileViewer.getGuiTop();
basicPage.drawSideButtons(mouseX, mouseY);
if (constant == null) {
Utils.showOutdatedRepoNotification("sblevels.json");
return;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_levels);
Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST);
SkyblockProfiles.SkyblockProfile selectedProfile = getSelectedProfile();
if (selectedProfile == null) {
return;
}
double skyblockLevel = selectedProfile.getSkyblockLevel();
JsonObject profileInfo = selectedProfile.getProfileJson();
drawMainBar(skyblockLevel, mouseX, mouseY, guiLeft, guiTop);
tasks.forEach(task -> task.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop));
}
public void renderLevelBar(
String name,
ItemStack stack,
int x,
int y,
int xSize,
double level,
double xp,
double max,
int mouseX,
int mouseY,
boolean percentage,
List<String> tooltip
) {
if (xp < 0) xp = 0;
double experienceRequired = (xp / max);
String second = EnumChatFormatting.WHITE.toString() + (int) level;
if (percentage) {
second = EnumChatFormatting.WHITE.toString() + (int) (experienceRequired * 100) + "%";
}
Utils.renderAlignedString(
EnumChatFormatting.RED + name,
second,
x + 14,
y - 4,
xSize - 20
);
if (xp >= max) {
getInstance().renderGoldBar(x, y + 6, xSize);
} else {
getInstance().renderBar(x, y + 6, xSize, (float) experienceRequired);
}
String levelStr;
if (mouseX > x && mouseX < x + 120) {
if (mouseY > y - 4 && mouseY < y + 13) {
String xpFormatted = StringUtils.formatNumber((int) xp);
String maxFormatted = StringUtils.formatNumber((int) max);
levelStr =
EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.DARK_PURPLE + (int) (experienceRequired * 100) +
"%" +
" §8(" + xpFormatted + "/" + maxFormatted + " XP)";
if (tooltip != null && !tooltip.isEmpty()) {
tooltip.add("");
tooltip.add(levelStr);
getInstance().tooltipToDisplay = tooltip;
} else {
getInstance().tooltipToDisplay = Utils.createList(levelStr);
}
}
}
GlStateManager.enableDepth();
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);
GlStateManager.disableDepth();
}
private void drawMainBar(double skyblockLevel, int mouseX, int mouseY, int guiLeft, int guiTop) {
renderLevelBar(
"Level",
BasicPage.skull,
guiLeft + 163, guiTop + 30,
110,
skyblockLevel,
Math.round((skyblockLevel - (long) skyblockLevel) * 100),
100,
mouseX, mouseY,
false,
Collections.emptyList()
);
}
public String buildLore(String name, double xpGotten, double xpGainful, boolean hasNoLimit) {
String xpGottenFormatted = StringUtils.formatNumber((int) xpGotten);
String xpGainfulFormatted = StringUtils.formatNumber((int) xpGainful);
if (xpGainful == 0 && xpGotten == 0 && !hasNoLimit) {
return EnumChatFormatting.GOLD + name + ": §c§lNOT DETECTABLE!";
}
if (hasNoLimit) {
return EnumChatFormatting.GOLD + name + ": " + EnumChatFormatting.YELLOW + xpGottenFormatted + " XP";
}
int percentage = (int) ((xpGotten / xpGainful) * 100);
if (xpGotten >= xpGainful) {
return EnumChatFormatting.GOLD + name + ": " + EnumChatFormatting.GREEN
+ percentage + "%" + " §8(" + xpGottenFormatted + "/" + xpGainfulFormatted + " XP)";
} else if (xpGotten == -1) {
return EnumChatFormatting.GOLD + name + ": §c§lCOLLECTION DISABLED!";
} else {
return EnumChatFormatting.GOLD + name + ": " + EnumChatFormatting.YELLOW
+ percentage + "%" + " §8(" + xpGottenFormatted + "/" + xpGainfulFormatted + " XP)";
}
}
public JsonObject getConstant() {
return constant;
}
}
|