From bd6f658c6c53d160c40bc3b5fdead7b7b3dd20c4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Jul 2020 00:53:17 +1000 Subject: 1.8 --- .../moulberry/notenoughupdates/CustomAH.java | 208 +++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/CustomAH.java (limited to 'src/main/java/io/github/moulberry/notenoughupdates/CustomAH.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomAH.java new file mode 100644 index 00000000..d74d0e5c --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomAH.java @@ -0,0 +1,208 @@ +package io.github.moulberry.notenoughupdates; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.util.TexLoc; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.item.Item; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Base64; +import java.util.HashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import static io.github.moulberry.notenoughupdates.GuiTextures.*; + +public class CustomAH extends GuiScreen { + + private static final ResourceLocation inventoryBackground = new ResourceLocation("textures/gui/container/inventory.png"); + private static final ResourceLocation creativeTabSearch = new ResourceLocation("textures/gui/container/creative_inventory/tab_item_search.png"); + private static final ResourceLocation creativeInventoryTabs = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); + + private int yScrollInitial = 0; + private boolean scrollClicked = false; + + + private int splits = 2; + + private int ySplit = 35; + private int ySplitSize = 18; + private int ySize = 136 + ySplitSize*splits; + private int xSize = 195; + + private float scrollAmount; + + private int guiLeft = 0; + private int guiTop = 0; + + private NEUManager manager; + private HashMap auctionItems = new HashMap<>(); + + private TexLoc tl = new TexLoc(0, 0, Keyboard.KEY_M); + + public CustomAH(NEUManager manager) { + this.manager = manager; + updateAuctions(); + } + + private void updateAuctions() { + HashMap pages = new HashMap<>(); + + HashMap args = new HashMap<>(); + args.put("page", "0"); + AtomicInteger totalPages = new AtomicInteger(1); + AtomicInteger currentPages = new AtomicInteger(0); + manager.hypixelApi.getHypixelApiAsync(manager.config.apiKey.value, "skyblock/profiles", + args, jsonObject -> { + if(jsonObject.get("success").getAsBoolean()) { + pages.put(0, jsonObject); + totalPages.set(jsonObject.get("totalPages").getAsInt()); + currentPages.incrementAndGet(); + + for(int i=1; i args2 = new HashMap<>(); + args2.put("page", ""+i); + manager.hypixelApi.getHypixelApiAsync(manager.config.apiKey.value, "skyblock/profiles", + args2, jsonObject2 -> { + if (jsonObject2.get("success").getAsBoolean()) { + pages.put(j, jsonObject2); + currentPages.incrementAndGet(); + } + } + ); + } + } + } + ); + + ScheduledExecutorService ses = Executors.newSingleThreadScheduledExecutor();//1593549115 () 1593631661919 + long startTime = System.currentTimeMillis(); + ses.schedule(new Runnable() { + public void run() { + if(System.currentTimeMillis() - startTime > 20000) return; + + if(currentPages.get() == totalPages.get()) { + auctionItems.clear(); + for(int pageNum : pages.keySet()) { + JsonObject page = pages.get(pageNum); + JsonArray auctions = page.get("auctions").getAsJsonArray(); + for(int i=0; i guiLeft+175 && mouseX < guiLeft+175+12) { + if(mouseY > y && mouseY < y+15) { + scrollClicked = true; + return; + } + } + scrollClicked = false; + } + + @Override + protected void mouseReleased(int mouseX, int mouseY, int state) { + scrollClicked = false; + } + + @Override + protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + if(scrollClicked) { + int yMin = guiTop+18 + 8; + int yMax = guiTop+18+(95+ySplitSize*2) + 8; + + scrollAmount = (mouseY-yMin)/(float)yMax; + scrollAmount = Math.max(0, Math.min(1, scrollAmount)); + } + } +} -- cgit