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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
package me.Danker.features;
import me.Danker.DankersSkyblockMod;
import me.Danker.commands.ToggleCommand;
import me.Danker.gui.crystalhollowwaypoints.CrystalHollowAddWaypointGui;
import me.Danker.handlers.ScoreboardHandler;
import me.Danker.utils.RenderUtils;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.event.ClickEvent;
import net.minecraft.util.*;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CrystalHollowWaypoints {
public static List<Waypoint> waypoints = new ArrayList<>();
public static Pattern skytilsPattern = Pattern.compile("(?<name>.*?): (?<x>\\d{1,3}) (?<y>\\d{1,3}) (?<z>\\d{1,3})");
static boolean khazad = false;
static boolean fairy = false;
static boolean temple = false;
static boolean guardian = false;
static boolean divan = false;
static boolean corleone = false;
static boolean king = false;
static boolean queen = false;
static boolean city = false;
static boolean nucleus = false;
static boolean shop = false;
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase != TickEvent.Phase.START) return;
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
World world = mc.theWorld;
if (DankersSkyblockMod.tickAmount % 20 == 0) {
if (ToggleCommand.crystalAutoWaypoints && Utils.tabLocation.equals("Crystal Hollows") && world != null) {
boolean found = false;
List<String> scoreboard = ScoreboardHandler.getSidebarLines();
if (!nucleus) {
nucleus = true;
waypoints.add(new Waypoint("Crystal Nucleus", new BlockPos(512, 110, 512)));
}
for (String s : scoreboard) {
String sCleaned = ScoreboardHandler.cleanSB(s);
if (!khazad && sCleaned.contains("Khazad-d")) {
khazad = found = true;
waypoints.add(new Waypoint("Khazad-dûm", player.getPosition()));
} else if (!fairy && sCleaned.contains("Fairy Grotto")) {
fairy = found = true;
waypoints.add(new Waypoint("Fairy Grotto", player.getPosition()));
} else if (!temple && sCleaned.contains("Jungle Temple")) {
temple = found = true;
waypoints.add(new Waypoint("Jungle Temple", player.getPosition()));
} else if (!divan && sCleaned.contains("Mines of Divan")) {
divan = found = true;
waypoints.add(new Waypoint("Mines of Divan", player.getPosition()));
} else if (!queen && sCleaned.contains("Goblin Queen's Den")) {
queen = found = true;
waypoints.add(new Waypoint("Goblin Queen's Den", player.getPosition()));
} else if (!city && sCleaned.contains("Lost Precursor City")) {
city = found = true;
waypoints.add(new Waypoint("Lost Precursor City", player.getPosition()));
}
if (found) break;
}
if (!found) {
AxisAlignedBB scan = new AxisAlignedBB(player.getPosition().add(-15, -15, -15), player.getPosition().add(15, 15, 15));
List<EntityArmorStand> entities = world.getEntitiesWithinAABB(EntityArmorStand.class, scan);
for (EntityArmorStand entity : entities) {
if (entity.hasCustomName()) {
if (!king && entity.getCustomNameTag().endsWith("King Yolkar")) {
king = found = true;
waypoints.add(new Waypoint("King Yolkar", entity.getPosition()));
} else if (!corleone && entity.getCustomNameTag().contains("Boss Corleone")) {
corleone = found = true;
waypoints.add(new Waypoint("Boss Corleone", entity.getPosition()));
} else if (!guardian && entity.getCustomNameTag().contains("Key Guardian")) {
guardian = found = true;
waypoints.add(new Waypoint("Key Guardian", entity.getPosition()));
} else if (!shop && entity.getCustomNameTag().contains("Odawa")) {
shop = found = true;
waypoints.add(new Waypoint("Odawa", entity.getPosition()));
}
}
}
}
if (found && ToggleCommand.crystalHollowWaypoints) {
Waypoint latest = waypoints.get(waypoints.size() - 1);
player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Added " + latest.location + " @ " + latest.getPos()));
}
}
}
}
@SubscribeEvent
public void onChat(ClientChatReceivedEvent event) {
String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (player == null) return;
/* examples
$SBECHWP:Mines of Divan@-673,117,426
$SBECHWP:Khazad-dûm@-292,63,281\nFairy Grotto@-216,110,400\njungle temple@-525,110,395\nJungle Temple@-493,101,425\nMines of Divan@-673,117,426
*/
if (ToggleCommand.crystalHollowWaypoints && Utils.tabLocation.equals("Crystal Hollows")) {
if (!message.contains(player.getName())) {
if (message.contains(": $DSMCHWP:") || message.contains(": $SBECHWP:")) {
String waypoints = message.substring(message.lastIndexOf(":") + 1);
if (ToggleCommand.crystalAutoPlayerWaypoints) {
addDSMWaypoints(waypoints, true);
return;
}
ChatComponentText add = new ChatComponentText(EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + " [ADD]\n");
add.setChatStyle(add.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dsmaddcrystalhollowwaypoints " + waypoints)));
new Thread(() -> {
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
player.addChatMessage(new ChatComponentText("\n" + DankersSkyblockMod.MAIN_COLOUR + "DSM/SBE Crystal Hollows waypoints found. Click to add.\n").appendSibling(add));
}).start();
} else {
String text = message.substring(message.indexOf(":") + 2);
Matcher matcher = skytilsPattern.matcher(text);
if (matcher.matches()) {
String name = matcher.group("name");
String x = matcher.group("x");
String y = matcher.group("y");
String z = matcher.group("z");
if (ToggleCommand.crystalAutoPlayerWaypoints) {
addWaypoint(name, x, y, z);
return;
}
ChatComponentText add = new ChatComponentText(EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + " [ADD]\n");
add.setChatStyle(add.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dsmaddcrystalhollowwaypoints st " + x + " " + y + " " + z + " " + name)));
new Thread(() -> {
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
player.addChatMessage(new ChatComponentText("\n" + DankersSkyblockMod.MAIN_COLOUR + "Skytils Crystal Hollows waypoints found. Click to add.\n").appendSibling(add));
}).start();
}
}
}
}
}
@SubscribeEvent
public void onKey(InputEvent.KeyInputEvent event) {
if (!Utils.tabLocation.equals("Crystal Hollows")) return;
if (DankersSkyblockMod.keyBindings[3].isPressed()) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
mc.displayGuiScreen(new CrystalHollowAddWaypointGui((int) player.posX, (int) player.posY, (int) player.posZ));
}
}
@SubscribeEvent
public void onWorldRender(RenderWorldLastEvent event) {
if (ToggleCommand.crystalHollowWaypoints && Utils.tabLocation.equals("Crystal Hollows")) {
for (Waypoint waypoint : waypoints) {
if (waypoint.toggled) RenderUtils.draw3DWaypointString(waypoint, event.partialTicks);
}
}
}
@SubscribeEvent
public void onWorldChange(WorldEvent.Load event) {
waypoints.clear();
khazad = false;
fairy = false;
temple = false;
guardian = false;
divan = false;
corleone = false;
king = false;
queen = false;
city = false;
nucleus = false;
shop = false;
}
public static class Waypoint {
public String location;
public BlockPos pos;
public boolean toggled;
public Waypoint(String location, BlockPos pos) {
this.location = location;
this.pos = pos;
this.toggled = true;
}
public String getFormattedWaypoint() {
return location + "@-" + pos.getX() + "," + pos.getY() + "," + pos.getZ();
}
public String getDistance(EntityPlayer player) {
return Math.round(player.getDistance(pos.getX(), pos.getY(), pos.getZ())) + "m";
}
public String getPos() {
return pos.getX() + ", " + pos.getY() + ", " + pos.getZ();
}
public void toggle() {
toggled = !toggled;
}
}
public static void addWaypoint(String name, String x, String y, String z) {
BlockPos pos = new BlockPos(Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(z));
Waypoint waypoint = new Waypoint(name, pos);
waypoints.add(waypoint);
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Added " + waypoint.location + " @ " + waypoint.getPos()));
}
public static void addDSMWaypoints(String list, boolean auto) {
String[] waypointsList = list.split("\\\\n");
for (String waypoint : waypointsList) {
String[] parts = waypoint.split("@-");
String[] coords = parts[1].split(",");
String location = parts[0];
BlockPos pos = new BlockPos(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]));
Waypoint newWaypoint = new Waypoint(location, pos);
if (auto) {
boolean contains = false;
for (Waypoint existing : waypoints) {
if (existing.location.equals(location)) {
contains = true;
break;
}
}
if (contains) continue;
}
waypoints.add(newWaypoint);
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Added " + newWaypoint.location + " @ " + newWaypoint.getPos()));
}
}
}
|