diff options
Diffstat (limited to 'src/main/java/rosegoldaddons/features/CustomItemMacro.java')
-rw-r--r-- | src/main/java/rosegoldaddons/features/CustomItemMacro.java | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/main/java/rosegoldaddons/features/CustomItemMacro.java b/src/main/java/rosegoldaddons/features/CustomItemMacro.java index 57c650f..3133cb8 100644 --- a/src/main/java/rosegoldaddons/features/CustomItemMacro.java +++ b/src/main/java/rosegoldaddons/features/CustomItemMacro.java @@ -10,7 +10,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import rosegoldaddons.Main; import rosegoldaddons.commands.UseCooldown; -import rosegoldaddons.commands.WartSetup; import java.lang.reflect.Method; @@ -26,9 +25,8 @@ public class CustomItemMacro { try { milis++; int prevItem = Minecraft.getMinecraft().thePlayer.inventory.currentItem; - for (String i : UseCooldown.items.keySet()) { - //Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(Math.floor(UseCooldown.items.get(i)/1000) + " " + milis)); - if (milis % Math.floor(UseCooldown.items.get(i)/100) == 0) { + for (String i : UseCooldown.RCitems.keySet()) { + if (milis % Math.floor(UseCooldown.RCitems.get(i)/100) == 0) { int slot = findItemInHotbar(i); if (slot != -1) { Minecraft.getMinecraft().thePlayer.inventory.currentItem = slot; @@ -37,6 +35,16 @@ public class CustomItemMacro { } } } + for (String i : UseCooldown.LCitems.keySet()) { + if (milis % Math.floor(UseCooldown.LCitems.get(i)/100) == 0) { + int slot = findItemInHotbar(i); + if (slot != -1) { + Minecraft.getMinecraft().thePlayer.inventory.currentItem = slot; + Thread.sleep(100); + click(); + } + } + } Minecraft.getMinecraft().thePlayer.inventory.currentItem = prevItem; Thread.sleep(100); } catch (Exception e) { @@ -62,6 +70,21 @@ public class CustomItemMacro { } } + public static void click() { + try { + Method clickMouse; + try { + clickMouse = Minecraft.class.getDeclaredMethod("func_147116_af"); + } catch (NoSuchMethodException e) { + clickMouse = Minecraft.class.getDeclaredMethod("clickMouse"); + } + clickMouse.setAccessible(true); + clickMouse.invoke(Minecraft.getMinecraft()); + } catch (Exception e) { + e.printStackTrace(); + } + } + private static int findItemInHotbar(String name) { InventoryPlayer inv = Minecraft.getMinecraft().thePlayer.inventory; for (int i = 0; i < 9; i++) { |