/*
* Copyright (C) 2022-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.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.GlScissorStack;
import io.github.moulberry.notenoughupdates.core.GuiElement;
import io.github.moulberry.notenoughupdates.core.GuiElementBoolean;
import io.github.moulberry.notenoughupdates.core.GuiElementColour;
import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingFloat;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.GuiTextures;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
public class GuiItemCustomize extends GuiScreen {
private static final ResourceLocation PLUS = new ResourceLocation("notenoughupdates:itemcustomize/plus.png");
private final ItemStack stack;
ItemStack customItemStack;
private final String itemUUID;
private final GuiElementTextField textFieldRename = new GuiElementTextField("", 138, 20, GuiElementTextField.COLOUR);
final GuiElementTextField textFieldCustomItem = new GuiElementTextField("", 180, 20, GuiElementTextField.COLOUR);
final GuiElementTextField textFieldTickSpeed = new GuiElementTextField("", 180, 45, GuiElementTextField.COLOUR | GuiElementTextField.NUM_ONLY);
private final GuiElementBoolean enchantGlintButton;
private int renderHeight = 0;
private final LerpingFloat enchantGlintCustomColourAnimation = new LerpingFloat(0, 200);
private boolean enchantGlint;
String customGlintColour = null;
String customLeatherColour = null;
ArrayList<String> animatedLeatherColours = new ArrayList<>();
int animatedDyeTicks = 2;
DyeMode dyeMode = DyeMode.CYCLING;
private int lastTicks = 2;
boolean supportCustomLeatherColour;
private String lastCustomItem = "";
JsonObject animatedDyes = null;
JsonObject staticDyes = null;
JsonObject vanillaDyes = null;
ArrayList<DyeType> dyes = new ArrayList<>();
boolean repoError = false;
private GuiElement editor = null;
private GuiType guiType = GuiType.DEFAULT;
public GuiItemCustomize(ItemStack stack, String itemUUID) {
this.stack = stack;
this.itemUUID = itemUUID;
this.customItemStack = ItemCustomizationUtils.copy(stack, this);
IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
boolean stackHasEffect = stack.hasEffect() && !model.isBuiltInRenderer();
ItemCustomizeManager.ItemData data = ItemCustomizeManager