aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoKM <54663875+DoKM@users.noreply.github.com>2021-08-26 20:11:21 +0200
committerGitHub <noreply@github.com>2021-08-26 20:11:21 +0200
commitcca642952abea08e4cbd294c797c88f3d38564bc (patch)
treed26c19db719b3a1520e57ffed326325e3033a26e
parent25206150fc9ab860cdf6928acdc5869d96821c5a (diff)
parentd6d24db17354c116276a1dae86f4a65d590d206b (diff)
downloadNotEnoughUpdates-cca642952abea08e4cbd294c797c88f3d38564bc.tar.gz
NotEnoughUpdates-cca642952abea08e4cbd294c797c88f3d38564bc.tar.bz2
NotEnoughUpdates-cca642952abea08e4cbd294c797c88f3d38564bc.zip
Merge pull request #28 from DeDiamondPro/master
Icons in dwarven overlay, fix + save max commision number and add command block in sb profile viewer to open profile viewer
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java16
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java112
4 files changed, 131 insertions, 7 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
index 08ef97a9..ea9994a7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
@@ -937,6 +937,16 @@ public class NEUEventListener {
GuiChest eventGui = (GuiChest) guiScreen;
ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if(containerName.endsWith(" Profile")){
+ Slot slot = new Slot(cc.getLowerChestInventory(), 34, cc.inventorySlots.get(34).xDisplayPosition, cc.inventorySlots.get(34).yDisplayPosition);
+ slot.putStack(Utils.createItemStack(Item.getItemFromBlock(Blocks.command_block), EnumChatFormatting.GREEN + "Profile Viewer",
+ EnumChatFormatting.YELLOW + "Click to open NEU profile viewer!"));
+ cc.inventorySlots.replaceAll(e -> {
+ if(e.getSlotIndex() == 34)
+ return slot;
+ return e;
+ });
+ }
}
if(GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
@@ -1386,6 +1396,12 @@ public class NEUEventListener {
GuiChest eventGui = (GuiChest) guiScreen;
ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if(containerName.endsWith(" Profile") && eventGui.getSlotUnderMouse() != null && eventGui.getSlotUnderMouse().getSlotIndex() == 34 &&
+ Mouse.getEventButton() >= 0) {
+ event.setCanceled(true);
+ Utils.playPressSound();
+ NotEnoughUpdates.INSTANCE.viewProfileRunnable.processCommand(null, new String[]{containerName.replaceAll("'s? Profile", "")});
+ }
}
if(GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
index 22d3f6ff..98816714 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
@@ -23,6 +23,7 @@ import org.lwjgl.util.vector.Vector2f;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
public class NEUConfig extends Config {
@@ -285,6 +286,7 @@ public class NEUConfig extends Config {
@Expose public ArrayList<String> enchantColours = createDefaultEnchantColours();
@Expose public String repoURL = "https://github.com/Moulberry/NotEnoughUpdates-REPO/archive/master.zip";
@Expose public String repoCommitsURL = "https://api.github.com/repos/Moulberry/NotEnoughUpdates-REPO/commits/master";
+ @Expose public Map<String, Integer> commissionMaxes = new HashMap<>();
@Expose public boolean firstTimeSearchFocus = true;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
index a80e587d..90c4dc8a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
@@ -138,6 +138,14 @@ public class Mining {
@ConfigAccordionId(id = 2)
public int overlayStyle = 0;
+ @Expose
+ @ConfigOption(
+ name = "Show Icons",
+ desc = "Show Icons representing the part of the overlay."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean dwarvenOverlayIcons = true;
@Expose
@ConfigOption(
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
index f85ee646..c338c9a5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
@@ -14,6 +14,7 @@ import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.network.NetworkPlayerInfo;
+import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -22,6 +23,7 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.WorldSettings;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.lwjgl.util.vector.Vector2f;
import java.util.*;
import java.util.function.Supplier;
@@ -36,8 +38,7 @@ public class MiningOverlay extends TextOverlay {
super(position, dummyStrings, styleSupplier);
}
- private static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+(?: |$)");
- private static Map<String, Integer> commissionMaxes = new HashMap<>();
+ private static final Pattern NUMBER_PATTERN = Pattern.compile("(?<number>\\d*,?\\d+)(?: |$)");
public static Map<String, Float> commissionProgress = new LinkedHashMap<>();
@Override
@@ -65,7 +66,7 @@ public class MiningOverlay extends TextOverlay {
Matcher matcher = NUMBER_PATTERN.matcher(clean);
if(matcher.find()) {
try {
- numberValue = Integer.parseInt(matcher.group());
+ numberValue = Integer.parseInt(matcher.group("number").replace(",", ""));
} catch(NumberFormatException ignored) {}
}
}
@@ -78,7 +79,7 @@ public class MiningOverlay extends TextOverlay {
}
}
if(name != null && numberValue > 0) {
- commissionMaxes.put(name, numberValue);
+ NotEnoughUpdates.INSTANCE.config.hidden.commissionMaxes.put(name, numberValue);
}
}
}
@@ -341,8 +342,8 @@ public class MiningOverlay extends TextOverlay {
} else if (entry.getValue() >= 0.25) {
col = GOLD;
}
- if (true && commissionMaxes.containsKey(entry.getKey())) {
- int max = commissionMaxes.get(entry.getKey());
+ if (NotEnoughUpdates.INSTANCE.config.hidden.commissionMaxes.containsKey(entry.getKey())) {
+ int max = NotEnoughUpdates.INSTANCE.config.hidden.commissionMaxes.get(entry.getKey());
commissionsStrings.add(DARK_AQUA + entry.getKey() + ": " + col + Math.round(entry.getValue() * max) + "/" + max);
} else {
String valS = Utils.floatToString(entry.getValue() * 100, 1);
@@ -508,7 +509,7 @@ public class MiningOverlay extends TextOverlay {
}
long timeDuration = finishTime - currentTimeMillis;
- returnText = returnText+ EnumChatFormatting.DARK_PURPLE +this.itemName+" : ";
+ returnText = returnText+ EnumChatFormatting.DARK_PURPLE +this.itemName+": ";
int days = (int) (timeDuration / (1000*60*60*24));
timeDuration = timeDuration-(days*(1000*60*60*24));
@@ -551,5 +552,102 @@ public class MiningOverlay extends TextOverlay {
}
}
+ @Override
+ protected Vector2f getSize(List<String> strings) {
+ if (NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlayIcons)
+ return super.getSize(strings).translate(12, 0);
+ return super.getSize(strings);
+ }
+ @Override
+ protected void renderLine(String line, Vector2f position, boolean dummy) {
+ if (!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlayIcons) return;
+ GlStateManager.enableDepth();
+
+ ItemStack icon = null;
+ String cleaned = Utils.cleanColour(line);
+ String beforeColon = cleaned.split(":")[0];
+ switch (beforeColon) {
+ case "Mithril Powder":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("INK_SACK-10"));
+ break;
+ case "Gemstone Powder":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("INK_SACK-9"));
+ break;
+ case "Lucky Raffle":
+ case "Raffle":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("MINING_RAFFLE_TICKET"));
+ break;
+ case "Pickaxe CD":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DIAMOND_PICKAXE"));
+ break;
+ case "Thyst Slayer":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("THYST_MONSTER"));
+ break;
+ case "Hard Stone Miner":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("HARD_STONE"));
+ break;
+ case "Ice Walker Slayer":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ENCHANTED_ICE"));
+ break;
+ case "Goblin Slayer":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("GOBLIN_MONSTER"));
+ break;
+ case "Star Sentry Puncher":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("NETHER_STAR"));
+ break;
+ case "Goblin Raid":
+ case "Goblin Raid Slayer":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ENCHANTED_GOLD"));
+ break;
+ case "2x Mithril Powder Collector":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ENCHANTED_GLOWSTONE_DUST"));
+ break;
+ case "Automaton Slayer":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("AUTOMATON_MONSTER"));
+ break;
+ case "Sludge Slayer":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SLUDGE_MONSTER"));
+ break;
+ case "Team Treasurite Member Slayer":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("EXECUTIVE_WENDY_MONSTER"));
+ break;
+ case "Yog Slayer":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("YOG_MONSTER"));
+ break;
+ case "Boss Corleone Slayer":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("BOSS_CORLEONE_BOSS"));
+ break;
+ case "Chest Looter":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("CHEST"));
+ break;
+ }
+ if (icon == null) {
+ if(beforeColon.startsWith("Forge")){
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ANVIL"));
+ } else if (beforeColon.contains("Mithril")) {
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("MITHRIL_ORE"));
+ } else if(beforeColon.endsWith(" Gemstone Collector")){
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ROUGH_"
+ + beforeColon.replace(" Gemstone Collector", "").toUpperCase() + "_GEM"));
+ } else if (beforeColon.endsWith(" Crystal Hunter")){
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_"
+ + beforeColon.replace(" Crystal Hunter", "").toUpperCase() + "_GEM"));
+ } else if (beforeColon.contains("Titanium")) {
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("TITANIUM_ORE"));
+ }
+ }
+
+ if (icon != null) {
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(position.x, position.y, 0);
+ GlStateManager.scale(0.5f, 0.5f, 1f);
+ Utils.drawItemStack(icon, 0, 0);
+ GlStateManager.popMatrix();
+
+ position.x += 12;
+ }
+
+ super.renderLine(line, position, dummy);
+ }
}