diff options
author | syeyoung <cyong06@naver.com> | 2021-01-01 14:24:06 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-01 14:24:06 +0900 |
commit | be44a7665e4982934998020d3bb930be25a50c25 (patch) | |
tree | 62a8ba38bf5dccf98eec1876f1d3267bf161bca0 /src/main/java/kr/syeyoung/dungeonsguide/features/impl | |
parent | a09e7553a93a177df7a6a3c7db5a1383b08a2416 (diff) | |
download | Skyblock-Dungeons-Guide-be44a7665e4982934998020d3bb930be25a50c25.tar.gz Skyblock-Dungeons-Guide-be44a7665e4982934998020d3bb930be25a50c25.tar.bz2 Skyblock-Dungeons-Guide-be44a7665e4982934998020d3bb930be25a50c25.zip |
gui glitch fix and such
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features/impl')
3 files changed, 150 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java new file mode 100644 index 00000000..dc2b7dd8 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java @@ -0,0 +1,28 @@ +package kr.syeyoung.dungeonsguide.features.impl; + +import kr.syeyoung.dungeonsguide.features.GuiFeature; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import org.lwjgl.opengl.GL11; + +public class FeatureCooldownCounter extends GuiFeature { + public FeatureCooldownCounter() { + super("QoL", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, 100, 50); + } + + @Override + public void drawHUD(float partialTicks) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; + GL11.glScaled(scale, scale, 0); + fr.drawString("Cooldown: 1s", 0,0,0xFFFFFFFF); + } + + @Override + public void drawDemo(float partialTicks) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; + GL11.glScaled(scale, scale, 0); + fr.drawString("Cooldown: 1s", 0,0,0xFFFFFFFF); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java new file mode 100644 index 00000000..250d230d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java @@ -0,0 +1,35 @@ +package kr.syeyoung.dungeonsguide.features.impl; + +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.TooltipListener; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +public class FeatureTooltipDungeonStat extends SimpleFeature implements TooltipListener { + public FeatureTooltipDungeonStat() { + super("tooltip", "Dungeon Item Stats", "Shows quality of dungeon items (floor, percentage)", "tooltip.dungeonitem"); + } + + @Override + public void onTooltip(ItemTooltipEvent event) { + if (!isEnabled()) return; + + ItemStack hoveredItem = event.itemStack; + NBTTagCompound compound = hoveredItem.getTagCompound(); + if (compound == null) + return; + if (!compound.hasKey("ExtraAttributes")) + return; + NBTTagCompound nbtTagCompound = compound.getCompoundTag("ExtraAttributes"); + + int floor = nbtTagCompound.getInteger("item_tier"); + int percentage = nbtTagCompound.getInteger("baseStatBoostPercentage"); + + if (nbtTagCompound.hasKey("item_tier")) + event.toolTip.add("§7Obtained in: §c"+(floor == 0 ? "Entrance" : "Floor "+floor)); + if (nbtTagCompound.hasKey("baseStatBoostPercentage")) + event.toolTip.add("§7Stat Percentage: §"+(percentage == 50 ? "6§l":"c")+(percentage * 2)+"%"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipPrice.java new file mode 100644 index 00000000..b54fa682 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipPrice.java @@ -0,0 +1,87 @@ +package kr.syeyoung.dungeonsguide.features.impl; + +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.TooltipListener; +import kr.syeyoung.dungeonsguide.utils.AhUtils; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +import java.util.Comparator; +import java.util.Set; +import java.util.TreeSet; + +public class FeatureTooltipPrice extends SimpleFeature implements TooltipListener { + public FeatureTooltipPrice() { + super("tooltip", "Item Price", "Shows price of items", "tooltip.price"); + } + + @Override + public void onTooltip(ItemTooltipEvent event) { + if (!isEnabled()) return; + + ItemStack hoveredItem = event.itemStack; + NBTTagCompound compound = hoveredItem.getTagCompound(); + if (compound == null) + return; + if (!compound.hasKey("ExtraAttributes")) + return; + 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); + int price1 = (auctionData == null) ? 0 : ((Integer)auctionData.prices.first()).intValue(); + String id3 = id + "::" + o2 + "-" + enchants.getInteger(o2); + AhUtils.AuctionData auctionData2 = AhUtils.auctions.get(id3); + int price2 = (auctionData2 == null) ? 0 : ((Integer)auctionData2.prices.first()).intValue(); + return (compare2(price1, price2) == 0) ? o1.compareTo(o2) : compare2(price1, price2); + } + + public int compare2(int y, int x) { + return (x < y) ? -1 : ((x == y) ? 0 : 1); + } + }); + actualKeys.addAll(keys); + int totalLowestPrice = 0; + int totalHighestPrice = 0; + int iterations = 0; + for (String key : actualKeys) { + iterations++; + String id2 = id + "::" + key + "-" + enchants.getInteger(key); + AhUtils.AuctionData auctionData = AhUtils.auctions.get(id2); + if (auctionData == null) { + if (iterations < 10) + event.toolTip.add("§f"+ key + " " + enchants.getInteger(key) + "§7: §cn/a"); + continue; + } + if (iterations < 10) + event.toolTip.add("§f"+ key + " " + enchants.getInteger(key) + "§7: §e"+ TextUtils.format((Integer) auctionData.prices.first()) + " §7to§e "+ TextUtils.format(auctionData.prices.last())); + totalLowestPrice += auctionData.prices.first(); + totalHighestPrice += auctionData.prices.last(); + } + if (iterations >= 10) + event.toolTip.add("§7"+ (iterations - 10) + " more enchants... "); + event.toolTip.add("§fTotal§7 §e:"+ TextUtils.format(totalLowestPrice) + " §7to§e "+ TextUtils.format(totalHighestPrice)); + } else { + AhUtils.AuctionData auctionData = AhUtils.auctions.get(id); + event.toolTip.add(""); + if (auctionData == null) { + event.toolTip.add("§fLowest ah §7: §cn/a"); + event.toolTip.add("§fHighest ah §7: §cn/a"); + event.toolTip.add("§fBazaar sell price §7: §cn/a"); + event.toolTip.add("§fBazaar buy price §7: §cn/a"); + } else { + event.toolTip.add("§fLowest ah §7: " + ((auctionData.prices.size() != 0) ? ("§e"+ TextUtils.format(auctionData.prices.first().intValue())) : "§cn/a")); + event.toolTip.add("§fHighest ah §7: " + ((auctionData.prices.size() != 0) ? ("§e"+ TextUtils.format((auctionData.prices.last()).intValue())) : "§cn/a")); + event.toolTip.add("§fBazaar sell price §7: " + ((auctionData.sellPrice == -1) ? "§cn/a": ("§e"+ TextUtils.format(auctionData.sellPrice)))); + event.toolTip.add("§fBazaar buy price §7: " + ((auctionData.buyPrice == -1) ? "§cn/a": ("§e"+ TextUtils.format(auctionData.buyPrice)))); + } + } + } +} |