aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/chrisoft/trashyaddon/modules/AutoTrade.java
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2024-09-06 23:02:34 -0400
committerGravatar Chris Xiong <chirs241097@gmail.com> 2024-09-06 23:02:34 -0400
commit263695053d997e75ec4a10f0de3ea0cb8a0de80c (patch)
treea3d331738b56e0661731511cb46297d51e6ae9cd /src/main/java/org/chrisoft/trashyaddon/modules/AutoTrade.java
parent04b4941e65693f8d6b55f924781d7dd7cd26b1d5 (diff)
downloadmeteor-trashy-addon-dev.tar.xz
1.21 ... maybe (still testing)HEADdev
Special thanks to Xenapte for the 1.20.6 patch.
Diffstat (limited to 'src/main/java/org/chrisoft/trashyaddon/modules/AutoTrade.java')
-rw-r--r--src/main/java/org/chrisoft/trashyaddon/modules/AutoTrade.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main/java/org/chrisoft/trashyaddon/modules/AutoTrade.java b/src/main/java/org/chrisoft/trashyaddon/modules/AutoTrade.java
index dfb343d..a062b38 100644
--- a/src/main/java/org/chrisoft/trashyaddon/modules/AutoTrade.java
+++ b/src/main/java/org/chrisoft/trashyaddon/modules/AutoTrade.java
@@ -39,7 +39,7 @@ public class AutoTrade extends Module {
Items.ROTTEN_FLESH,
Items.GOLD_INGOT,
Items.RABBIT_FOOT,
- Items.SCUTE,
+ Items.TURTLE_SCUTE,
Items.GLASS_BOTTLE,
Items.NETHER_WART,
Items.WHEAT,
@@ -184,11 +184,11 @@ public class AutoTrade extends Module {
private boolean isOfferEligible(TradeOffer o) {
// I don't give a SHIT to trades that use the second slot
// well actually I do, but I don't need THAT many enchanted books...
- if (!o.getSecondBuyItem().getItem().equals(Items.AIR))
+ if (o.getSecondBuyItem().isPresent() && !o.getSecondBuyItem().get().equals(Items.AIR))
return false;
if (o.isDisabled())
return false;
- ItemStack mbuy = o.getAdjustedFirstBuyItem();
+ ItemStack mbuy = o.getDisplayedFirstBuyItem();
ItemStack msell = o.getSellItem();
List<Item> sells = sellingEnabled.get() ? this.sellsSetting.get() : List.of();
List<Item> buys = buyingEnabled.get() ? this.buysSetting.get() : List.of();
@@ -223,7 +223,7 @@ public class AutoTrade extends Module {
ticksRemaining = -0xdead;
TradeOffer o = offers.get(currentOffer);
Item tradedItem = o.getSellItem().getItem().equals(Items.EMERALD) ?
- o.getAdjustedFirstBuyItem().getItem() : o.getSellItem().getItem();
+ o.getDisplayedFirstBuyItem().getItem() : o.getSellItem().getItem();
countBefore = screen.getScreenHandler().slots.stream()
.map(slot -> slot.getStack())
.filter(s -> s.getItem().equals(tradedItem))
@@ -236,7 +236,7 @@ public class AutoTrade extends Module {
private void finalizeCurrentTrade() {
TradeOffer o = offers.get(currentOffer);
Item tradedItem = o.getSellItem().getItem().equals(Items.EMERALD) ?
- o.getAdjustedFirstBuyItem().getItem() : o.getSellItem().getItem();
+ o.getDisplayedFirstBuyItem().getItem() : o.getSellItem().getItem();
countAfter = screen.getScreenHandler().slots.stream()
.map(slot -> slot.getStack())
.filter(s -> s.getItem().equals(tradedItem))
@@ -265,6 +265,7 @@ public class AutoTrade extends Module {
first = false;
}
info(f.toString());
+ f.close();
}
if (!itemsBought.isEmpty()) {
Formatter f = new Formatter();
@@ -275,6 +276,7 @@ public class AutoTrade extends Module {
first = false;
}
info(f.toString());
+ f.close();
}
}
if (autoClose.get() && (!itemsBought.isEmpty() || !itemsSold.isEmpty()))
@@ -293,7 +295,7 @@ public class AutoTrade extends Module {
return;
}
if (waitState != WaitState.None && currentOffer < offers.size() && (offers.get(currentOffer).isDisabled() ||
- screen.getScreenHandler().slots.get(0).getStack().getCount() < offers.get(currentOffer).getAdjustedFirstBuyItem().getCount())) {
+ screen.getScreenHandler().slots.get(0).getStack().getCount() < offers.get(currentOffer).getDisplayedFirstBuyItem().getCount())) {
// the WaitingForInventoryUpdate state is mostly useless because ScreenHandlerSlotUpdateS2CPacket
// isn't sent after the shift-click...
finalizeCurrentTrade();