1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
package rosegoldaddons.features;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import rosegoldaddons.Main;
import rosegoldaddons.utils.ChatUtils;
import rosegoldaddons.utils.ScoreboardUtils;
import java.util.List;
public class AutoSlayer {
private static String lastMaddoxCommand = "/cb placeholder";
private static boolean openMaddox = false;
private static boolean startSlayer = false;
private static boolean waitingForMaddox = false;
private static int slayerSlot = 0;
private static int slotLevel = 0;
private static int debounce = 0;
@SubscribeEvent
public void chat(ClientChatReceivedEvent event) {
if (!Main.configFile.autoSlayer) return;
String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
if (message.contains(":")) return;
if (message.contains("[OPEN MENU]")) {
List<IChatComponent> siblings = event.message.getSiblings();
for (IChatComponent sibling : siblings) {
if (sibling.getUnformattedText().contains("[OPEN MENU]")) {
lastMaddoxCommand = sibling.getChatStyle().getChatClickEvent().getValue();
openMaddox = true;
}
}
}
}
@SubscribeEvent
public void onInteract(InputEvent.KeyInputEvent event) {
if (!Main.configFile.autoSlayer || !Main.configFile.clickMaddox || waitingForMaddox || debounce != 0) return;
List<String> scoreboard = ScoreboardUtils.getSidebarLines();
for (String line : scoreboard) {
String cleanedLine = ScoreboardUtils.cleanSB(line);
if (cleanedLine.contains("Boss slain!")) {
int maddox = findItemInHotbar("Batphone");
if (maddox != -1) {
ItemStack item = Main.mc.thePlayer.inventory.getStackInSlot(maddox);
int save = Main.mc.thePlayer.inventory.currentItem;
Main.mc.thePlayer.inventory.currentItem = maddox;
Main.mc.playerController.sendUseItem(Main.mc.thePlayer, Main.mc.theWorld, item);
Main.mc.thePlayer.inventory.currentItem = save;
waitingForMaddox = true;
break;
}
}
}
}
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (!Main.configFile.autoSlayer) return;
if (debounce > 0) {
debounce--;
}
if (!openMaddox) return;
Main.mc.thePlayer.sendChatMessage(lastMaddoxCommand);
switch (Main.configFile.slayerTypeIndex) {
case 1:
slayerSlot = 10; //zombie
slotLevel = 13; //tier 3
break;
case 2:
slayerSlot = 10;
slotLevel = 14; //tier 4
break;
case 3:
slayerSlot = 10;
slotLevel = 15; //tier 5
break;
case 4:
slayerSlot = 11; //spider
slotLevel = 13; //tier 3
break;
case 5:
slayerSlot = 11;
slotLevel = 14; //tier 4
break;
case 6:
slayerSlot = 12; //sven
slotLevel = 13; //tier 3
break;
case 7:
slayerSlot = 12;
slotLevel = 14; //tier 4
break;
case 8:
slayerSlot = 13; //eman
slotLevel = 12; //tier 2
break;
case 9:
slayerSlot = 13;
slotLevel = 13; //tier 3
break;
case 10:
slayerSlot = 13;
slotLevel = 14; //tier 4
break;
}
openMaddox = false;
startSlayer = true;
}
@SubscribeEvent
public void guiDraw(GuiScreenEvent.BackgroundDrawnEvent event) {
if (!Main.configFile.autoSlayer) return;
if (!startSlayer) return;
if (slayerSlot == 0 || slotLevel == 0) return;
if (event.gui instanceof GuiChest) {
Container container = ((GuiChest) event.gui).inventorySlots;
if (container instanceof ContainerChest) {
String chestName = ((ContainerChest) container).getLowerChestInventory().getDisplayName().getUnformattedText();
if (chestName.contains("Slayer")) {
List<Slot> chestInventory = ((GuiChest) Main.mc.currentScreen).inventorySlots.inventorySlots;
if (!chestInventory.get(13).getHasStack()) return;
if (chestInventory.get(13).getStack().getDisplayName().contains("Ongoing")) {
} else if (chestInventory.get(13).getStack().getDisplayName().contains("Complete")) {
clickSlot(13, 2, 0);
clickSlot(slayerSlot, 2, 1);
clickSlot(slotLevel, 2, 2);
clickSlot(11, 2, 3); //confirm
debounce = 80;
} else {
clickSlot(slayerSlot, 2, 0);
clickSlot(slotLevel, 2, 1);
clickSlot(11, 2, 2); //confirm
debounce = 80;
}
slayerSlot = 0;
slotLevel = 0;
startSlayer = false;
waitingForMaddox = false;
}
}
}
}
private static int findItemInHotbar(String name) {
InventoryPlayer inv = Main.mc.thePlayer.inventory;
for (int i = 0; i < 9; i++) {
ItemStack curStack = inv.getStackInSlot(i);
if (curStack != null) {
if (curStack.getDisplayName().contains(name)) {
return i;
}
}
}
return -1;
}
private void clickSlot(int slot, int type, int windowAdd) {
Main.mc.playerController.windowClick(Main.mc.thePlayer.openContainer.windowId + windowAdd, slot, type, 0, Main.mc.thePlayer);
}
}
|