aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java34
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java9
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/features/FeatureCooldownCounter.java)5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipDungeonStat.java35
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureTooltipPrice.java87
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java7
7 files changed, 156 insertions, 22 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java
index 2e2105b6..2facddbe 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java
@@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import kr.syeyoung.dungeonsguide.config.types.TypeConverter;
import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry;
+import kr.syeyoung.dungeonsguide.features.FeatureParameter;
import lombok.Getter;
import lombok.Setter;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
index c92e09a1..d04ed884 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java
@@ -1,5 +1,8 @@
package kr.syeyoung.dungeonsguide.features;
+import kr.syeyoung.dungeonsguide.features.impl.FeatureCooldownCounter;
+import kr.syeyoung.dungeonsguide.features.impl.FeatureTooltipDungeonStat;
+import kr.syeyoung.dungeonsguide.features.impl.FeatureTooltipPrice;
import lombok.Getter;
import java.util.ArrayList;
@@ -18,7 +21,7 @@ public class FeatureRegistry {
return featureByKey.get(key);
}
- public static AbstractFeature register(AbstractFeature abstractFeature) {
+ public static <T extends AbstractFeature> T register(T abstractFeature) {
featureList.add(abstractFeature);
featureByKey.put(abstractFeature.getKey(), abstractFeature);
List<AbstractFeature> features = featuresByCategory.get(abstractFeature.getCategory());
@@ -30,23 +33,24 @@ public class FeatureRegistry {
return abstractFeature;
}
- public static final AbstractFeature SOLVER_RIDDLE = register(new SimpleFeature("solver", "Riddle Puzzle (3 weirdo) Solver", "Highlights the correct box after clicking on all 3 weirdos", "solver.riddle"));
- public static final AbstractFeature SOLVER_KAHOOT = register(new SimpleFeature("solver", "Trivia Puzzle (Omnicrescent) Solver", "Highlights the correct solution for trivia puzzle", "solver.trivia"));
- public static final AbstractFeature SOLVER_BLAZE = register(new SimpleFeature("solver", "Blaze Puzzle Solver", "Highlights the blaze that needs to be killed in an blaze room", "solver.blaze"));
- public static final AbstractFeature SOLVER_TICTACTOE = register(new SimpleFeature("solver", "Tictactoe Solver", "Shows the best move that could be taken by player in the tictactoe room", "solver.tictactoe"));
- public static final AbstractFeature SOLVER_ICEPATH = register(new SimpleFeature("solver", "Icepath Puzzle Solver (Advanced)", "Calculates solution for icepath puzzle and displays it to user", "solver.icepath"));
- public static final AbstractFeature SOLVER_SILVERFISH = register(new SimpleFeature("solver", "Silverfish Puzzle Solver (Advanced)", "Actively calculates solution for silverfish puzzle and displays it to user", "solver.silverfish"));
- public static final AbstractFeature SOLVER_WATERPUZZLE = register(new SimpleFeature("solver", "Waterboard Puzzle Solver (Advanced)", "Calculates solution for waterboard puzzle and displays it to user", "solver.waterboard"));
- public static final AbstractFeature SOLVER_BOX = register(new SimpleFeature("solver", "Box Puzzle Solver (Advanced)", "Calculates solution for box puzzle room, and displays it to user", "solver.box"));
- public static final AbstractFeature SOLVER_CREEPER = register(new SimpleFeature("solver", "Creeper Puzzle Solver", "Draws line between prismarine lamps in creeper room", "solver.creeper"));
- public static final AbstractFeature SOLVER_TELEPORT = register(new SimpleFeature("solver", "Teleport Puzzle Solver", "Shows teleport pads you've visited in a teleport maze room", "solver.teleport"));
+ public static final SimpleFeature SOLVER_RIDDLE = register(new SimpleFeature("solver", "Riddle Puzzle (3 weirdo) Solver", "Highlights the correct box after clicking on all 3 weirdos", "solver.riddle"));
+ public static final SimpleFeature SOLVER_KAHOOT = register(new SimpleFeature("solver", "Trivia Puzzle (Omnicrescent) Solver", "Highlights the correct solution for trivia puzzle", "solver.trivia"));
+ public static final SimpleFeature SOLVER_BLAZE = register(new SimpleFeature("solver", "Blaze Puzzle Solver", "Highlights the blaze that needs to be killed in an blaze room", "solver.blaze"));
+ public static final SimpleFeature SOLVER_TICTACTOE = register(new SimpleFeature("solver", "Tictactoe Solver", "Shows the best move that could be taken by player in the tictactoe room", "solver.tictactoe"));
+ public static final SimpleFeature SOLVER_ICEPATH = register(new SimpleFeature("solver", "Icepath Puzzle Solver (Advanced)", "Calculates solution for icepath puzzle and displays it to user", "solver.icepath"));
+ public static final SimpleFeature SOLVER_SILVERFISH = register(new SimpleFeature("solver", "Silverfish Puzzle Solver (Advanced)", "Actively calculates solution for silverfish puzzle and displays it to user", "solver.silverfish"));
+ public static final SimpleFeature SOLVER_WATERPUZZLE = register(new SimpleFeature("solver", "Waterboard Puzzle Solver (Advanced)", "Calculates solution for waterboard puzzle and displays it to user", "solver.waterboard"));
+ public static final SimpleFeature SOLVER_BOX = register(new SimpleFeature("solver", "Box Puzzle Solver (Advanced)", "Calculates solution for box puzzle room, and displays it to user", "solver.box"));
+ public static final SimpleFeature SOLVER_CREEPER = register(new SimpleFeature("solver", "Creeper Puzzle Solver", "Draws line between prismarine lamps in creeper room", "solver.creeper"));
+ public static final SimpleFeature SOLVER_TELEPORT = register(new SimpleFeature("solver", "Teleport Puzzle Solver", "Shows teleport pads you've visited in a teleport maze room", "solver.teleport"));
- public static final AbstractFeature TOOLTIP_DUNGEONSTAT = register(new SimpleFeature("tooltip", "Dungeon Item Stats", "Shows quality of dungeon items (floor, percentage)", "tooltip.dungeonitem"));
- public static final AbstractFeature TOOLTIP_PRICE = register(new SimpleFeature("tooltip", "Item Price", "Shows price of items", "tooltip.price"));
+ public static final FeatureTooltipDungeonStat TOOLTIP_DUNGEONSTAT = register(new FeatureTooltipDungeonStat());
+ public static final FeatureTooltipPrice TOOLTIP_PRICE = register(new FeatureTooltipPrice());
- public static final AbstractFeature ADVANCED_ROOMEDIT = register(new SimpleFeature("advanced", "Room Edit", "Allow editing dungeon rooms\n\nWarning: using this feature can break or freeze your Minecraft\nThis is only for advanced users only", "advanced.roomedit", false));
+ public static final SimpleFeature ADVANCED_ROOMEDIT = register(new SimpleFeature("advanced", "Room Edit", "Allow editing dungeon rooms\n\nWarning: using this feature can break or freeze your Minecraft\nThis is only for advanced users only", "advanced.roomedit", false));
- public static final AbstractFeature DEBUG = register(new SimpleFeature("hidden", "Debug", "Toggles debug mode", "debug", false));
+ public static final SimpleFeature DEBUG = register(new SimpleFeature("hidden", "Debug", "Toggles debug mode", "debug", false));
+ public static final FeatureCooldownCounter QOL_COOLDOWN = (FeatureCooldownCounter) register(new FeatureCooldownCounter());
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java
index d47b6c34..98f8af15 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java
@@ -37,14 +37,13 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender
@Override
public void drawScreen(float partialTicks) {
if (!isEnabled()) return;
-
+ GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
clip(new ScaledResolution(Minecraft.getMinecraft()), featureRect.x, featureRect.y, featureRect.width, featureRect.height);
- GL11.glPushAttrib(GL11.GL_SCISSOR_BIT);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
- GL11.glEnable(GL11.GL_BLEND);
- OpenGlHelper.glBlendFunc(770, 771, 1, 0);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+// GL11.glEnable(GL11.GL_BLEND);
+// OpenGlHelper.glBlendFunc(770, 771, 1, 0);
+// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glPushMatrix();
GL11.glTranslated(featureRect.x, featureRect.y, 0);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java
index e5e0b1b6..dc2b7dd8 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureCooldownCounter.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java
@@ -1,11 +1,12 @@
-package kr.syeyoung.dungeonsguide.features;
+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 {
- protected FeatureCooldownCounter() {
+ public FeatureCooldownCounter() {
super("QoL", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, 100, 50);
}
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))));
+ }
+ }
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java
new file mode 100644
index 00000000..df1cf7ae
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TooltipListener.java
@@ -0,0 +1,7 @@
+package kr.syeyoung.dungeonsguide.features.listener;
+
+import net.minecraftforge.event.entity.player.ItemTooltipEvent;
+
+public interface TooltipListener {
+ void onTooltip(ItemTooltipEvent event);
+}