sebseb7
2024-02-04 07:56:30 +01:00
parent 8e7bd09cfc
commit bbc8d1e9fb
3 changed files with 16 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ mod_name = AutoTrade
author = sebseb7 author = sebseb7
mod_file_name = autotrade-fabric mod_file_name = autotrade-fabric
mod_version = 0.0.10 mod_version = 0.0.11
malilib_version = 0.18.0 malilib_version = 0.18.0
minecraft_version_min = 1.20.3 minecraft_version_min = 1.20.3

View File

@@ -55,11 +55,13 @@ public class Configs implements IConfigHandler {
public static final ConfigBoolean VOID_TRADING_DELAY_AFTER_TELEPORT = new ConfigBoolean("delayAfterTeleport", public static final ConfigBoolean VOID_TRADING_DELAY_AFTER_TELEPORT = new ConfigBoolean("delayAfterTeleport",
true, true,
"true: Start the delay after the villager was unloaded; false: Start the delay after the trade has been initiated"); "true: Start the delay after the villager was unloaded; false: Start the delay after the trade has been initiated");
public static final ConfigInteger CONTAINER_CLOSE_DELAY = new ConfigInteger("containerCloseDelay", 0, 0,
30000000, "delay in ticks; to get signal from trapped chest");
public static final ImmutableList<IConfigValue> OPTIONS = ImmutableList.of(ENABLED, ITEM_FRAME, GLASS_BLOCK, public static final ImmutableList<IConfigValue> OPTIONS = ImmutableList.of(ENABLED, ITEM_FRAME, GLASS_BLOCK,
SELECTOR_OFFSET, ENABLE_SELL, SELL_ITEM, SELL_LIMIT, ENABLE_BUY, BUY_ITEM, BUY_LIMIT, MAX_INPUT_ITEMS, SELECTOR_OFFSET, ENABLE_SELL, SELL_ITEM, 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, INPUT_CONTAINER_X, INPUT_CONTAINER_Y, INPUT_CONTAINER_Z, OUTPUT_CONTAINER_X, OUTPUT_CONTAINER_Y,
OUTPUT_CONTAINER_Z, VOID_TRADING_DELAY, VOID_TRADING_DELAY_AFTER_TELEPORT); OUTPUT_CONTAINER_Z, VOID_TRADING_DELAY, VOID_TRADING_DELAY_AFTER_TELEPORT, CONTAINER_CLOSE_DELAY);
} }
public static void loadFromFile() { public static void loadFromFile() {

View File

@@ -59,6 +59,7 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
private boolean outputOpened = false; private boolean outputOpened = false;
private int tickCount = 0; private int tickCount = 0;
private int voidDelay = 0; private int voidDelay = 0;
private int containerDelay = 0;
private int screenOpened = 0; private int screenOpened = 0;
public static KeybindCallbacks getInstance() { public static KeybindCallbacks getInstance() {
@@ -227,6 +228,11 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
return; return;
} }
if (containerDelay > 0) {
containerDelay--;
}
if (this.functionalityEnabled() == false || mc.player == null) { if (this.functionalityEnabled() == false || mc.player == null) {
return; return;
} }
@@ -371,11 +377,11 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
if (GuiUtils.getCurrentScreen() instanceof ShulkerBoxScreen) { if (GuiUtils.getCurrentScreen() instanceof ShulkerBoxScreen) {
ShulkerBoxScreen screen = (ShulkerBoxScreen) GuiUtils.getCurrentScreen(); ShulkerBoxScreen screen = (ShulkerBoxScreen) GuiUtils.getCurrentScreen();
ShulkerBoxScreenHandler handler = screen.getScreenHandler(); ShulkerBoxScreenHandler handler = screen.getScreenHandler();
if (inputOpened) { if ((containerDelay == 0) && inputOpened) {
processInput(handler); processInput(handler);
screen.close(); screen.close();
} }
if (outputOpened) { if ((containerDelay == 0) && outputOpened) {
processOutput(handler); processOutput(handler);
screen.close(); screen.close();
} }
@@ -383,11 +389,11 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
if (GuiUtils.getCurrentScreen() instanceof GenericContainerScreen) { if (GuiUtils.getCurrentScreen() instanceof GenericContainerScreen) {
GenericContainerScreen screen = (GenericContainerScreen) GuiUtils.getCurrentScreen(); GenericContainerScreen screen = (GenericContainerScreen) GuiUtils.getCurrentScreen();
GenericContainerScreenHandler handler = screen.getScreenHandler(); GenericContainerScreenHandler handler = screen.getScreenHandler();
if (inputOpened) { if ((containerDelay == 0) && inputOpened) {
processInput(handler); processInput(handler);
screen.close(); screen.close();
} }
if (outputOpened) { if ((containerDelay == 0) && outputOpened) {
processOutput(handler); processOutput(handler);
screen.close(); screen.close();
} }
@@ -437,6 +443,7 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
inputInRange = true; inputInRange = true;
ActionResult result = mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, ActionResult result = mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND,
new BlockHitResult(input.toCenterPos(), Direction.UP, input, false)); new BlockHitResult(input.toCenterPos(), Direction.UP, input, false));
containerDelay = Configs.Generic.CONTAINER_CLOSE_DELAY.getIntegerValue();
inputOpened = true; inputOpened = true;
return; return;
} }
@@ -444,6 +451,7 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
outputInRange = true; outputInRange = true;
ActionResult result = mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, ActionResult result = mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND,
new BlockHitResult(output.toCenterPos(), Direction.UP, output, false)); new BlockHitResult(output.toCenterPos(), Direction.UP, output, false));
containerDelay = Configs.Generic.CONTAINER_CLOSE_DELAY.getIntegerValue();
outputOpened = true; outputOpened = true;
return; return;
} }