aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-03-27 02:47:30 +0900
committersyeyoung <cyong06@naver.com>2021-03-27 02:47:30 +0900
commitcef6bf93b82dd2ba53c646b0852d7caee8f8634c (patch)
treea639e2770cca210b9fcf320bd56191a153ebd48f /src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss
parent5608fb71917c12f065c1dd5ce319d08ec6850382 (diff)
downloadSkyblock-Dungeons-Guide-cef6bf93b82dd2ba53c646b0852d7caee8f8634c.tar.gz
Skyblock-Dungeons-Guide-cef6bf93b82dd2ba53c646b0852d7caee8f8634c.tar.bz2
Skyblock-Dungeons-Guide-cef6bf93b82dd2ba53c646b0852d7caee8f8634c.zip
bye bye insta close
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java58
1 files changed, 56 insertions, 2 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java
index 15e210c4..fdb7130b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java
@@ -2,8 +2,8 @@ package kr.syeyoung.dungeonsguide.features.impl.boss;
import kr.syeyoung.dungeonsguide.e;
import kr.syeyoung.dungeonsguide.features.SimpleFeature;
-import kr.syeyoung.dungeonsguide.features.impl.dungeon.FeatureInstaCloseChest;
import kr.syeyoung.dungeonsguide.features.listener.GuiBackgroundRenderListener;
+import kr.syeyoung.dungeonsguide.utils.AhUtils;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
@@ -18,6 +18,10 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.client.event.GuiScreenEvent;
+import java.util.Comparator;
+import java.util.Set;
+import java.util.TreeSet;
+
public class FeatureChestPrice extends SimpleFeature implements GuiBackgroundRenderListener {
public FeatureChestPrice() {
super("Bossfight", "Show Profit of Dungeon Chests","Show Profit of Dungeon Chests", "bossfight.profitchest", true);
@@ -64,7 +68,7 @@ public class FeatureChestPrice extends SimpleFeature implements GuiBackgroundRen
}
}
}
- itemPrice += FeatureInstaCloseChest.getPrice(item) * item.stackSize;
+ itemPrice += getPrice(item) * item.stackSize;
}
}
@@ -94,4 +98,54 @@ public class FeatureChestPrice extends SimpleFeature implements GuiBackgroundRen
GlStateManager.enableLighting();
GlStateManager.enableBlend();
}
+
+ public static long getPrice(ItemStack itemStack) {
+ if (itemStack == null) return 0;
+ NBTTagCompound compound = itemStack.getTagCompound();
+ if (compound == null)
+ return 0;
+ if (!compound.hasKey("ExtraAttributes"))
+ return 0;
+ final String id = compound.getCompoundTag("ExtraAttributes").getString("id");
+ if (id.equals("ENCHANTED_BOOK")) {
+ final NBTTagCompound enchants = compound.getCompoundTag("ExtraAttributes").getCompoundTag("enchantments");
+ Set<String> keys = enchants.getKeySet();
+ Set<String> actualKeys = new TreeSet<String>(new Comparator<String>() {
+ public int compare(String o1, String o2) {
+ String id2 = id + "::" + o1 + "-" + enchants.getInteger(o1);
+ AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2);
+ long price1 = (auctionData == null) ? 0 : auctionData.lowestBin;
+ String id3 = id + "::" + o2 + "-" + enchants.getInteger(o2);
+ AhUtils.AuctionData auctionData2 = AhUtils.auctions.get(id3);
+ long price2 = (auctionData2 == null) ? 0 : auctionData2.lowestBin;
+ return (compare2(price1, price2) == 0) ? o1.compareTo(o2) : compare2(price1, price2);
+ }
+
+ public int compare2(long y, long x) {
+ return (x < y) ? -1 : ((x == y) ? 0 : 1);
+ }
+ });
+ actualKeys.addAll(keys);
+ int totalLowestPrice = 0;
+ for (String key : actualKeys) {
+ String id2 = id + "::" + key + "-" + enchants.getInteger(key);
+ AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2);
+ totalLowestPrice += auctionData.lowestBin;
+ }
+ return totalLowestPrice;
+ } else {
+ AhUtils.AuctionData auctionData = AhUtils.auctions.get(id);
+ if (auctionData == null) {
+ return 0;
+ } else {
+ if (auctionData.sellPrice == -1 && auctionData.lowestBin != -1) return auctionData.lowestBin;
+ else if (auctionData.sellPrice != -1 && auctionData.lowestBin == -1) return auctionData.sellPrice;
+ else {
+ long ahPrice = auctionData.lowestBin;
+ if (ahPrice > auctionData.sellPrice) return ahPrice;
+ else return auctionData.sellPrice;
+ }
+ }
+ }
+ }
}