package io.github.moulberry.notenoughupdates;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.util.TexLoc;
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.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiEditSign;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
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.ByteArrayInputStream;
import java.text.NumberFormat;
import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TradeWindow {
private static ResourceLocation location = new ResourceLocation("notenoughupdates", "custom_trade.png");
private static final int xSize = 176;
private static final int ySize = 204;
private static int guiLeft;
private static int guiTop;
private static long lastTradeMillis = -1;
private static final long CHANGE_EXCLAM_MILLIS = 5000;
private static Integer[] ourTradeIndexes = new Integer[16];
private static Integer[] theirTradeIndexes = new Integer[16];
private static String[] theirTradeOld = new String[16];
private static Long[] theirTradeChangesMillis = new Long[16];
private static ItemStack lastBackpack;
private static int lastBackpackX;
private static int lastBackpackY;
public static boolean tradeWindowActive() {
if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return false;
if(!NotEnoughUpdates.INSTANCE.manager.config.useCustomTrade.value) return false;
GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
if(guiScreen instanceof GuiChest) {
GuiChest eventGui = (GuiChest) guiScreen;
ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
if(containerName.trim().startsWith("You ")) {
return true;
}
}
lastTradeMillis = -1;
ourTradeIndexes = new Integer[16];
theirTradeIndexes = new Integer[16];
theirTradeOld = new String[16];
theirTradeChangesMillis = new Long[16];
return false;
}
private static TexLoc tl = new TexLoc(0, 0, Keyboard.KEY_M);
private static void drawStringShadow(String str, float x, float y, int len) {
for(int xOff=-2; xOff<=2; xOff++) {
for(int yOff=-2; yOff<=2; yOff++) {
if(Math.abs(xOff) != Math.abs(yOff)) {
Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(str),
Minecraft.getMinecraft().fontRendererObj,
x+xOff/2f, y+yOff/2f, false, len,
new Color(20, 20, 20, 100/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());