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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
|
package de.hysky.skyblocker.skyblock;
import de.hysky.skyblocker.annotations.Init;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.dungeon.DungeonBoss;
import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Location;
import de.hysky.skyblocker.utils.Utils;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
import net.minecraft.block.*;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.Perspective;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.World;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SmoothAOTE {
private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
private static final Pattern MANA_LORE = Pattern.compile("Mana Cost: (\\d+)");
private static final long MAX_TELEPORT_TIME = 2500; //2.5 seconds
private static long startTime;
private static Vec3d startPos;
private static Vec3d cameraStartPos;
private static Vec3d teleportVector;
private static long lastPing;
private static long currentTeleportPing;
private static int teleportsAhead;
private static long lastTeleportTime;
public static boolean teleportDisabled;
@Init
public static void init() {
UseItemCallback.EVENT.register(SmoothAOTE::onItemInteract);
UseBlockCallback.EVENT.register(SmoothAOTE::onBlockInteract);
}
/**
* When a player receives a teleport packet finish a teleport
*/
public static void playerTeleported() {
//the player has been teleported so 1 less teleport ahead
teleportsAhead = Math.max(0, teleportsAhead - 1);
//re-enable the animation if the player is teleported as this means they can teleport again. and reset timer for last teleport update
lastTeleportTime = System.currentTimeMillis();
teleportDisabled = false;
//if the server is in sync in number of teleports
if (teleportsAhead == 0) {
//see if the teleport has a small amount left to continue animating instead of jumping to the end
long timeLeft = (currentTeleportPing - (System.currentTimeMillis() - startTime));
if (timeLeft > 0 && timeLeft <= SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.maximumAddedLag) {
return;
}
//reset when player has reached the end of the teleports
startPos = null;
teleportVector = null;
}
}
/**
* checks to see if a teleport device is using transmission tuner to increase the range
*
* @param customData the custom data of the teleport device
* @param baseRange the base range for the device without tuner
* @return the range with tuner
*/
private static int extractTunedCustomData(NbtCompound customData, int baseRange) {
return customData != null && customData.contains("tuned_transmission") ? baseRange + customData.getInt("tuned_transmission", 0) : baseRange;
}
/**
* When an item is right-clicked send off to calculate teleport with the clicked item
*
* @param playerEntity player
* @param world world
* @param hand held item
* @return pass
*/
private static ActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) {
if (CLIENT.player == null) {
return null;
}
calculateTeleportUse(hand);
return ActionResult.PASS;
}
/**
* Allows shovel teleport items to be used when aiming at interactable blocks
*
* @param playerEntity player
* @param world world
* @param hand hand item
* @param blockHitResult target block
* @return always pass
*/
private static ActionResult onBlockInteract(PlayerEntity playerEntity, World world, Hand hand, BlockHitResult blockHitResult) {
ItemStack itemStack = playerEntity.getStackInHand(hand);
if (isShovel(itemStack) && canShovelActOnBlock(world.getBlockState(blockHitResult.getBlockPos()).getBlock())) {
calculateTeleportUse(hand);
}
return ActionResult.PASS;
}
private static boolean isShovel(ItemStack itemStack) {
return itemStack.isOf(Items.WOODEN_SHOVEL) ||
itemStack.isOf(Items.STONE_SHOVEL) ||
itemStack.isOf(Items.IRON_SHOVEL) ||
itemStack.isOf(Items.GOLDEN_SHOVEL) ||
itemStack.isOf(Items.DIAMOND_SHOVEL);
}
/**
* Checks if the block is one that the shovel can turn into a path (e.g., grass or dirt)
*
* @param block block to check
* @return if block can be turned into path
*/
private static boolean canShovelActOnBlock(Block block) {
return block == Blocks.GRASS_BLOCK ||
block == Blocks.DIRT ||
block == Blocks.COARSE_DIRT ||
block == Blocks.PODZOL;
}
/**
* Finds if a player uses a teleport and then saves the start position and time. then works out final position and saves that too
*
* @param hand what the player is holding
*/
private static void calculateTeleportUse(Hand hand) {
//stop checking if player does not exist
if (CLIENT.player == null || CLIENT.world == null) {
return;
}
//get return item
ItemStack stack = CLIENT.player.getStackInHand(hand);
//make sure it's not disabled
if (teleportDisabled) {
return;
}
// make sure the camera is not in 3rd person
if (CLIENT.options.getPerspective() != Perspective.FIRST_PERSON) {
return;
}
//make sure the player is in an area teleporting is allowed not allowed in glacite mineshafts and floor 7 boss
if (!isAllowedLocation()) {
return;
}
//work out if the player is holding a teleporting item that is enabled and if so how far the item will take them
ItemStack heldItem = CLIENT.player.getMainHandStack();
String itemId = heldItem.getSkyblockId();
NbtCompound customData = ItemUtils.getCustomData(heldItem);
int distance;
switch (itemId) {
case "ASPECT_OF_THE_LEECH_1" -> {
if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWeirdTransmission) {
distance = 3;
break;
}
return;
}
case "ASPECT_OF_THE_LEECH_2" -> {
if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWeirdTransmission) {
distance = 4;
break;
}
return;
}
case "ASPECT_OF_THE_END", "ASPECT_OF_THE_VOID" -> {
if (CLIENT.options.sneakKey.isPressed() && customData.getInt("ethermerge", 0) == 1) {
if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableEtherTransmission) {
distance = extractTunedCustomData(customData, 57);
break;
}
} else if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableInstantTransmission) {
distance = extractTunedCustomData(customData, 8);
break;
}
return;
}
case "ETHERWARP_CONDUIT" -> {
if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableEtherTransmission) {
distance = extractTunedCustomData(customData, 57);
break;
}
return;
}
case "SINSEEKER_SCYTHE" -> {
if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableSinrecallTransmission) {
distance = extractTunedCustomData(customData, 4);
break;
}
return;
}
case "NECRON_BLADE", "ASTRAEA", "HYPERION", "SCYLLA", "VALKYRIE" -> {
if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWitherImpact) {
distance = 10;
break;
}
return;
}
default -> {
return;
}
}
//make sure the player has enough mana to do the teleport
Matcher manaNeeded = ItemUtils.getLoreLineIfMatch(heldItem, MANA_LORE);
if (manaNeeded != null && manaNeeded.matches()) {
int manaCost = Integer.parseInt(manaNeeded
|