price limits

This commit is contained in:
sebseb7
2023-07-22 22:49:28 +02:00
parent 365bb33bab
commit 830147411c
3 changed files with 10 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ mod_name = AutoTrade
author = sebseb7
mod_file_name = autotrade-fabric
mod_version = 0.0.3
mod_version = 0.0.4
malilib_version = 0.16.0

View File

@@ -24,10 +24,13 @@ public class Configs implements IConfigHandler {
"Enable selling (if disabled emeralds are taken from the input container)");
public static final ConfigString SELL_ITEM = new ConfigString("sellItem", "minecraft:gold_ingot",
"The item to sell for emerald.");
public static final ConfigInteger SELL_LIMIT = new ConfigInteger("sellLimit", 64, 1, 64,
"max price to sell for");
public static final ConfigBoolean ENABLE_BUY = new ConfigBoolean("enableBuy", false,
"Enable buying (if disabled emeralds are placed in the output container)");
public static final ConfigString BUY_ITEM = new ConfigString("buyItem", "minecraft:redstone",
"The item to buy using emerald.");
public static final ConfigInteger BUY_LIMIT = new ConfigInteger("buyLimit", 64, 1, 64, "max price to buy for");
public static final ConfigInteger MAX_INPUT_ITEMS = new ConfigInteger("maxInputStacks", 9, 1, 35,
"stacks to take from input container (or emerald container in buy-only mode)");
public static final ConfigInteger INPUT_CONTAINER_X = new ConfigInteger("inputContainerX", 0, -30000000,
@@ -46,8 +49,8 @@ public class Configs implements IConfigHandler {
"delay in ticks for void trading");
public static final ImmutableList<IConfigValue> OPTIONS = ImmutableList.of(ENABLED, ENABLE_SELL, SELL_ITEM,
ENABLE_BUY, BUY_ITEM, MAX_INPUT_ITEMS, INPUT_CONTAINER_X, INPUT_CONTAINER_Y, INPUT_CONTAINER_Z,
OUTPUT_CONTAINER_X, OUTPUT_CONTAINER_Y, OUTPUT_CONTAINER_Z, VOID_TRADING_DELAY);
SELL_LIMIT, ENABLE_BUY, BUY_ITEM, BUY_LIMIT, MAX_INPUT_ITEMS, INPUT_CONTAINER_X, INPUT_CONTAINER_Y,
INPUT_CONTAINER_Z, OUTPUT_CONTAINER_X, OUTPUT_CONTAINER_Y, OUTPUT_CONTAINER_Z, VOID_TRADING_DELAY);
}
public static void loadFromFile() {

View File

@@ -218,7 +218,8 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
String sellId = Registries.ITEM.getId(sellItem.getItem()).toString();
String buyId = Registries.ITEM.getId(buyItem.getItem()).toString();
if (sellId.equals(buyItemStr) && Configs.Generic.ENABLE_BUY.getBooleanValue()) {
if (sellId.equals(buyItemStr) && Configs.Generic.ENABLE_BUY.getBooleanValue()
&& buyItem.getCount() <= Configs.Generic.BUY_LIMIT.getIntegerValue()) {
Slot slot = handler.getSlot(2);
handler.switchTo(i);
handler.setRecipeIndex(i);
@@ -230,7 +231,8 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
System.out.println("err " + e.toString());
}
}
if (buyId.equals(sellItemStr) && Configs.Generic.ENABLE_SELL.getBooleanValue()) {
if (buyId.equals(sellItemStr) && Configs.Generic.ENABLE_SELL.getBooleanValue()
&& buyItem.getCount() <= Configs.Generic.SELL_LIMIT.getIntegerValue()) {
Slot slot = handler.getSlot(2);
handler.switchTo(i);
handler.setRecipeIndex(i);