aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java
index c76a22b4..c7bcc0e1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java
@@ -37,6 +37,7 @@ public class AuctionBINWarning extends GuiElement {
private String sellingName;
private int sellingPrice;
private int lowestPrice;
+ private int sellStackAmount;
private boolean shouldPerformCheck() {
if (!NotEnoughUpdates.INSTANCE.config.ahTweaks.enableBINWarning ||
@@ -83,6 +84,7 @@ public class AuctionBINWarning extends GuiElement {
ItemStack sellStack = chest.inventorySlots.getSlot(13).getStack();
String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(sellStack);
+ sellStackAmount = sellStack.stackSize;
if (internalname == null) {
return false;
@@ -105,13 +107,17 @@ public class AuctionBINWarning extends GuiElement {
lowestPrice = (int) NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname);
}
- //TODO: Add option for warning if lowest price does not exist
-
- float factor = 1 - NotEnoughUpdates.INSTANCE.config.ahTweaks.warningThreshold / 100;
- if (factor < 0) factor = 0;
- if (factor > 1) factor = 1;
-
- if (sellingPrice > 0 && lowestPrice > 0 && sellingPrice < lowestPrice * factor) {
+ float undercutFactor = 1 - NotEnoughUpdates.INSTANCE.config.ahTweaks.warningThreshold / 100;
+ if (undercutFactor < 0) undercutFactor = 0;
+ if (undercutFactor > 1) undercutFactor = 1;
+ float overcutFactor = 1 + NotEnoughUpdates.INSTANCE.config.ahTweaks.overcutWarningThreshold / 100;
+ if (overcutFactor < 0) overcutFactor = 0;
+
+ if (
+ (sellingPrice > 0 && lowestPrice > 0 &&
+ ((sellingPrice > sellStackAmount * lowestPrice * overcutFactor) ||
+ sellingPrice < sellStackAmount * lowestPrice * undercutFactor))
+ || lowestPrice == -1) {
showWarning = true;
return true;
} else {
@@ -155,10 +161,10 @@ public class AuctionBINWarning extends GuiElement {
);
String lowestPriceStr;
- if (lowestPrice > 999) {
- lowestPriceStr = Utils.shortNumberFormat(lowestPrice, 0);
+ if (lowestPrice * sellStackAmount > 999) {
+ lowestPriceStr = Utils.shortNumberFormat(lowestPrice * sellStackAmount, 0);
} else {
- lowestPriceStr = "" + lowestPrice;
+ lowestPriceStr = "" + lowestPrice * sellStackAmount;
}
String sellingPriceStr;
@@ -174,7 +180,9 @@ public class AuctionBINWarning extends GuiElement {
width / 2, height / 2 - 45 + 25, false, 170, 0xffffffff
);
TextRenderUtils.drawStringCenteredScaledMaxWidth(
- "has a lowest BIN of \u00a76" + lowestPriceStr + "\u00a7r coins",
+ (lowestPrice > 0
+ ? "has a lowest BIN of \u00a76" + lowestPriceStr + "\u00a7r coins"
+ : "\u00a7cWarning: No lowest BIN found!"),
Minecraft.getMinecraft().fontRendererObj,
width / 2,
height / 2 - 45 + 34,
@@ -183,8 +191,15 @@ public class AuctionBINWarning extends GuiElement {
0xffa0a0a0
);
- int buyPercentage = 100 - sellingPrice * 100 / lowestPrice;
- if (buyPercentage <= 0) buyPercentage = 1;
+ boolean isALoss = false;
+ int buyPercentage = 0;
+ if (sellingPrice > lowestPrice * sellStackAmount) {
+ buyPercentage = sellingPrice * 100 / (lowestPrice * sellStackAmount) - 100;
+ isALoss = false;
+ } else if (sellingPrice < lowestPrice * sellStackAmount) {
+ buyPercentage = 100 - sellingPrice * 100 / (lowestPrice * sellStackAmount);
+ isALoss = true;
+ }
TextRenderUtils.drawStringCenteredScaledMaxWidth(
"Continue selling it for",
@@ -196,7 +211,10 @@ public class AuctionBINWarning extends GuiElement {
0xffa0a0a0
);
TextRenderUtils.drawStringCenteredScaledMaxWidth(
- "\u00a76" + sellingPriceStr + "\u00a7r coins? (\u00a7c-" + buyPercentage + "%\u00a7r)",
+ "\u00a76" + sellingPriceStr + "\u00a7r coins?" +
+ ((lowestPrice > 0 && buyPercentage > 0)
+ ? "(\u00a7" + (isALoss ? "c-" : "a+") + buyPercentage + "%\u00a7r)"
+ : ""),
Minecraft.getMinecraft().fontRendererObj,
width / 2,
height / 2 - 45 + 59,
@@ -218,7 +236,7 @@ public class AuctionBINWarning extends GuiElement {
0xff00ff00
);
TextRenderUtils.drawStringCenteredScaledMaxWidth(
- EnumChatFormatting.RED + "[n]o",
+ EnumChatFormatting.RED + "[N]o",
Minecraft.getMinecraft().fontRendererObj,
width / 2 + 23,
height / 2 + 31,