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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
/*
* Copyright (C) 2024 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.miscgui.itemcustomization;
import com.google.common.collect.Lists;
import io.github.moulberry.notenoughupdates.core.ChromaColour;
import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List;
import static io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour.custom_ench_colour;
public class ItemCustomizationUtils {
public static List<String> customizeColourGuide = Lists.newArrayList(
EnumChatFormatting.AQUA + "Set a custom name for the item",
EnumChatFormatting.GREEN + "",
EnumChatFormatting.GREEN + "Type \"&&\" for ¶",
EnumChatFormatting.GREEN + "Type \"**\" for ✪",
EnumChatFormatting.GREEN + "Type \"*1-9\" for ➊-➒",
EnumChatFormatting.GREEN + "",
EnumChatFormatting.GREEN + "Available colour codes:",
Utils.chromaString("¶z = Chroma"),
EnumChatFormatting.DARK_BLUE + "¶1 = Dark Blue",
EnumChatFormatting.DARK_GREEN + "¶2 = Dark Green",
EnumChatFormatting.DARK_AQUA + "¶3 = Dark Aqua",
EnumChatFormatting.DARK_RED + "¶4 = Dark Red",
EnumChatFormatting.DARK_PURPLE + "¶5 = Dark Purple",
EnumChatFormatting.GOLD + "¶6 = Gold",
EnumChatFormatting.GRAY + "¶7 = Gray",
EnumChatFormatting.DARK_GRAY + "¶8 = Dark Gray",
EnumChatFormatting.BLUE + "¶9 = Blue",
EnumChatFormatting.GREEN + "¶a = Green",
EnumChatFormatting.AQUA + "¶b = Aqua",
EnumChatFormatting.RED + "¶c = Red",
EnumChatFormatting.LIGHT_PURPLE + "¶d = Purple",
EnumChatFormatting.YELLOW + "¶e = Yellow",
EnumChatFormatting.WHITE + "¶f = White",
"§Z¶Z = SBA Chroma" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " (Requires SBA)",
"",
EnumChatFormatting.GREEN + "Available formatting codes:",
EnumChatFormatting.GRAY + "¶k = " + EnumChatFormatting.OBFUSCATED + "Obfuscated",
EnumChatFormatting.GRAY + "¶l = " + EnumChatFormatting.BOLD + "Bold",
EnumChatFormatting.GRAY + "¶m = " + EnumChatFormatting.STRIKETHROUGH + "Strikethrough",
EnumChatFormatting.GRAY + "¶n = " + EnumChatFormatting.UNDERLINE + "Underline",
EnumChatFormatting.GRAY + "¶o = " + EnumChatFormatting.ITALIC + "Italic"
);
public static List<String> resetGuide = Lists.newArrayList(
EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "This will reset all customisations!!",
EnumChatFormatting.GREEN + "",
EnumChatFormatting.RED + "Only click if you are sure you want to reset everything for this item"
);
public static List<String> speedGuide = Lists.newArrayList(
EnumChatFormatting.AQUA + "This is how fast the dyes will cycle, in ticks",
EnumChatFormatting.GRAY + "§6Hypixel §7dyes cycle every 2 ticks",
EnumChatFormatting.GRAY + "",
EnumChatFormatting.GRAY + "In the §dgradient mode §7this decides the amount of intermediary colours",
EnumChatFormatting.GRAY + "This means if speed is set to 1 it's the same as §aCycling mode"
);
public static ItemStack copy(ItemStack stack, GuiItemCustomize instance) {
ItemStack customStack = stack.copy();
if (!instance.textFieldCustomItem.getText().isEmpty()) {
customStack.setItem(ItemCustomizeManager.getCustomItem(stack, instance.textFieldCustomItem.getText().trim()));
customStack.setItemDamage(ItemCustomizeManager.getCustomItemDamage(stack));
NBTTagCompound tagCompound = customStack.getTagCompound();
if (tagCompound != null) {
NBTTagCompound customSkull = ItemCustomizeManager.getCustomSkull(customStack);
if (customSkull != null) {
tagCompound.removeTag("SkullOwner");
tagCompound.setTag("SkullOwner", customSkull);
}
}
}
return customStack;
}
public static int getGlintColour(GuiItemCustomize instance) {
int col = instance.customGlintColour == null
? ChromaColour.specialToChromaRGB(ItemCustomizeManager.DEFAULT_GLINT_COLOR)
: ChromaColour.specialToChromaRGB(instance.customGlintColour);
return 0xff000000 | col;
}
public static int getLeatherColour(GuiItemCustomize instance) {
if (!instance.supportCustomLeatherColour) return 0xff000000;
String customLeatherColour = instance.customLeatherColour;
int col = customLeatherColour == null
? ((ItemArmor) instance.customItemStack.getItem()).getColor(instance.customItemStack)
: ChromaColour.specialToChromaRGB(customLeatherColour);
return 0xff000000 | col;
}
public static int getLeatherColour(String colourString) {
return 0xff000000 | ChromaColour.specialToChromaRGB(colourString);
}
public static String getChromaStrFromLeatherColour(GuiItemCustomize instance) {
ItemStack customItemStack = instance.customItemStack;
return ChromaColour.special(0, 0xff, ((ItemArmor) customItemStack.getItem()).getColor(customItemStack));
}
public static void renderFooter(int xCenter, int yTop, GuiType guiType) {
int xCentreLeft = xCenter - 90;
int xCentreRight = xCenter;
Gui.drawRect(xCentreLeft, yTop, xCenter + 1, yTop + 17, 0xff101016);
Gui.drawRect(xCentreLeft, yTop, xCenter - 1, yTop + 15, 0xff101016);
Gui.drawRect(xCentreLeft - 1, yTop + 1, xCenter - 2, yTop + 14, 0xff000000 | 0xff00ffc4);
Utils.renderShadowedString(getButtons(guiType, 0).getDisplay(),
xCentreLeft + 44,
yTop + 4,
xCenter * 2 - xCentreRight
);
xCentreLeft += 90;
xCentreRight += 90;
Gui.drawRect(xCentreLeft, yTop, xCentreRight, yTop + 17, 0x70000000);
Gui.drawRect(xCentreLeft, yTop, xCentreRight, yTop + 15, 0xff101016);
Gui.drawRect(xCentreLeft - 1, yTop + 1, xCentreRight, yTop + 14, 0xff000000 | 0xff00ffc4 * 2);
Utils.renderShadowedString(getButtons(guiType, 1).getDisplay(),
xCentreLeft + 45,
yTop + 4,
xCenter * 2 - xCentreRight
);
}
public static GuiType getButtons(GuiType guiType, int button) {
if (button == 0) {
if (guiType == GuiType.DEFAULT) {
return GuiType.ANIMATED;
} else {
return GuiType.DEFAULT;
}
}
if (button == 1) {
if (guiType == GuiType.HYPIXEL) {
return GuiType.ANIMATED;
} else {
return GuiType.HYPIXEL;
}
}
return GuiType.DEFAULT;
}
public static GuiType getButtonClicked(int mouseX, int mouseY, GuiType guiType, float offset) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int xCenter = scaledResolution.getScaledWidth() / 2;
int xCentreLeft = xCenter - 90;
int xCentreRight = xCenter;
for (int i = 0; i < 2; i++
|