void trading delay

This commit is contained in:
sebseb7
2023-07-07 17:06:44 +02:00
parent f9b79f49ed
commit 365bb33bab
3 changed files with 12 additions and 2 deletions

View File

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

View File

@@ -42,10 +42,12 @@ public class Configs implements IConfigHandler {
"Output container Y (not used when buy disabled)");
public static final ConfigInteger OUTPUT_CONTAINER_Z = new ConfigInteger("outputContainerZ", 0, -30000000,
30000000, "Output container Z (not used when buy disabled)");
public static final ConfigInteger VOID_TRADING_DELAY = new ConfigInteger("voidTradingDelay", 0, 0, 30000000,
"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);
OUTPUT_CONTAINER_X, OUTPUT_CONTAINER_Y, OUTPUT_CONTAINER_Z, VOID_TRADING_DELAY);
}
public static void loadFromFile() {

View File

@@ -51,6 +51,7 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
private boolean outputInRange = false;
private boolean outputOpened = false;
private int tickCount = 0;
private int voidDelay = 0;
public static KeybindCallbacks getInstance() {
return INSTANCE;
@@ -192,6 +193,12 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
@Override
public void onClientTick(MinecraftClient mc) {
if (voidDelay > 0) {
voidDelay--;
return;
}
if (this.functionalityEnabled() == false || mc.player == null) {
return;
}
@@ -282,6 +289,7 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
found = true;
newVillagersInRange.add(entity);
mc.interactionManager.interactEntity(mc.player, entity, Hand.MAIN_HAND);
voidDelay = Configs.Generic.VOID_TRADING_DELAY.getIntegerValue();
state = false;
break;
}