removed the need to move the player, emerald cannot be the selected item
This commit is contained in:
@@ -7,7 +7,7 @@ mod_name = AutoTrade
|
||||
author = sebseb7
|
||||
mod_file_name = autotrade-fabric
|
||||
|
||||
mod_version = 0.0.1
|
||||
mod_version = 0.0.2
|
||||
|
||||
malilib_version = 0.16.0
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@ import com.github.sebseb7.autotrade.config.Configs;
|
||||
import com.github.sebseb7.autotrade.event.InputHandler;
|
||||
import com.github.sebseb7.autotrade.event.KeybindCallbacks;
|
||||
import fi.dy.masa.malilib.config.ConfigManager;
|
||||
import fi.dy.masa.malilib.config.options.ConfigString;
|
||||
import fi.dy.masa.malilib.event.InputEventHandler;
|
||||
import fi.dy.masa.malilib.event.TickHandler;
|
||||
import fi.dy.masa.malilib.interfaces.IInitializationHandler;
|
||||
import fi.dy.masa.malilib.interfaces.IValueChangeCallback;
|
||||
|
||||
public class InitHandler implements IInitializationHandler {
|
||||
@Override
|
||||
@@ -19,5 +21,26 @@ public class InitHandler implements IInitializationHandler {
|
||||
TickHandler.getInstance().registerClientTickHandler(KeybindCallbacks.getInstance());
|
||||
|
||||
KeybindCallbacks.getInstance().setCallbacks();
|
||||
|
||||
ValueChangeCallback valueChangeCallback = new ValueChangeCallback();
|
||||
Configs.Generic.SELL_ITEM.setValueChangeCallback(valueChangeCallback);
|
||||
Configs.Generic.BUY_ITEM.setValueChangeCallback(valueChangeCallback);
|
||||
|
||||
}
|
||||
|
||||
private static class ValueChangeCallback implements IValueChangeCallback<ConfigString> {
|
||||
@Override
|
||||
public void onValueChanged(ConfigString config) {
|
||||
if (config == Configs.Generic.SELL_ITEM) {
|
||||
if (Configs.Generic.SELL_ITEM.getStringValue().equals("minecraft:emerald")) {
|
||||
Configs.Generic.SELL_ITEM.setValueFromString("");
|
||||
} ;
|
||||
}
|
||||
if (config == Configs.Generic.BUY_ITEM) {
|
||||
if (Configs.Generic.BUY_ITEM.getStringValue().equals("minecraft:emerald")) {
|
||||
Configs.Generic.BUY_ITEM.setValueFromString("");
|
||||
} ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
|
||||
private boolean inputOpened = false;
|
||||
private boolean outputInRange = false;
|
||||
private boolean outputOpened = false;
|
||||
private int tickCount = 0;
|
||||
|
||||
public static KeybindCallbacks getInstance() {
|
||||
return INSTANCE;
|
||||
@@ -329,5 +330,13 @@ public class KeybindCallbacks implements IHotkeyCallback, IClientTickHandler {
|
||||
outputInRange = false;
|
||||
}
|
||||
|
||||
tickCount++;
|
||||
if (tickCount > 200) {
|
||||
tickCount = 0;
|
||||
villagersInRange = new Vector<Entity>();
|
||||
inputInRange = false;
|
||||
outputInRange = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user