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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
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 boolean restart = false;
private static int countdown = 0;
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 interactHandler(TickEvent.ClientTickEvent event) {
if(Main.mc.thePlayer == null || Main.mc.theWorld == null) return;
if(ScoreboardUtils.inPrivateIsland) return;
if (!Main.configFile.autoSlayer || !Main.configFile.clickMaddox || waitingForMaddox || debounce != 0) return;
if (Main.configFile.forceSlayer) {
if (!ScoreboardUtils.scoreboardContains("Slay the boss!") && !ScoreboardUtils.scoreboardContains("Kills") && !ScoreboardUtils.scoreboardContains("Combat XP")) {
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;
restart = false;
}
}
if (ScoreboardUtils.scoreboardContains("Slay the boss!")) {
if (!restart) {
countdown = 800;
restart = true;
} else {
if (countdown > 0) {
if (countdown % 40 == 0) {
ChatUtils.sendMessage("§ccountdown: " + countdown / 40);
}
countdown--;
} else {
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;
restart = false;
}
}
}
}
} else {
if (ScoreboardUtils.scoreboardContains("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;
restart = false;
}
}
}
}
@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")) {
if (Main.configFile.forceSlayer) {
clickSlot(13, 2, 0);
clickSlot(11, 2, 1);
clickSlot(slayerSlot, 2, 2);
clickSlot(slotLevel, 2, 3);
clickSlot(11, 2, 4); //confirm
debounce = 80;
}
} 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 if (chestInventory.get(13).getStack().getDisplayName().contains("Failed")) {
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);
}
}
|