aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorjani270 <69345714+jani270@users.noreply.github.com>2024-03-06 21:05:18 +0100
committerGitHub <noreply@github.com>2024-03-06 21:05:18 +0100
commit4c24769b971cb9ed6d6edf267aeebf1a8fe45766 (patch)
tree1beba8e0867d39363588b89dadc5624fcb925c95 /src/main/java
parent635770bfcd31c66b175a8480a1488e4dd3fd55ce (diff)
downloadNotEnoughUpdates-4c24769b971cb9ed6d6edf267aeebf1a8fe45766.tar.gz
NotEnoughUpdates-4c24769b971cb9ed6d6edf267aeebf1a8fe45766.tar.bz2
NotEnoughUpdates-4c24769b971cb9ed6d6edf267aeebf1a8fe45766.zip
Made shift in sacks show the stored amount as the price (#1037)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
index c149cfe2..cd756a88 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
@@ -28,6 +28,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.inventory.MuseumTooltip
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import io.github.moulberry.notenoughupdates.util.hypixelapi.HypixelItemAPI;
+import lombok.val;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.input.Keyboard;
@@ -48,6 +49,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
+import java.util.regex.Pattern;
public class ItemPriceInformation {
private static File file;
@@ -56,6 +58,9 @@ public class ItemPriceInformation {
private static final NumberFormat format = new DecimalFormat("#,##0.#", new DecimalFormatSymbols(Locale.US));
public static String STACKSIZE_OVERRIDE = "NEU_STACKSIZE_OVERRIDE";
+ private static final Pattern SACK_STORED_AMOUNT = Pattern.compile(
+ ".*Stored: §.(?<amount>[\\d,]+)§.\\/.*");
+
public static void addToTooltip(List<String> tooltip, String internalName, ItemStack stack) {
addToTooltip(tooltip, internalName, stack, true);
}
@@ -130,6 +135,20 @@ public class ItemPriceInformation {
shiftStackMultiplier = stack.getTagCompound().getInteger(STACKSIZE_OVERRIDE);
}
int stackMultiplier = 1;
+ for (int i = 3; i < tooltip.size(); i++) {
+ val matcher = SACK_STORED_AMOUNT.matcher(tooltip.get(i));
+ if (matcher.matches()) {
+ String amountString = matcher.group("amount").replace(",", "");
+ try {
+ int parsedValue = Integer.parseInt(amountString);
+ if (parsedValue != 0) {
+ shiftStackMultiplier = parsedValue;
+ }
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
+ }
+ }
boolean shiftPressed = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
if (shiftPressed) {
stackMultiplier = shiftStackMultiplier;