package io.github.moulberry.notenoughupdates.miscgui;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.util.SBAIntegration;
import io.github.moulberry.notenoughupdates.util.TexLoc;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
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.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.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 hypixelTradeWindowActive(String containerName) {
return containerName != null && containerName.trim().startsWith("You ");
}
public static boolean tradeWindowActive(String containerName) {
if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return false;
if(!NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade) return false;
if(hypixelTradeWindowActive(containerName)) {
return true;
}
if(lastTradeMillis != -99) {
lastTradeMillis = -99;
ourTradeIndexes = new Integer[16];
theirTradeIndexes = new Integer[16];
theirTradeOld = new String[16];
theirTradeChangesMillis = new Long[16];
}
return false;
}
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());
}
}
}
Utils.drawStringCenteredScaledMaxWidth(str,
Minecraft.getMinecraft().fontRendererObj,
x, y, false, len,
new Color(64, 64, 64, 255).getRGB());