From ece0af65a8bba6c722ac6f0853c570d2e8cad784 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Mon, 4 Jan 2021 15:02:32 +0900 Subject: many things --- .../dungeonsguide/features/FeatureRegistry.java | 1 + .../features/impl/FeatureChestPrice.java | 101 +++++++++++++++++++++ .../features/impl/FeatureCooldownCounter.java | 2 +- .../features/impl/FeatureInstaCloseChest.java | 13 ++- .../features/impl/FeatureTooltipDungeonStat.java | 2 +- .../features/impl/FeatureTooltipPrice.java | 12 ++- .../listener/GuiBackgroundRenderListener.java | 7 ++ .../features/listener/GuiPreRenderListener.java | 7 ++ 8 files changed, 138 insertions(+), 7 deletions(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureChestPrice.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiBackgroundRenderListener.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPreRenderListener.java (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index c5b9daa1..6a66a13f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -54,4 +54,5 @@ public class FeatureRegistry { public static final FeatureInstaCloseChest DUNGEON_INSTACLOSE = register(new FeatureInstaCloseChest()); public static final FeatureBoxSkelemaster DUNGEON_BOXSKELEMASTER = register(new FeatureBoxSkelemaster()); public static final SimpleFeature FIX_SPIRIT_BOOTS = register(new SimpleFeature("fixes", "Spirit Boots Fixer", "Fix Spirit boots messing up with inventory", "fixes.spirit", true)); + public static final SimpleFeature BOSSFIGHT_CHESTPRICE = register(new FeatureChestPrice()); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureChestPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureChestPrice.java new file mode 100644 index 00000000..432f3169 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureChestPrice.java @@ -0,0 +1,101 @@ +package kr.syeyoung.dungeonsguide.features.impl; + +import kr.syeyoung.dungeonsguide.e; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.GuiBackgroundRenderListener; +import kr.syeyoung.dungeonsguide.features.listener.GuiPostRenderListener; +import kr.syeyoung.dungeonsguide.features.listener.GuiPreRenderListener; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.client.event.GuiScreenEvent; +import org.lwjgl.opengl.GL11; + +import java.util.HashMap; +import java.util.TreeMap; + +public class FeatureChestPrice extends SimpleFeature implements GuiBackgroundRenderListener { + public FeatureChestPrice() { + super("Bossfight", "Show Profit of Dungeon Chests","Show Profit of Dungeon Chests", "bossfight.profitchest", true); + } + + @Override + public void onGuiBGRender(GuiScreenEvent.BackgroundDrawnEvent rendered) { + if (!isEnabled()) return; + if (!(rendered.gui instanceof GuiChest)) return; + if (!e.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; + + GL11.glColor4f(1,1,1,1); + GlStateManager.disableLighting(); + + ContainerChest chest = (ContainerChest) ((GuiChest) rendered.gui).inventorySlots; + IInventory actualChest = chest.getLowerChestInventory(); + + int chestPrice = 0; + int itemPrice = 0; + for (int i = 0; i 0) { + for (int j1 = 0; j1 < nbttaglist1.tagCount(); ++j1) { + String str = nbttaglist1.getStringTagAt(j1); + if (str.endsWith("Coins")) { + String coins = TextUtils.stripColor(str).replace(" Coins", "").replace(",",""); + try { + chestPrice = Integer.parseInt(coins); + } catch (Exception e) { + + } + } + } + } + } + } + } + itemPrice += FeatureInstaCloseChest.getPrice(item) * item.stackSize; + } + } + + int i = 222; + int j = i - 108; + int ySize = j + (actualChest.getSizeInventory() / 9) * 18; + int left = (rendered.gui.width + 176) / 2; + int top = (rendered.gui.height - ySize ) / 2; + + int width = 120; + + GL11.glPushMatrix(); + GL11.glTranslated(left, top, 0); + Gui.drawRect( 0,0,width, 30, 0xFFDDDDDD); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("BIN/AH Price: ", 5,5, 0xFF000000); + String str = TextUtils.format(itemPrice); + fr.drawString(str, width - fr.getStringWidth(str) - 5, 5, 0xFF000000); + + fr.drawString("Profit: ", 5,15, 0xFF000000); + str = (itemPrice > chestPrice ? "+" : "") +TextUtils.format(itemPrice - chestPrice); + fr.drawString(str, width - fr.getStringWidth(str) - 5, 15, itemPrice > chestPrice ? 0xFF00CC00 : 0xFFCC0000); + + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java index 276dfe3f..17efd2e8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java @@ -13,7 +13,7 @@ import java.awt.*; public class FeatureCooldownCounter extends GuiFeature implements TickListener { public FeatureCooldownCounter() { - super("HUD", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, getFontRenderer().getStringWidth("Cooldown: 10s "), getFontRenderer().FONT_HEIGHT); + super("ETC", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, getFontRenderer().getStringWidth("Cooldown: 10s "), getFontRenderer().FONT_HEIGHT); parameters.put("color", new FeatureParameter("color", "Color", "Color of text", Color.white, "color")); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java index f8069d73..74c0cec3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java @@ -14,6 +14,7 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.client.event.GuiOpenEvent; @@ -21,6 +22,7 @@ import org.lwjgl.opengl.GL11; import java.awt.*; import java.util.Comparator; +import java.util.HashMap; import java.util.Set; import java.util.TreeSet; @@ -35,7 +37,6 @@ public class FeatureInstaCloseChest extends SimpleFeature implements GuiOpenList @Override public void onGuiOpen(GuiOpenEvent event) { if (!this.isEnabled()) return; - if (!skyblockStatus.isOnDungeon()) return; if (!(event.gui instanceof GuiChest)) return; @@ -46,7 +47,7 @@ public class FeatureInstaCloseChest extends SimpleFeature implements GuiOpenList check = true; } - public int getPrice(ItemStack itemStack) { + public static int getPrice(ItemStack itemStack) { if (itemStack == null) return 0; NBTTagCompound compound = itemStack.getTagCompound(); if (compound == null) @@ -104,9 +105,13 @@ public class FeatureInstaCloseChest extends SimpleFeature implements GuiOpenList GuiScreen screen = Minecraft.getMinecraft().currentScreen; if (screen instanceof GuiChest){ + + ContainerChest chest = (ContainerChest) ((GuiChest) screen).inventorySlots; + IInventory actualChest = chest.getLowerChestInventory(); + int priceSum = 0; - for (ItemStack inventoryItemStack : ((GuiChest) screen).inventorySlots.inventoryItemStacks) { - priceSum += getPrice(inventoryItemStack); + for (int i = 0; i < actualChest.getSizeInventory(); i++) { + priceSum += getPrice(actualChest.getStackInSlot(i)); } int threshold = this.getParameter("threshold").getValue(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java index 250d230d..a3f10c30 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java @@ -9,7 +9,7 @@ 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"); + super("ETC", "Dungeon Item Stats", "Shows quality of dungeon items (floor, percentage)", "tooltip.dungeonitem"); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipPrice.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipPrice.java index b9059427..68393ca2 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipPrice.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipPrice.java @@ -1,5 +1,6 @@ package kr.syeyoung.dungeonsguide.features.impl; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.SimpleFeature; import kr.syeyoung.dungeonsguide.features.listener.TooltipListener; @@ -8,6 +9,7 @@ import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import org.lwjgl.input.Keyboard; import java.util.Comparator; import java.util.Set; @@ -15,19 +17,27 @@ import java.util.TreeSet; public class FeatureTooltipPrice extends SimpleFeature implements TooltipListener { public FeatureTooltipPrice() { - super("tooltip", "Item Price", "Shows price of items", "tooltip.price"); + super("ETC", "Item Price", "Shows price of items", "tooltip.price"); + parameters.put("reqShift", new FeatureParameter("reqShift", "Require Shift", "If shift needs to be pressed in order for this feature to be activated", false, "boolean")); } @Override public void onTooltip(ItemTooltipEvent event) { if (!isEnabled()) return; + boolean activated = !this.getParameter("reqShift").getValue() || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + ItemStack hoveredItem = event.itemStack; NBTTagCompound compound = hoveredItem.getTagCompound(); if (compound == null) return; if (!compound.hasKey("ExtraAttributes")) return; + if (!activated) { + event.toolTip.add("ยง7Shift to view price"); + return; + } + final String id = compound.getCompoundTag("ExtraAttributes").getString("id"); if (id.equals("ENCHANTED_BOOK")) { final NBTTagCompound enchants = compound.getCompoundTag("ExtraAttributes").getCompoundTag("enchantments"); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiBackgroundRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiBackgroundRenderListener.java new file mode 100644 index 00000000..df1bbecf --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiBackgroundRenderListener.java @@ -0,0 +1,7 @@ +package kr.syeyoung.dungeonsguide.features.listener; + +import net.minecraftforge.client.event.GuiScreenEvent; + +public interface GuiBackgroundRenderListener { + void onGuiBGRender(GuiScreenEvent.BackgroundDrawnEvent rendered); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPreRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPreRenderListener.java new file mode 100644 index 00000000..6183b9f5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPreRenderListener.java @@ -0,0 +1,7 @@ +package kr.syeyoung.dungeonsguide.features.listener; + +import net.minecraftforge.client.event.GuiScreenEvent; + +public interface GuiPreRenderListener { + void onGuiPreRender(GuiScreenEvent.DrawScreenEvent.Pre rendered); +} -- cgit