/*
* Copyright (C) 2022 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;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NEUOverlay;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.GlScissorStack;
import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.overlays.EquipmentOverlay;
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.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import static io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour.custom_ench_colour;
public class GuiInvButtonEditor extends GuiScreen {
private static final ResourceLocation INVENTORY = new ResourceLocation(
"minecraft:textures/gui/container/inventory.png");
private static final ResourceLocation EDITOR = new ResourceLocation("notenoughupdates:invbuttons/editor.png");
private static final ResourceLocation EXTRA_ICONS_JSON = new ResourceLocation(
"notenoughupdates:invbuttons/extraicons.json");
private static final ResourceLocation PRESETS_JSON = new ResourceLocation("notenoughupdates:invbuttons/presets.json");
private static final String sharePrefix = "NEUBUTTONS/";
private final int xSize = 176;
private final int ySize = 166;
private int guiLeft;
private int guiTop;
//region getGuiCoordinates
public int getGuiLeft() {
return this.guiLeft;
}
public int getGuiTop() {
return this.guiTop;
}
//endregion
private static final int BACKGROUND_TYPES = 5;
private static final int ICON_TYPES = 3;
private int iconTypeIndex = 0;
private final int editorXSize = 150;
private final int editorYSize = 204;
private int editorLeft;
private int editorTop;
private final GuiElementTextField commandTextField = new GuiElementTextField(
"",
editorXSize - 14,
16,
GuiElementTextField.SCALE_TEXT
);
private final GuiElementTextField iconTextField = new GuiElementTextField(
"",
editorXSize - 14,
16,
GuiElementTextField.SCALE_TEXT
);
private static final HashSet<String> prioritisedIcons = new HashSet<String>() {{
add("WORKBENCH");
add("LEATHER_CHESTPLATE");
add("CHEST");
add("BONE");
add("ENDER_CHEST");
add("GOLD_BARDING");
add("COMPASS");
add("GOLD_BLOCK");
add("EMPTY_MAP");
add("RAW_FISH");
add("FISHING_ROD");
add("EMERALD");
add("IRON_SWORD");
add("POTION");
add("NETHER_STAR");
add("PAINTING");
add("COMMAND");
add("BOOK");
}};
private static HashMap<String, String> extraIcons = null;
private static final HashMap<String, String> skullIcons = new HashMap<String, String>() {{
put("personal bank", "skull:e36e94f6c34a35465fce4a90f2e25976389eb9709a12273574ff70fd4daa6852");