From b876d0467bd4e976cd2e6ade6ca3d2518172eed5 Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 20 Aug 2024 19:59:45 +0100 Subject: [PATCH 01/46] init commit basics working just needs lots of polish --- .../hysky/skyblocker/mixins/CameraMixin.java | 23 ++++++ .../mixins/ClientPlayNetworkHandlerMixin.java | 8 ++ .../hysky/skyblocker/skyblock/SmoothAOTE.java | 77 +++++++++++++++++++ src/main/resources/skyblocker.mixins.json | 1 + 4 files changed, 109 insertions(+) create mode 100644 src/main/java/de/hysky/skyblocker/mixins/CameraMixin.java create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java diff --git a/src/main/java/de/hysky/skyblocker/mixins/CameraMixin.java b/src/main/java/de/hysky/skyblocker/mixins/CameraMixin.java new file mode 100644 index 0000000000..b916a5241d --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/mixins/CameraMixin.java @@ -0,0 +1,23 @@ +package de.hysky.skyblocker.mixins; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import de.hysky.skyblocker.skyblock.SmoothAOTE; +import net.minecraft.client.render.Camera; +import net.minecraft.util.math.Vec3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(Camera.class) +public class CameraMixin { + + @ModifyReturnValue(method = "getPos", at = @At("RETURN")) + private Vec3d skyblocker$onCameraUpdate(Vec3d original) { + + Vec3d pos = SmoothAOTE.getInterpolatedPos(); + if (pos != null) { + return pos; + } + + return original; + } +} diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index cd7c6ba3cb..b267df8522 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -7,6 +7,7 @@ import de.hysky.skyblocker.config.configs.SlayersConfig; import de.hysky.skyblocker.skyblock.CompactDamage; import de.hysky.skyblocker.skyblock.FishingHelper; +import de.hysky.skyblocker.skyblock.SmoothAOTE; import de.hysky.skyblocker.skyblock.chocolatefactory.EggFinder; import de.hysky.skyblocker.skyblock.crimson.dojo.DojoManager; import de.hysky.skyblocker.skyblock.dungeon.DungeonScore; @@ -31,6 +32,7 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; +import net.minecraft.util.math.Vec3d; import org.slf4j.Logger; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -150,4 +152,10 @@ public abstract class ClientPlayNetworkHandlerMixin { EnderNodes.onParticle(packet); WishingCompassSolver.onParticle(packet); } + + @Inject(method = "onPlayerPositionLook", at = @At("TAIL")) + private void onPlayerTeleported(PlayerPositionLookS2CPacket packet, CallbackInfo ci) { + //player has been teleported by the server tell the smooth aote this + SmoothAOTE.reset(); + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java new file mode 100644 index 0000000000..4a4ef0ebca --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -0,0 +1,77 @@ +package de.hysky.skyblocker.skyblock; + +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.fabricmc.fabric.api.event.player.UseItemCallback; +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +public class SmoothAOTE { + + private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); + + private static final int smoothTime = 100; // todo i would like this to be able to be your ping value + + private static long startTime; + private static Vec3d startPos; + private static Vec3d teleportVector; + + public static void init() { + UseItemCallback.EVENT.register(SmoothAOTE::onItemInteract); + } + + public static void reset() { + //reset when player has reached the end of the teleport + startPos = null; + teleportVector = null; + } + + + private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { + //todo add manna check + if (CLIENT.player == null) { + return null; + } + ItemStack stack = CLIENT.player.getStackInHand(hand); + //make sure the user is in the crystal hollows and holding the wishing compass + if (!stack.getSkyblockId().equals("ASPECT_OF_THE_END") && !stack.getSkyblockId().equals("ASPECT_OF_THE_VOID")) { + return TypedActionResult.pass(stack); + } + //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one + if (startPos == null || teleportVector == null) { + startPos = CLIENT.player.getEyePos(); + } else { + startPos = startPos.add(teleportVector); + System.out.println("this is doing somthing"); + } + startTime = System.currentTimeMillis(); + + // calculate the vector the player will follow for the teleport + //get direction + float pitch = CLIENT.player.getPitch(); + float yaw = CLIENT.player.getYaw(); + Vec3d look = CLIENT.player.getRotationVector(pitch, yaw); + //find target location depending on how far the item they are using takes them + teleportVector = look.multiply(12); + //compensate for pixel rounding the end position to x.5 y.62 z.5 + Vec3d predictedEnd = startPos.add(teleportVector); + Vec3d offset = new Vec3d(predictedEnd.x - (Math.floor(predictedEnd.x) + 0.5), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - (Math.floor(predictedEnd.z) + 0.5)); + teleportVector = teleportVector.subtract(offset); + + return TypedActionResult.pass(stack); + } + + public static Vec3d getInterpolatedPos() { + double percentage = Math.min((double) (System.currentTimeMillis() - startTime) / smoothTime, 1); + if (CLIENT.player == null || teleportVector == null || startPos == null) { + return null; + } + + return startPos.add(teleportVector.multiply(percentage)); + } +} diff --git a/src/main/resources/skyblocker.mixins.json b/src/main/resources/skyblocker.mixins.json index dc9d27cc43..20ef3807bd 100644 --- a/src/main/resources/skyblocker.mixins.json +++ b/src/main/resources/skyblocker.mixins.json @@ -7,6 +7,7 @@ "BackgroundRendererMixin", "BatEntityMixin", "BossBarHudMixin", + "CameraMixin", "ClientPlayerEntityMixin", "ClientPlayNetworkHandlerMixin", "ClientWorldMixin", From 771e37c385ea2be486b87600c6d50e6a74b120bd Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 20 Aug 2024 21:49:57 +0100 Subject: [PATCH 02/46] add setting and base teleport time on ping now constantly monitors ping and makes the teleport try to last as long as last ping packet recived --- .../categories/UIAndVisualsCategory.java | 13 +++++++++++ .../config/configs/UIAndVisualsConfig.java | 9 ++++++++ .../mixins/ClientPlayNetworkHandlerMixin.java | 10 +++++++++ .../skyblocker/mixins/PingMeasurerMixin.java | 3 +++ .../hysky/skyblocker/skyblock/SmoothAOTE.java | 22 ++++++++++++++----- .../assets/skyblocker/lang/en_us.json | 4 ++++ 6 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java index 6d18c45175..6147b0335e 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -397,6 +397,19 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .controller(ConfigUtils::createBooleanController) .build()) .build()) + //Smooth AOTE + .group(OptionGroup.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE")) + .collapsed(true) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enabled")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enabled.@Tooltip"))) + .binding(defaults.uiAndVisuals.smoothAOTE.enabled, + () -> config.uiAndVisuals.smoothAOTE.enabled, + newValue -> config.uiAndVisuals.smoothAOTE.enabled = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .build()) //Search overlay .group(OptionGroup.createBuilder() diff --git a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java index 7a6b3f5daa..2a6e1ce1f1 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -70,6 +70,9 @@ public class UIAndVisualsConfig { @SerialEntry public TeleportOverlay teleportOverlay = new TeleportOverlay(); + @SerialEntry + public SmoothAOTE smoothAOTE = new SmoothAOTE(); + @SerialEntry public SearchOverlay searchOverlay = new SearchOverlay(); @@ -328,6 +331,12 @@ public static class TeleportOverlay { public boolean enableWitherImpact = true; } + public static class SmoothAOTE { + @SerialEntry + public boolean enabled = true; + + } + public static class SearchOverlay { @SerialEntry public boolean enableBazaar = true; diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index b267df8522..3f468c8eeb 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -2,6 +2,8 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.config.configs.SlayersConfig; @@ -22,6 +24,8 @@ import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual; import de.hysky.skyblocker.utils.Utils; +import net.minecraft.block.Blocks; +import net.minecraft.client.gui.hud.DebugHud; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; @@ -158,4 +162,10 @@ private void onPlayerTeleported(PlayerPositionLookS2CPacket packet, CallbackInfo //player has been teleported by the server tell the smooth aote this SmoothAOTE.reset(); } + + @WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowPacketSizeAndPingCharts()Z")) + private boolean shouldShowPacketSizeAndPingCharts(DebugHud instance, Operation original) { + //make the f3+3 screen always send ping packets even when closed + return true; //todo config + } } diff --git a/src/main/java/de/hysky/skyblocker/mixins/PingMeasurerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/PingMeasurerMixin.java index 3273968690..d7431fd98a 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/PingMeasurerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/PingMeasurerMixin.java @@ -1,5 +1,7 @@ package de.hysky.skyblocker.mixins; +import de.hysky.skyblocker.config.configs.UIAndVisualsConfig; +import de.hysky.skyblocker.skyblock.SmoothAOTE; import de.hysky.skyblocker.skyblock.crimson.dojo.DojoManager; import de.hysky.skyblocker.utils.Utils; import net.minecraft.client.network.PingMeasurer; @@ -15,6 +17,7 @@ public class PingMeasurerMixin { if (Utils.isInCrimson()) { DojoManager.onPingResult(ping); } + SmoothAOTE.updatePing(ping); return ping; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 4a4ef0ebca..914f3674e1 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -1,7 +1,6 @@ package de.hysky.skyblocker.skyblock; -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; @@ -15,11 +14,12 @@ public class SmoothAOTE { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); - private static final int smoothTime = 100; // todo i would like this to be able to be your ping value + private static final long maxTeleportTime = 1000; private static long startTime; private static Vec3d startPos; private static Vec3d teleportVector; + private static long lastPing; public static void init() { UseItemCallback.EVENT.register(SmoothAOTE::onItemInteract); @@ -34,7 +34,8 @@ public static void reset() { private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { //todo add manna check - if (CLIENT.player == null) { + //stop checking if player does not exist or option is disabled + if (CLIENT.player == null || !SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enabled) { return null; } ItemStack stack = CLIENT.player.getStackInHand(hand); @@ -47,7 +48,6 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn startPos = CLIENT.player.getEyePos(); } else { startPos = startPos.add(teleportVector); - System.out.println("this is doing somthing"); } startTime = System.currentTimeMillis(); @@ -67,11 +67,21 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn } public static Vec3d getInterpolatedPos() { - double percentage = Math.min((double) (System.currentTimeMillis() - startTime) / smoothTime, 1); if (CLIENT.player == null || teleportVector == null || startPos == null) { return null; } + long gap = System.currentTimeMillis() - startTime; + //if teleport has taken over max time reset and return null + if (gap > maxTeleportTime) { + reset(); + return null; + } + double percentage = Math.min((double) (gap) / Math.min(lastPing, maxTeleportTime), 1); return startPos.add(teleportVector.multiply(percentage)); } + + public static void updatePing(long ping) { + lastPing = ping; + } } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 058b321de4..be3037da2a 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -887,6 +887,10 @@ "skyblocker.config.uiAndVisuals.showEquipmentInInventory": "Show Equipment in Inventory", + "skyblocker.config.uiAndVisuals.smoothAOTE": "Smooth AOTE", + "skyblocker.config.uiAndVisuals.smoothAOTE.enabled": "Enable smoothing when using teleport ability's", + + "skyblocker.config.uiAndVisuals.tabHud": "Fancy HUD and TAB", "skyblocker.config.uiAndVisuals.tabHud.configScreen": "Open Config Screen", "skyblocker.config.uiAndVisuals.tabHud.defaultPositioning": "Default Positioning Behavior", From 4656e0ac5b1ade78a92455451c92d841f50505e1 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 22 Aug 2024 21:32:08 +0100 Subject: [PATCH 03/46] add settings for each wepon type and work with each of them --- .../categories/UIAndVisualsCategory.java | 35 +++++++++ .../config/configs/UIAndVisualsConfig.java | 15 ++++ .../hysky/skyblocker/skyblock/SmoothAOTE.java | 73 +++++++++++++++++-- .../assets/skyblocker/lang/en_us.json | 8 +- 4 files changed, 125 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java index 6147b0335e..b5b8ed844e 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -409,6 +409,41 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.uiAndVisuals.smoothAOTE.enabled = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission")) + .binding(defaults.uiAndVisuals.smoothAOTE.enableWeirdTransmission, + () -> config.uiAndVisuals.smoothAOTE.enableWeirdTransmission, + newValue -> config.uiAndVisuals.smoothAOTE.enableWeirdTransmission = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission")) + .binding(defaults.uiAndVisuals.smoothAOTE.enableInstantTransmission, + () -> config.uiAndVisuals.smoothAOTE.enableInstantTransmission, + newValue -> config.uiAndVisuals.smoothAOTE.enableInstantTransmission = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission")) + .binding(defaults.uiAndVisuals.smoothAOTE.enableEtherTransmission, + () -> config.uiAndVisuals.smoothAOTE.enableEtherTransmission, + newValue -> config.uiAndVisuals.smoothAOTE.enableEtherTransmission = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission")) + .binding(defaults.uiAndVisuals.smoothAOTE.enableSinrecallTransmission, + () -> config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission, + newValue -> config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact")) + .binding(defaults.uiAndVisuals.smoothAOTE.enableWitherImpact, + () -> config.uiAndVisuals.smoothAOTE.enableWitherImpact, + newValue -> config.uiAndVisuals.smoothAOTE.enableWitherImpact = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .build()) //Search overlay diff --git a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java index 2a6e1ce1f1..a1c7246cd0 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -335,6 +335,21 @@ public static class SmoothAOTE { @SerialEntry public boolean enabled = true; + @SerialEntry + public boolean enableWeirdTransmission = true; + + @SerialEntry + public boolean enableInstantTransmission = true; + + @SerialEntry + public boolean enableEtherTransmission = true; + + @SerialEntry + public boolean enableSinrecallTransmission = true; + + @SerialEntry + public boolean enableWitherImpact = true; + } public static class SearchOverlay { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 914f3674e1..a7af7a4ec5 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -1,10 +1,12 @@ package de.hysky.skyblocker.skyblock; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.ItemUtils; import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NbtCompound; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.Vec3d; @@ -31,18 +33,79 @@ public static void reset() { teleportVector = null; } + private static int extractTeleporterCustomData(NbtCompound customData, int baseRange) { + return customData != null && customData.contains("tuned_transmission") ? baseRange + customData.getInt("tuned_transmission") : baseRange; + } + private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { //todo add manna check - //stop checking if player does not exist or option is disabled - if (CLIENT.player == null || !SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enabled) { + //stop checking if player does not exist + if (CLIENT.player == null) { return null; } + //get return item ItemStack stack = CLIENT.player.getStackInHand(hand); - //make sure the user is in the crystal hollows and holding the wishing compass - if (!stack.getSkyblockId().equals("ASPECT_OF_THE_END") && !stack.getSkyblockId().equals("ASPECT_OF_THE_VOID")) { + if (!SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enabled) { return TypedActionResult.pass(stack); } + + //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 = 0; + switch (itemId) { + case "ASPECT_OF_THE_LEECH_1" -> { + if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWeirdTransmission) { + distance = 3; + } else { + return TypedActionResult.pass(stack); + } + } + case "ASPECT_OF_THE_LEECH_2" -> { + if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWeirdTransmission) { + distance = 4; + } else { + return TypedActionResult.pass(stack); + } + } + case "ASPECT_OF_THE_END", "ASPECT_OF_THE_VOID" -> { + if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableEtherTransmission && CLIENT.options.sneakKey.isPressed() && customData.getInt("ethermerge") == 1) { + distance = extractTeleporterCustomData(customData, 57); + } else if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableInstantTransmission) { + distance = extractTeleporterCustomData(customData, 8); + } else { + return TypedActionResult.pass(stack); + } + } + case "ETHERWARP_CONDUIT" -> { + if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableEtherTransmission) { + distance = extractTeleporterCustomData(customData, 57); + } else { + return TypedActionResult.pass(stack); + } + } + case "SINSEEKER_SCYTHE" -> { + if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableSinrecallTransmission) { + distance = extractTeleporterCustomData(customData, 4); + } else { + return TypedActionResult.pass(stack); + } + } + case "NECRON_BLADE", "ASTRAEA", "HYPERION", "SCYLLA", "VALKYRIE" -> { + if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWitherImpact) { + distance = 10; + } else { + return TypedActionResult.pass(stack); + } + } + default -> { + return TypedActionResult.pass(stack); + } + } + + //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one if (startPos == null || teleportVector == null) { startPos = CLIENT.player.getEyePos(); @@ -57,7 +120,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn float yaw = CLIENT.player.getYaw(); Vec3d look = CLIENT.player.getRotationVector(pitch, yaw); //find target location depending on how far the item they are using takes them - teleportVector = look.multiply(12); + teleportVector = look.multiply(distance); //compensate for pixel rounding the end position to x.5 y.62 z.5 Vec3d predictedEnd = startPos.add(teleportVector); Vec3d offset = new Vec3d(predictedEnd.x - (Math.floor(predictedEnd.x) + 0.5), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - (Math.floor(predictedEnd.z) + 0.5)); diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index be3037da2a..a749b51761 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -888,7 +888,13 @@ "skyblocker.config.uiAndVisuals.showEquipmentInInventory": "Show Equipment in Inventory", "skyblocker.config.uiAndVisuals.smoothAOTE": "Smooth AOTE", - "skyblocker.config.uiAndVisuals.smoothAOTE.enabled": "Enable smoothing when using teleport ability's", + "skyblocker.config.uiAndVisuals.smoothAOTE.enabled": "Enable Teleport Smoothing", + "skyblocker.config.uiAndVisuals.smoothAOTE.enabled.@Tooltip": "Toggle teleport smoothing for all teleporting methods", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission": "Enable Ether Transmission", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission": "Enable Instant Transmission ", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission": "Enable Sinrecall Transmission", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission": "Enable Weird Transmission", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact": "Enable Wither Impact", "skyblocker.config.uiAndVisuals.tabHud": "Fancy HUD and TAB", From 7e234846ce7cc9305c5975ea03cbe3ff24c3ff2b Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 26 Aug 2024 22:16:42 +0100 Subject: [PATCH 04/46] add raycast add raycast so predicted camera can not go though walls. could use improvement this is not how it is done exactly on hypixels side --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index a7af7a4ec5..362c1c26be 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -9,7 +9,11 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.RaycastContext; import net.minecraft.world.World; public class SmoothAOTE { @@ -41,7 +45,7 @@ private static int extractTeleporterCustomData(NbtCompound customData, int baseR private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { //todo add manna check //stop checking if player does not exist - if (CLIENT.player == null) { + if (CLIENT.player == null || CLIENT.world == null) { return null; } //get return item @@ -105,7 +109,6 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn } } - //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one if (startPos == null || teleportVector == null) { startPos = CLIENT.player.getEyePos(); @@ -121,10 +124,21 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn Vec3d look = CLIENT.player.getRotationVector(pitch, yaw); //find target location depending on how far the item they are using takes them teleportVector = look.multiply(distance); + //make sure there are no blocks in the way and if so account for this + BlockHitResult hitResult = world.raycast(new RaycastContext(startPos, startPos.add(teleportVector), RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, CLIENT.player)); + if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) { + Vec3d offsetEndPos; + if (hitResult.getSide().equals(Direction.UP) || hitResult.getSide().equals(Direction.DOWN)) { + offsetEndPos = hitResult.getPos().offset(hitResult.getSide(), 1); + } else { + offsetEndPos = hitResult.getPos().offset(hitResult.getSide(), 0.5); + } + teleportVector = offsetEndPos.subtract(startPos); + } //compensate for pixel rounding the end position to x.5 y.62 z.5 Vec3d predictedEnd = startPos.add(teleportVector); - Vec3d offset = new Vec3d(predictedEnd.x - (Math.floor(predictedEnd.x) + 0.5), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - (Math.floor(predictedEnd.z) + 0.5)); - teleportVector = teleportVector.subtract(offset); + Vec3d offsetVec = new Vec3d(predictedEnd.x - (Math.floor(predictedEnd.x) + 0.5), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - (Math.floor(predictedEnd.z) + 0.5)); + teleportVector = teleportVector.subtract(offsetVec); return TypedActionResult.pass(stack); } From a77ff2a829aaadc12df7fadeb8bc9771a0e374fd Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 27 Aug 2024 12:14:56 +0100 Subject: [PATCH 05/46] cheak the players mana before assuming they can teleport --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 362c1c26be..4c586c9d29 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -1,12 +1,16 @@ package de.hysky.skyblocker.skyblock; +import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.ItemUtils; +import de.hysky.skyblocker.utils.Utils; import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; +import net.minecraft.nbt.NbtList; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.util.hit.BlockHitResult; @@ -15,11 +19,16 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.RaycastContext; import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +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 maxTeleportTime = 1000; private static long startTime; @@ -41,9 +50,7 @@ private static int extractTeleporterCustomData(NbtCompound customData, int baseR return customData != null && customData.contains("tuned_transmission") ? baseRange + customData.getInt("tuned_transmission") : baseRange; } - private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { - //todo add manna check //stop checking if player does not exist if (CLIENT.player == null || CLIENT.world == null) { return null; @@ -58,6 +65,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn ItemStack heldItem = CLIENT.player.getMainHandStack(); String itemId = heldItem.getSkyblockId(); NbtCompound customData = ItemUtils.getCustomData(heldItem); + int distance = 0; switch (itemId) { case "ASPECT_OF_THE_LEECH_1" -> { @@ -108,6 +116,13 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn return TypedActionResult.pass(stack); } } + //make sure the player has enough mana to do the teleport + Matcher manaNeeded = ItemUtils.getLoreLineIfMatch(heldItem,MANA_LORE); + if (manaNeeded != null && manaNeeded.matches()) { + if (SkyblockerMod.getInstance().statusBarTracker.getMana().value() < Integer.parseInt(manaNeeded.group(1))) { // todo the players mana can lag behind as it is updated server side. client side mana calculations would help with this + return TypedActionResult.pass(stack); + } + } //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one if (startPos == null || teleportVector == null) { From 2303ee783f19fe5bc73d1e5f014bcc6d06677d84 Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 27 Aug 2024 12:36:30 +0100 Subject: [PATCH 06/46] remove un needed setting and update settings --- .../config/categories/UIAndVisualsCategory.java | 9 +-------- .../skyblocker/config/configs/UIAndVisualsConfig.java | 2 -- .../mixins/ClientPlayNetworkHandlerMixin.java | 6 ++++-- .../java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 11 ++--------- src/main/resources/assets/skyblocker/lang/en_us.json | 3 +-- 5 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java index b5b8ed844e..6dfdd80e2e 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -400,15 +400,8 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig //Smooth AOTE .group(OptionGroup.createBuilder() .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.@Tooltip"))) .collapsed(true) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enabled")) - .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enabled.@Tooltip"))) - .binding(defaults.uiAndVisuals.smoothAOTE.enabled, - () -> config.uiAndVisuals.smoothAOTE.enabled, - newValue -> config.uiAndVisuals.smoothAOTE.enabled = newValue) - .controller(ConfigUtils::createBooleanController) - .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission")) .binding(defaults.uiAndVisuals.smoothAOTE.enableWeirdTransmission, diff --git a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java index a1c7246cd0..828bf39427 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -332,8 +332,6 @@ public static class TeleportOverlay { } public static class SmoothAOTE { - @SerialEntry - public boolean enabled = true; @SerialEntry public boolean enableWeirdTransmission = true; diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index 3f468c8eeb..21e2036c72 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -159,13 +159,15 @@ public abstract class ClientPlayNetworkHandlerMixin { @Inject(method = "onPlayerPositionLook", at = @At("TAIL")) private void onPlayerTeleported(PlayerPositionLookS2CPacket packet, CallbackInfo ci) { - //player has been teleported by the server tell the smooth aote this + //player has been teleported by the server tell the smooth AOTE this SmoothAOTE.reset(); } @WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowPacketSizeAndPingCharts()Z")) private boolean shouldShowPacketSizeAndPingCharts(DebugHud instance, Operation original) { //make the f3+3 screen always send ping packets even when closed - return true; //todo config + //this is needed to make smooth AOTE work + return true; + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 4c586c9d29..bcab354277 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -3,14 +3,11 @@ import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.ItemUtils; -import de.hysky.skyblocker.utils.Utils; import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; -import net.minecraft.nbt.NbtList; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.util.hit.BlockHitResult; @@ -19,7 +16,6 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.RaycastContext; import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -57,16 +53,13 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn } //get return item ItemStack stack = CLIENT.player.getStackInHand(hand); - if (!SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enabled) { - return TypedActionResult.pass(stack); - } //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 = 0; + int distance; switch (itemId) { case "ASPECT_OF_THE_LEECH_1" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWeirdTransmission) { @@ -117,7 +110,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn } } //make sure the player has enough mana to do the teleport - Matcher manaNeeded = ItemUtils.getLoreLineIfMatch(heldItem,MANA_LORE); + Matcher manaNeeded = ItemUtils.getLoreLineIfMatch(heldItem, MANA_LORE); if (manaNeeded != null && manaNeeded.matches()) { if (SkyblockerMod.getInstance().statusBarTracker.getMana().value() < Integer.parseInt(manaNeeded.group(1))) { // todo the players mana can lag behind as it is updated server side. client side mana calculations would help with this return TypedActionResult.pass(stack); diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index a749b51761..481569b305 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -888,8 +888,7 @@ "skyblocker.config.uiAndVisuals.showEquipmentInInventory": "Show Equipment in Inventory", "skyblocker.config.uiAndVisuals.smoothAOTE": "Smooth AOTE", - "skyblocker.config.uiAndVisuals.smoothAOTE.enabled": "Enable Teleport Smoothing", - "skyblocker.config.uiAndVisuals.smoothAOTE.enabled.@Tooltip": "Toggle teleport smoothing for all teleporting methods", + "skyblocker.config.uiAndVisuals.smoothAOTE.@Tooltip": "Smooth out teleporting with right click teleport ability's", "skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission": "Enable Ether Transmission", "skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission": "Enable Instant Transmission ", "skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission": "Enable Sinrecall Transmission", From 8a4450ce888ad47028d71ed2d88c828c7443a5a1 Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 27 Aug 2024 21:37:12 +0100 Subject: [PATCH 07/46] add java docs and 3rd person check --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index bcab354277..60f4ea686d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -5,6 +5,7 @@ import de.hysky.skyblocker.utils.ItemUtils; import net.fabricmc.fabric.api.event.player.UseItemCallback; 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.nbt.NbtCompound; @@ -42,13 +43,29 @@ public static void reset() { teleportVector = null; } - private static int extractTeleporterCustomData(NbtCompound customData, int baseRange) { + /** + * 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") : baseRange; } + /** + * 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 playerEntity the player + * @param world the world + * @param hand what the player is holding + * @return if the right click should go though + */ + private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { - //stop checking if player does not exist - if (CLIENT.player == null || CLIENT.world == null) { + //stop checking if player does not exist or is in 3d person + if (CLIENT.player == null || CLIENT.world == null || CLIENT.options.getPerspective() != Perspective.FIRST_PERSON) { return null; } //get return item @@ -77,23 +94,23 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn } case "ASPECT_OF_THE_END", "ASPECT_OF_THE_VOID" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableEtherTransmission && CLIENT.options.sneakKey.isPressed() && customData.getInt("ethermerge") == 1) { - distance = extractTeleporterCustomData(customData, 57); + distance = extractTunedCustomData(customData, 57); } else if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableInstantTransmission) { - distance = extractTeleporterCustomData(customData, 8); + distance = extractTunedCustomData(customData, 8); } else { return TypedActionResult.pass(stack); } } case "ETHERWARP_CONDUIT" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableEtherTransmission) { - distance = extractTeleporterCustomData(customData, 57); + distance = extractTunedCustomData(customData, 57); } else { return TypedActionResult.pass(stack); } } case "SINSEEKER_SCYTHE" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableSinrecallTransmission) { - distance = extractTeleporterCustomData(customData, 4); + distance = extractTunedCustomData(customData, 4); } else { return TypedActionResult.pass(stack); } @@ -151,6 +168,12 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn return TypedActionResult.pass(stack); } + /** + * works out where they player should be based on how far though the predicted teleport time. + * + * @return the camera position for the interpolated pos + */ + public static Vec3d getInterpolatedPos() { if (CLIENT.player == null || teleportVector == null || startPos == null) { return null; From 1b5fa2c7de34eaf9418f0ee07fc6ed0927c28d78 Mon Sep 17 00:00:00 2001 From: olim Date: Wed, 28 Aug 2024 10:55:47 +0100 Subject: [PATCH 08/46] clean --- .../de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java | 1 - src/main/java/de/hysky/skyblocker/mixins/CameraMixin.java | 1 - .../hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java | 1 - src/main/java/de/hysky/skyblocker/mixins/PingMeasurerMixin.java | 1 - src/main/resources/assets/skyblocker/lang/en_us.json | 2 +- 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java index 828bf39427..7ee27459e6 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -347,7 +347,6 @@ public static class SmoothAOTE { @SerialEntry public boolean enableWitherImpact = true; - } public static class SearchOverlay { diff --git a/src/main/java/de/hysky/skyblocker/mixins/CameraMixin.java b/src/main/java/de/hysky/skyblocker/mixins/CameraMixin.java index b916a5241d..78d9e547fe 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/CameraMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/CameraMixin.java @@ -12,7 +12,6 @@ public class CameraMixin { @ModifyReturnValue(method = "getPos", at = @At("RETURN")) private Vec3d skyblocker$onCameraUpdate(Vec3d original) { - Vec3d pos = SmoothAOTE.getInterpolatedPos(); if (pos != null) { return pos; diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index 21e2036c72..f667ee7f58 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -36,7 +36,6 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; -import net.minecraft.util.math.Vec3d; import org.slf4j.Logger; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/de/hysky/skyblocker/mixins/PingMeasurerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/PingMeasurerMixin.java index d7431fd98a..b09abc64b1 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/PingMeasurerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/PingMeasurerMixin.java @@ -1,6 +1,5 @@ package de.hysky.skyblocker.mixins; -import de.hysky.skyblocker.config.configs.UIAndVisualsConfig; import de.hysky.skyblocker.skyblock.SmoothAOTE; import de.hysky.skyblocker.skyblock.crimson.dojo.DojoManager; import de.hysky.skyblocker.utils.Utils; diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 481569b305..b3b1d09dc0 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -888,7 +888,7 @@ "skyblocker.config.uiAndVisuals.showEquipmentInInventory": "Show Equipment in Inventory", "skyblocker.config.uiAndVisuals.smoothAOTE": "Smooth AOTE", - "skyblocker.config.uiAndVisuals.smoothAOTE.@Tooltip": "Smooth out teleporting with right click teleport ability's", + "skyblocker.config.uiAndVisuals.smoothAOTE.@Tooltip": "Smooths out teleporting with right click teleport ability's", "skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission": "Enable Ether Transmission", "skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission": "Enable Instant Transmission ", "skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission": "Enable Sinrecall Transmission", From 0b631a012d69607224f0a271f07120a223dd5ac2 Mon Sep 17 00:00:00 2001 From: olim Date: Wed, 28 Aug 2024 11:05:20 +0100 Subject: [PATCH 09/46] fix 3rd person check --- .../java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 60f4ea686d..43cf3e4b1a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -64,13 +64,18 @@ private static int extractTunedCustomData(NbtCompound customData, int baseRange) */ private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { - //stop checking if player does not exist or is in 3d person - if (CLIENT.player == null || CLIENT.world == null || CLIENT.options.getPerspective() != Perspective.FIRST_PERSON) { + //stop checking if player does not exist + if (CLIENT.player == null || CLIENT.world == null) { return null; } //get return item ItemStack stack = CLIENT.player.getStackInHand(hand); + // make sure the camera is not in 3rd person + if ( CLIENT.options.getPerspective() != Perspective.FIRST_PERSON) { + return TypedActionResult.pass(stack); + } + //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(); From 8f2ec20b8920cc7e98a540f51ccdbdec20f2d8e8 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 29 Aug 2024 11:19:45 +0100 Subject: [PATCH 10/46] apply suggested changes --- .../skyblocker/mixins/ClientPlayNetworkHandlerMixin.java | 5 ++++- .../java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 8 ++++---- src/main/resources/assets/skyblocker/lang/en_us.json | 5 +++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index f667ee7f58..6e371524cd 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -166,7 +166,10 @@ private void onPlayerTeleported(PlayerPositionLookS2CPacket packet, CallbackInfo private boolean shouldShowPacketSizeAndPingCharts(DebugHud instance, Operation original) { //make the f3+3 screen always send ping packets even when closed //this is needed to make smooth AOTE work - return true; + if (Utils.isOnSkyblock()) { + return true; + } + return original.call(); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 43cf3e4b1a..392b01631d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -26,7 +26,7 @@ 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 maxTeleportTime = 1000; + private static final long MAX_TELEPORT_TIME = 1000; private static long startTime; private static Vec3d startPos; @@ -72,7 +72,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn ItemStack stack = CLIENT.player.getStackInHand(hand); // make sure the camera is not in 3rd person - if ( CLIENT.options.getPerspective() != Perspective.FIRST_PERSON) { + if (CLIENT.options.getPerspective() != Perspective.FIRST_PERSON) { return TypedActionResult.pass(stack); } @@ -185,11 +185,11 @@ public static Vec3d getInterpolatedPos() { } long gap = System.currentTimeMillis() - startTime; //if teleport has taken over max time reset and return null - if (gap > maxTeleportTime) { + if (gap > MAX_TELEPORT_TIME) { reset(); return null; } - double percentage = Math.min((double) (gap) / Math.min(lastPing, maxTeleportTime), 1); + double percentage = Math.min((double) (gap) / Math.min(lastPing, MAX_TELEPORT_TIME), 1); return startPos.add(teleportVector.multiply(percentage)); } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index b3b1d09dc0..2a48061391 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -890,10 +890,15 @@ "skyblocker.config.uiAndVisuals.smoothAOTE": "Smooth AOTE", "skyblocker.config.uiAndVisuals.smoothAOTE.@Tooltip": "Smooths out teleporting with right click teleport ability's", "skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission": "Enable Ether Transmission", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission.@Tooltip": "for: Etherwarp Conduit and Ether Merged", "skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission": "Enable Instant Transmission ", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission.@Tooltip": "for: AOTE and AOTV ", "skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission": "Enable Sinrecall Transmission", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission.@Tooltip": "for: Sinseeker Scythe", "skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission": "Enable Weird Transmission", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission.@Tooltip": "for: Aspect of the Leech 1 and 2", "skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact": "Enable Wither Impact", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact.@Tooltip": "for: Necron Blade, Hyperion, Scylla, Valkyrie", "skyblocker.config.uiAndVisuals.tabHud": "Fancy HUD and TAB", From 8c48a444db7a878a468148ee1631b6ee1a6da620 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 29 Aug 2024 11:28:28 +0100 Subject: [PATCH 11/46] do not allow when invalid location --- .../java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 392b01631d..348cb4c605 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -2,7 +2,10 @@ import de.hysky.skyblocker.SkyblockerMod; 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.Utils; import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.Perspective; @@ -76,6 +79,11 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn return TypedActionResult.pass(stack); } + //make sure the player is in an area teleporting is allowed not allowed in glacite mineshafts and floor 7 boss + if (Utils.getMap().equals("Glacite Mineshafts") || (Utils.isInDungeons() && DungeonManager.isInBoss() && DungeonManager.getBoss() == DungeonBoss.MAXOR)) { + return TypedActionResult.pass(stack); + } + //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(); From bf1e7d66b1aafce3297c9520bb6d57928fa21f50 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 29 Aug 2024 11:35:16 +0100 Subject: [PATCH 12/46] fix etherwarp logic using wrong tp --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 348cb4c605..03bdb5e61e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -94,46 +94,50 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn case "ASPECT_OF_THE_LEECH_1" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWeirdTransmission) { distance = 3; - } else { - return TypedActionResult.pass(stack); + break; } + return TypedActionResult.pass(stack); + } case "ASPECT_OF_THE_LEECH_2" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWeirdTransmission) { distance = 4; - } else { - return TypedActionResult.pass(stack); + break; } + return TypedActionResult.pass(stack); } case "ASPECT_OF_THE_END", "ASPECT_OF_THE_VOID" -> { - if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableEtherTransmission && CLIENT.options.sneakKey.isPressed() && customData.getInt("ethermerge") == 1) { - distance = extractTunedCustomData(customData, 57); + if (CLIENT.options.sneakKey.isPressed() && customData.getInt("ethermerge") == 1) { + if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableEtherTransmission) { + distance = extractTunedCustomData(customData, 57); + break; + } } else if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableInstantTransmission) { distance = extractTunedCustomData(customData, 8); - } else { - return TypedActionResult.pass(stack); + break; } + return TypedActionResult.pass(stack); } case "ETHERWARP_CONDUIT" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableEtherTransmission) { distance = extractTunedCustomData(customData, 57); - } else { - return TypedActionResult.pass(stack); + break; } + return TypedActionResult.pass(stack); } case "SINSEEKER_SCYTHE" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableSinrecallTransmission) { distance = extractTunedCustomData(customData, 4); - } else { - return TypedActionResult.pass(stack); + break; } + return TypedActionResult.pass(stack); } case "NECRON_BLADE", "ASTRAEA", "HYPERION", "SCYLLA", "VALKYRIE" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWitherImpact) { distance = 10; - } else { - return TypedActionResult.pass(stack); + break; } + return TypedActionResult.pass(stack); } default -> { return TypedActionResult.pass(stack); From a55b0d4632a2136a675724eaeaea8f421a671fdd Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 29 Aug 2024 11:37:41 +0100 Subject: [PATCH 13/46] add tooltips to options --- .../skyblocker/config/categories/UIAndVisualsCategory.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java index 6dfdd80e2e..227e1ae7e4 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -397,6 +397,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .controller(ConfigUtils::createBooleanController) .build()) .build()) + //Smooth AOTE .group(OptionGroup.createBuilder() .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE")) @@ -404,6 +405,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .collapsed(true) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission.@Tooltip"))) .binding(defaults.uiAndVisuals.smoothAOTE.enableWeirdTransmission, () -> config.uiAndVisuals.smoothAOTE.enableWeirdTransmission, newValue -> config.uiAndVisuals.smoothAOTE.enableWeirdTransmission = newValue) @@ -411,6 +413,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission.@Tooltip"))) .binding(defaults.uiAndVisuals.smoothAOTE.enableInstantTransmission, () -> config.uiAndVisuals.smoothAOTE.enableInstantTransmission, newValue -> config.uiAndVisuals.smoothAOTE.enableInstantTransmission = newValue) @@ -418,6 +421,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission.@Tooltip"))) .binding(defaults.uiAndVisuals.smoothAOTE.enableEtherTransmission, () -> config.uiAndVisuals.smoothAOTE.enableEtherTransmission, newValue -> config.uiAndVisuals.smoothAOTE.enableEtherTransmission = newValue) @@ -425,6 +429,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission.@Tooltip"))) .binding(defaults.uiAndVisuals.smoothAOTE.enableSinrecallTransmission, () -> config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission, newValue -> config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission = newValue) @@ -432,6 +437,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact.@Tooltip"))) .binding(defaults.uiAndVisuals.smoothAOTE.enableWitherImpact, () -> config.uiAndVisuals.smoothAOTE.enableWitherImpact, newValue -> config.uiAndVisuals.smoothAOTE.enableWitherImpact = newValue) From 36d72b2f1ea718e62128b6c98070500b16e6638f Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 29 Aug 2024 11:46:33 +0100 Subject: [PATCH 14/46] fix : click too fast cause the animation break adds counter for how many teleports ahead the player is to the server so receiving a teleport for an old use will not reset the camera --- .../mixins/ClientPlayNetworkHandlerMixin.java | 2 +- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 21 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index 6e371524cd..bb8cbb9ea7 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -159,7 +159,7 @@ public abstract class ClientPlayNetworkHandlerMixin { @Inject(method = "onPlayerPositionLook", at = @At("TAIL")) private void onPlayerTeleported(PlayerPositionLookS2CPacket packet, CallbackInfo ci) { //player has been teleported by the server tell the smooth AOTE this - SmoothAOTE.reset(); + SmoothAOTE.playerTeleported(); } @WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowPacketSizeAndPingCharts()Z")) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 03bdb5e61e..62a8471ef6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -35,15 +35,23 @@ public class SmoothAOTE { private static Vec3d startPos; private static Vec3d teleportVector; private static long lastPing; + private static int teleportsAhead; public static void init() { UseItemCallback.EVENT.register(SmoothAOTE::onItemInteract); } - public static void reset() { - //reset when player has reached the end of the teleport - startPos = null; - teleportVector = null; + public static void playerTeleported() { + //the player has been teleported so 1 less teleport ahead + teleportsAhead = Math.max(0, teleportsAhead - 1); + + //if the server is in sync in number of teleports + if (teleportsAhead == 0) { + //reset when player has reached the end of the teleports + startPos = null; + teleportVector = null; + } + } /** @@ -182,6 +190,9 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn Vec3d offsetVec = new Vec3d(predictedEnd.x - (Math.floor(predictedEnd.x) + 0.5), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - (Math.floor(predictedEnd.z) + 0.5)); teleportVector = teleportVector.subtract(offsetVec); + //add 1 to teleports ahead + teleportsAhead += 1; + return TypedActionResult.pass(stack); } @@ -198,7 +209,7 @@ public static Vec3d getInterpolatedPos() { long gap = System.currentTimeMillis() - startTime; //if teleport has taken over max time reset and return null if (gap > MAX_TELEPORT_TIME) { - reset(); + playerTeleported(); return null; } double percentage = Math.min((double) (gap) / Math.min(lastPing, MAX_TELEPORT_TIME), 1); From 2f5cc8fd8828c3d2961d0501aab8c3e54f605fd1 Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Thu, 29 Aug 2024 16:16:01 +0200 Subject: [PATCH 15/46] fix mixin --- .../hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index bb8cbb9ea7..064dba2900 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -169,7 +169,7 @@ private boolean shouldShowPacketSizeAndPingCharts(DebugHud instance, Operation Date: Thu, 29 Aug 2024 22:33:16 +0100 Subject: [PATCH 16/46] add more disabled locations and fix for not coded disabled locations adds other suggested locations to disable but also a timer for if the go to long without the server teleporting them assuming that its disabled and not working until they are teleported again --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 65 +++++++++++++++++-- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 62a8471ef6..f8e159f088 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -5,6 +5,7 @@ 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.UseItemCallback; import net.minecraft.client.MinecraftClient; @@ -29,13 +30,15 @@ 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 = 1000; + private static final long MAX_TELEPORT_TIME = 2500; //2.5 seconds private static long startTime; private static Vec3d startPos; private static Vec3d teleportVector; private static long lastPing; private static int teleportsAhead; + private static long lastTeleportTime; + private static boolean teleportDisabled; public static void init() { UseItemCallback.EVENT.register(SmoothAOTE::onItemInteract); @@ -44,6 +47,9 @@ public static void init() { 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) { @@ -88,7 +94,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn } //make sure the player is in an area teleporting is allowed not allowed in glacite mineshafts and floor 7 boss - if (Utils.getMap().equals("Glacite Mineshafts") || (Utils.isInDungeons() && DungeonManager.isInBoss() && DungeonManager.getBoss() == DungeonBoss.MAXOR)) { + if (!isAllowedLocation()) { return TypedActionResult.pass(stack); } @@ -161,10 +167,14 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one if (startPos == null || teleportVector == null) { + //start of teleport sequence startPos = CLIENT.player.getEyePos(); + lastTeleportTime = System.currentTimeMillis(); } else { + //add to the end of the teleport sequence startPos = startPos.add(teleportVector); } + startTime = System.currentTimeMillis(); // calculate the vector the player will follow for the teleport @@ -196,6 +206,46 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn return TypedActionResult.pass(stack); } + /** + * Works out if the players location lets them use teleportation or not + * + * @return if the player should be allowed to teleport + */ + private static boolean isAllowedLocation() { + //check mines shafts + if (Utils.getMap().equals("Mineshaft")) { + return false; + } else if (Utils.getIslandArea().equals("⏣ Jungle Temple")) { //do not allow in jungle temple + return false; + } else if (Utils.getLocation() == Location.PRIVATE_ISLAND && !Utils.getIslandArea().equals("⏣ Your Island")) { //do not allow it when visiting + return false; + } else if (Utils.getLocation() == Location.PRIVATE_ISLAND && !Utils.getIslandArea().equals("⏣ Your Island")) { //do not allow it when visiting garden + return false; + } else if (Utils.isInDungeons()) { //check places in dungeons where you can't teleport + if (DungeonManager.isInBoss() && DungeonManager.getBoss() == DungeonBoss.MAXOR) { + return false; + } + //make sure the player is in a room then check for disallowed rooms + if (!DungeonManager.isCurrentRoomMatched()) { + return true; + } + //does not work in boulder room + if (DungeonManager.getCurrentRoom().getName().equals("boxes-room")) { + return false; + } + //does not work in teleport maze room + if (DungeonManager.getCurrentRoom().getName().equals("teleport-pad-room")) { + return false; + } + //does not work in trap room + if (DungeonManager.getCurrentRoom().getName().startsWith("trap")) { + return false; + } + } + + return true; + } + /** * works out where they player should be based on how far though the predicted teleport time. * @@ -203,13 +253,16 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn */ public static Vec3d getInterpolatedPos() { - if (CLIENT.player == null || teleportVector == null || startPos == null) { + if (CLIENT.player == null || teleportVector == null || startPos == null || teleportDisabled) { return null; } long gap = System.currentTimeMillis() - startTime; - //if teleport has taken over max time reset and return null - if (gap > MAX_TELEPORT_TIME) { - playerTeleported(); + //make sure the player is actually getting teleported if not disable teleporting until they are teleported again + if (System.currentTimeMillis() - lastTeleportTime > MAX_TELEPORT_TIME) { + teleportDisabled = true; + startPos = null; + teleportVector = null; + teleportsAhead = 0; return null; } double percentage = Math.min((double) (gap) / Math.min(lastPing, MAX_TELEPORT_TIME), 1); From 5158fd692a2691ad60d2bd8bc26beb5e8de948e4 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 30 Aug 2024 12:01:44 +0100 Subject: [PATCH 17/46] improve raycast to be more like hypxiels still not the same but closer --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 76 +++++++++++++------ 1 file changed, 54 insertions(+), 22 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index f8e159f088..7fc83bff82 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -15,11 +15,8 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.Direction; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; import net.minecraft.world.World; import java.util.regex.Matcher; @@ -57,7 +54,6 @@ public static void playerTeleported() { startPos = null; teleportVector = null; } - } /** @@ -88,6 +84,11 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn //get return item ItemStack stack = CLIENT.player.getStackInHand(hand); + //make sure it's not disabled + if (teleportDisabled) { + return TypedActionResult.pass(stack); + } + // make sure the camera is not in 3rd person if (CLIENT.options.getPerspective() != Perspective.FIRST_PERSON) { return TypedActionResult.pass(stack); @@ -169,43 +170,45 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn if (startPos == null || teleportVector == null) { //start of teleport sequence startPos = CLIENT.player.getEyePos(); - lastTeleportTime = System.currentTimeMillis(); } else { //add to the end of the teleport sequence - startPos = startPos.add(teleportVector); + startPos = startPos.add(teleportVector);//todo start moving from current interpolated pos } startTime = System.currentTimeMillis(); + //if not ahead reset last teleport time + if (teleportsAhead == 0) { + lastTeleportTime = System.currentTimeMillis(); + } // calculate the vector the player will follow for the teleport //get direction float pitch = CLIENT.player.getPitch(); float yaw = CLIENT.player.getYaw(); Vec3d look = CLIENT.player.getRotationVector(pitch, yaw); + //find target location depending on how far the item they are using takes them - teleportVector = look.multiply(distance); - //make sure there are no blocks in the way and if so account for this - BlockHitResult hitResult = world.raycast(new RaycastContext(startPos, startPos.add(teleportVector), RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, CLIENT.player)); - if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) { - Vec3d offsetEndPos; - if (hitResult.getSide().equals(Direction.UP) || hitResult.getSide().equals(Direction.DOWN)) { - offsetEndPos = hitResult.getPos().offset(hitResult.getSide(), 1); - } else { - offsetEndPos = hitResult.getPos().offset(hitResult.getSide(), 0.5); - } - teleportVector = offsetEndPos.subtract(startPos); + teleportVector = raycast(distance, look, startPos); + if (teleportVector == null) { + startPos = null; + return TypedActionResult.pass(stack); } - //compensate for pixel rounding the end position to x.5 y.62 z.5 + //round the vector values to 1dp + + //compensate for hypixel rounding the end position to x.5 y.62 z.5 Vec3d predictedEnd = startPos.add(teleportVector); - Vec3d offsetVec = new Vec3d(predictedEnd.x - (Math.floor(predictedEnd.x) + 0.5), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - (Math.floor(predictedEnd.z) + 0.5)); + Vec3d offsetVec = new Vec3d(predictedEnd.x - getOffset(predictedEnd.x), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - getOffset(predictedEnd.z)); teleportVector = teleportVector.subtract(offsetVec); - //add 1 to teleports ahead teleportsAhead += 1; return TypedActionResult.pass(stack); } + private static double getOffset(double input) { + return Math.round(input - 0.5) + 0.5; + } + /** * Works out if the players location lets them use teleportation or not * @@ -246,6 +249,33 @@ private static boolean isAllowedLocation() { return true; } + /** + * custom raycast hopefully more like hypxiels checks the player can be at every block of the raycast then when one is hit set pos to block before + * + * @param distance maximum distance + * @return teleport vector + */ + private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { + if (CLIENT.world == null) { + return null; + } + for (double offset = 0; offset <= distance; offset += 1) { + BlockPos checkPos = BlockPos.ofFloored(startPos.add(direction.multiply(offset))); + + //there are block in the way return the previce location + if (!CLIENT.world.getBlockState(checkPos).isAir() || !CLIENT.world.getBlockState(checkPos.up()).isAir()) { //todo some transparent blocks can be teleported in (Buttons could be more) + System.out.println(startPos.add(direction.multiply(offset - 1)) + "hit block"); + if (offset == 0) { + // no teleport can happen + return null; + } + return direction.multiply(offset - 1); + } + + } + return direction.multiply(distance); + } + /** * works out where they player should be based on how far though the predicted teleport time. * @@ -258,7 +288,7 @@ public static Vec3d getInterpolatedPos() { } long gap = System.currentTimeMillis() - startTime; //make sure the player is actually getting teleported if not disable teleporting until they are teleported again - if (System.currentTimeMillis() - lastTeleportTime > MAX_TELEPORT_TIME) { + if (System.currentTimeMillis() - lastTeleportTime > 1000) { teleportDisabled = true; startPos = null; teleportVector = null; @@ -273,4 +303,6 @@ public static Vec3d getInterpolatedPos() { public static void updatePing(long ping) { lastPing = ping; } + + } From b4ee65ae1bfecc1ffebedfd6b75553e52478eed0 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 30 Aug 2024 12:16:02 +0100 Subject: [PATCH 18/46] add separate cameraStartPos to try and smooth combined animations --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 7fc83bff82..9b9fde3156 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -31,6 +31,7 @@ public class SmoothAOTE { private static long startTime; private static Vec3d startPos; + private static Vec3d cameraStartPos; private static Vec3d teleportVector; private static long lastPing; private static int teleportsAhead; @@ -167,19 +168,20 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn } //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one - if (startPos == null || teleportVector == null) { + if (teleportsAhead == 0) { //start of teleport sequence - startPos = CLIENT.player.getEyePos(); + startPos = CLIENT.player.getPos().add(0,1.62,0); // the eye poss should not be affected by crouching + cameraStartPos = CLIENT.player.getEyePos(); + lastTeleportTime = System.currentTimeMillis(); } else { //add to the end of the teleport sequence - startPos = startPos.add(teleportVector);//todo start moving from current interpolated pos + startPos = startPos.add(teleportVector); + //set the camera start pos to how far though the teleport the player is to make is smoother + cameraStartPos = getInterpolatedPos(); } startTime = System.currentTimeMillis(); - //if not ahead reset last teleport time - if (teleportsAhead == 0) { - lastTeleportTime = System.currentTimeMillis(); - } + // calculate the vector the player will follow for the teleport //get direction @@ -297,7 +299,7 @@ public static Vec3d getInterpolatedPos() { } double percentage = Math.min((double) (gap) / Math.min(lastPing, MAX_TELEPORT_TIME), 1); - return startPos.add(teleportVector.multiply(percentage)); + return cameraStartPos.add(teleportVector.multiply(percentage)); } public static void updatePing(long ping) { From 6d570c10f1d25dd45d821ca90fd6481b8029ecc0 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 30 Aug 2024 12:30:17 +0100 Subject: [PATCH 19/46] fix extra code --- .../de/hysky/skyblocker/skyblock/SmoothAOTE.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 9b9fde3156..9f533382d9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -87,7 +87,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn //make sure it's not disabled if (teleportDisabled) { - return TypedActionResult.pass(stack); + return TypedActionResult.pass(stack); } // make sure the camera is not in 3rd person @@ -170,7 +170,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one if (teleportsAhead == 0) { //start of teleport sequence - startPos = CLIENT.player.getPos().add(0,1.62,0); // the eye poss should not be affected by crouching + startPos = CLIENT.player.getPos().add(0, 1.62, 0); // the eye poss should not be affected by crouching cameraStartPos = CLIENT.player.getEyePos(); lastTeleportTime = System.currentTimeMillis(); } else { @@ -188,7 +188,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn float pitch = CLIENT.player.getPitch(); float yaw = CLIENT.player.getYaw(); Vec3d look = CLIENT.player.getRotationVector(pitch, yaw); - + //find target location depending on how far the item they are using takes them teleportVector = raycast(distance, look, startPos); if (teleportVector == null) { @@ -199,7 +199,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn //compensate for hypixel rounding the end position to x.5 y.62 z.5 Vec3d predictedEnd = startPos.add(teleportVector); - Vec3d offsetVec = new Vec3d(predictedEnd.x - getOffset(predictedEnd.x), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - getOffset(predictedEnd.z)); + Vec3d offsetVec = new Vec3d(predictedEnd.x - roundToCenter(predictedEnd.x), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - roundToCenter(predictedEnd.z)); teleportVector = teleportVector.subtract(offsetVec); //add 1 to teleports ahead teleportsAhead += 1; @@ -207,7 +207,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn return TypedActionResult.pass(stack); } - private static double getOffset(double input) { + private static double roundToCenter(double input) { return Math.round(input - 0.5) + 0.5; } @@ -224,8 +224,6 @@ private static boolean isAllowedLocation() { return false; } else if (Utils.getLocation() == Location.PRIVATE_ISLAND && !Utils.getIslandArea().equals("⏣ Your Island")) { //do not allow it when visiting return false; - } else if (Utils.getLocation() == Location.PRIVATE_ISLAND && !Utils.getIslandArea().equals("⏣ Your Island")) { //do not allow it when visiting garden - return false; } else if (Utils.isInDungeons()) { //check places in dungeons where you can't teleport if (DungeonManager.isInBoss() && DungeonManager.getBoss() == DungeonBoss.MAXOR) { return false; From 78f17c918f3680dbc2b5e114d28ff2006ca6dc48 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 30 Aug 2024 12:38:09 +0100 Subject: [PATCH 20/46] fix not working when clicking dirt with shovel --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 53 ++++++++++++------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 9f533382d9..989a7990c4 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -7,14 +7,17 @@ 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.client.MinecraftClient; import net.minecraft.client.option.Perspective; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -40,6 +43,7 @@ public class SmoothAOTE { public static void init() { UseItemCallback.EVENT.register(SmoothAOTE::onItemInteract); + UseBlockCallback.EVENT.register(SmoothAOTE::onBlockInteract); } public static void playerTeleported() { @@ -68,36 +72,47 @@ private static int extractTunedCustomData(NbtCompound customData, int baseRange) return customData != null && customData.contains("tuned_transmission") ? baseRange + customData.getInt("tuned_transmission") : baseRange; } + + private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { + if (CLIENT.player == null) { + return null; + } + calculateTeleportUse(hand); + return TypedActionResult.pass(CLIENT.player.getStackInHand(hand)); + } + + private static ActionResult onBlockInteract(PlayerEntity playerEntity, World world, Hand hand, BlockHitResult blockHitResult) { + calculateTeleportUse(hand); + return ActionResult.PASS; + } + /** * 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 playerEntity the player - * @param world the world - * @param hand what the player is holding - * @return if the right click should go though + * @param hand what the player is holding */ - private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { + private static void calculateTeleportUse(Hand hand) { //stop checking if player does not exist if (CLIENT.player == null || CLIENT.world == null) { - return null; + return; } //get return item ItemStack stack = CLIENT.player.getStackInHand(hand); //make sure it's not disabled if (teleportDisabled) { - return TypedActionResult.pass(stack); + return; } // make sure the camera is not in 3rd person if (CLIENT.options.getPerspective() != Perspective.FIRST_PERSON) { - return TypedActionResult.pass(stack); + return; } //make sure the player is in an area teleporting is allowed not allowed in glacite mineshafts and floor 7 boss if (!isAllowedLocation()) { - return TypedActionResult.pass(stack); + return; } //work out if the player is holding a teleporting item that is enabled and if so how far the item will take them @@ -112,7 +127,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn distance = 3; break; } - return TypedActionResult.pass(stack); + return; } case "ASPECT_OF_THE_LEECH_2" -> { @@ -120,7 +135,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn distance = 4; break; } - return TypedActionResult.pass(stack); + return; } case "ASPECT_OF_THE_END", "ASPECT_OF_THE_VOID" -> { if (CLIENT.options.sneakKey.isPressed() && customData.getInt("ethermerge") == 1) { @@ -132,38 +147,38 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn distance = extractTunedCustomData(customData, 8); break; } - return TypedActionResult.pass(stack); + return; } case "ETHERWARP_CONDUIT" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableEtherTransmission) { distance = extractTunedCustomData(customData, 57); break; } - return TypedActionResult.pass(stack); + return; } case "SINSEEKER_SCYTHE" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableSinrecallTransmission) { distance = extractTunedCustomData(customData, 4); break; } - return TypedActionResult.pass(stack); + return; } case "NECRON_BLADE", "ASTRAEA", "HYPERION", "SCYLLA", "VALKYRIE" -> { if (SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.enableWitherImpact) { distance = 10; break; } - return TypedActionResult.pass(stack); + return; } default -> { - return TypedActionResult.pass(stack); + return; } } //make sure the player has enough mana to do the teleport Matcher manaNeeded = ItemUtils.getLoreLineIfMatch(heldItem, MANA_LORE); if (manaNeeded != null && manaNeeded.matches()) { if (SkyblockerMod.getInstance().statusBarTracker.getMana().value() < Integer.parseInt(manaNeeded.group(1))) { // todo the players mana can lag behind as it is updated server side. client side mana calculations would help with this - return TypedActionResult.pass(stack); + return; } } @@ -193,7 +208,7 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn teleportVector = raycast(distance, look, startPos); if (teleportVector == null) { startPos = null; - return TypedActionResult.pass(stack); + return; } //round the vector values to 1dp @@ -203,8 +218,6 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn teleportVector = teleportVector.subtract(offsetVec); //add 1 to teleports ahead teleportsAhead += 1; - - return TypedActionResult.pass(stack); } private static double roundToCenter(double input) { From 4c76d8c7b604b4fc87ff129ec304bbd8285378c2 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 30 Aug 2024 13:01:31 +0100 Subject: [PATCH 21/46] more clean --- src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 989a7990c4..351c5ef9a3 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -183,7 +183,7 @@ private static void calculateTeleportUse(Hand hand) { } //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one - if (teleportsAhead == 0) { + if (teleportsAhead == 0 || startPos == null || teleportVector == null) { //start of teleport sequence startPos = CLIENT.player.getPos().add(0, 1.62, 0); // the eye poss should not be affected by crouching cameraStartPos = CLIENT.player.getEyePos(); @@ -272,12 +272,11 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { if (CLIENT.world == null) { return null; } - for (double offset = 0; offset <= distance; offset += 1) { + for (double offset = 0; offset <= distance; offset ++) { BlockPos checkPos = BlockPos.ofFloored(startPos.add(direction.multiply(offset))); - //there are block in the way return the previce location + //there are block in the way return the last location if (!CLIENT.world.getBlockState(checkPos).isAir() || !CLIENT.world.getBlockState(checkPos.up()).isAir()) { //todo some transparent blocks can be teleported in (Buttons could be more) - System.out.println(startPos.add(direction.multiply(offset - 1)) + "hit block"); if (offset == 0) { // no teleport can happen return null; From 98790c61a72c707e514519d3bb8bd84186c74835 Mon Sep 17 00:00:00 2001 From: olim Date: Wed, 4 Sep 2024 15:54:37 +0100 Subject: [PATCH 22/46] fix the init --- src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 351c5ef9a3..406ee42f0d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.skyblock; import de.hysky.skyblocker.SkyblockerMod; +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; @@ -41,6 +42,7 @@ public class SmoothAOTE { private static long lastTeleportTime; private static boolean teleportDisabled; + @Init public static void init() { UseItemCallback.EVENT.register(SmoothAOTE::onItemInteract); UseBlockCallback.EVENT.register(SmoothAOTE::onBlockInteract); From 2c9108204e579ece1d03b721d717a1bf43b642d0 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 12 Sep 2024 16:29:49 +0100 Subject: [PATCH 23/46] fix multiple teleports when looking at a block there is still debug stuff in this commit --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 79 ++++++++++++++++++- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 406ee42f0d..58ae37b3fa 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -8,12 +8,18 @@ import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Location; import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.render.RenderHelper; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.fabricmc.fabric.api.event.player.UseBlockCallback; import net.fabricmc.fabric.api.event.player.UseItemCallback; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; 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.util.ActionResult; import net.minecraft.util.Hand; @@ -23,6 +29,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -42,10 +49,36 @@ public class SmoothAOTE { private static long lastTeleportTime; private static boolean teleportDisabled; + + private static Vec3d debugLastStart; + private static Vec3d debugLastEnd; + private static Vec3d debugPos1; + private static Vec3d debugPos2; + private static Vec3d debugPos3; + @Init public static void init() { UseItemCallback.EVENT.register(SmoothAOTE::onItemInteract); UseBlockCallback.EVENT.register(SmoothAOTE::onBlockInteract); + WorldRenderEvents.AFTER_TRANSLUCENT.register(SmoothAOTE::render); + } + + private static void render(WorldRenderContext context) { + //dev testing rendering + if (debugLastStart != null && debugLastEnd != null){ + RenderHelper.renderLinesFromPoints(context, new Vec3d[]{debugLastStart, debugLastEnd} ,new float[]{1,1,1},1,4,true); + } + + //render debug positions + if (debugPos1 != null) { + RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos1), new float[] {1,0,0},0.5f, true); + } + if (debugPos2 != null) { + RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos2), new float[] {0,1,0},0.5f, true); + } + if (debugPos3 != null) { + RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos3), new float[] {0,0,1},0.5f, true); + } } public static void playerTeleported() { @@ -55,6 +88,8 @@ public static void playerTeleported() { lastTeleportTime = System.currentTimeMillis(); teleportDisabled = false; + debugPos3 = CLIENT.player.getEyePos(); + //if the server is in sync in number of teleports if (teleportsAhead == 0) { //reset when player has reached the end of the teleports @@ -83,11 +118,38 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn return TypedActionResult.pass(CLIENT.player.getStackInHand(hand)); } + /** + * 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) { - calculateTeleportUse(hand); + 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); + } + + // Helper method to check if the block is one that the shovel can turn into a path (e.g., grass or dirt) + 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 * @@ -95,6 +157,7 @@ private static ActionResult onBlockInteract(PlayerEntity playerEntity, World wor */ private static void calculateTeleportUse(Hand hand) { + System.out.println(System.currentTimeMillis()+"staring"); //stop checking if player does not exist if (CLIENT.player == null || CLIENT.world == null) { return; @@ -104,6 +167,7 @@ private static void calculateTeleportUse(Hand hand) { //make sure it's not disabled if (teleportDisabled) { + System.out.println("disabled not teleporting"); return; } @@ -183,6 +247,7 @@ private static void calculateTeleportUse(Hand hand) { return; } } + System.out.println("starting the teleport"); //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one if (teleportsAhead == 0 || startPos == null || teleportVector == null) { @@ -193,6 +258,7 @@ private static void calculateTeleportUse(Hand hand) { } else { //add to the end of the teleport sequence startPos = startPos.add(teleportVector); + debugLastStart = startPos; //set the camera start pos to how far though the teleport the player is to make is smoother cameraStartPos = getInterpolatedPos(); } @@ -220,6 +286,9 @@ private static void calculateTeleportUse(Hand hand) { teleportVector = teleportVector.subtract(offsetVec); //add 1 to teleports ahead teleportsAhead += 1; + + debugLastEnd = startPos.add(teleportVector); + System.out.println(teleportsAhead); } private static double roundToCenter(double input) { @@ -274,18 +343,22 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { if (CLIENT.world == null) { return null; } + System.out.println(BlockPos.ofFloored(startPos.add(direction))); for (double offset = 0; offset <= distance; offset ++) { BlockPos checkPos = BlockPos.ofFloored(startPos.add(direction.multiply(offset))); //there are block in the way return the last location - if (!CLIENT.world.getBlockState(checkPos).isAir() || !CLIENT.world.getBlockState(checkPos.up()).isAir()) { //todo some transparent blocks can be teleported in (Buttons could be more) + if (!CLIENT.world.getBlockState(checkPos).isAir() || !CLIENT.world.getBlockState(checkPos.up()).isAir()) { //todo some transparent blocks can be teleported in (Buttons, carpets could be more) if (offset == 0) { // no teleport can happen return null; } + debugPos1 = startPos.add(direction.multiply(offset)); + debugPos2 = startPos.add(direction.multiply(offset -1)); //todo befoer foget spiral cheking? check +y then +x then +z ? idk tbh return direction.multiply(offset - 1); } + } return direction.multiply(distance); } @@ -319,4 +392,4 @@ public static void updatePing(long ping) { } -} + } From f9f46a108af6d4fb0055e7fcc8dbe6389a860e9d Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 12 Sep 2024 23:50:29 +0100 Subject: [PATCH 24/46] hopefully improve raycast and add allowed blocks still debug stuff in --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 55 ++++++++++++++++--- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 58ae37b3fa..0d4e495e39 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -13,14 +13,15 @@ import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.fabricmc.fabric.api.event.player.UseBlockCallback; import net.fabricmc.fabric.api.event.player.UseItemCallback; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; +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.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; @@ -29,6 +30,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -55,6 +57,7 @@ public class SmoothAOTE { private static Vec3d debugPos1; private static Vec3d debugPos2; private static Vec3d debugPos3; + private static List debugRaycastChecks = new ArrayList<>(); @Init public static void init() { @@ -79,6 +82,11 @@ private static void render(WorldRenderContext context) { if (debugPos3 != null) { RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos3), new float[] {0,0,1},0.5f, true); } + //raycast check pos things + + for (Vec3d pos : debugRaycastChecks) { + RenderHelper.renderFilled(context,pos.add(0.05, 0.05, 0.05),new Vec3d(0.1,0.1,0.1), new float[] {1, 0, 0},1, true); + } } public static void playerTeleported() { @@ -255,6 +263,7 @@ private static void calculateTeleportUse(Hand hand) { startPos = CLIENT.player.getPos().add(0, 1.62, 0); // the eye poss should not be affected by crouching cameraStartPos = CLIENT.player.getEyePos(); lastTeleportTime = System.currentTimeMillis(); + debugLastStart = startPos; } else { //add to the end of the teleport sequence startPos = startPos.add(teleportVector); @@ -278,6 +287,7 @@ private static void calculateTeleportUse(Hand hand) { startPos = null; return; } + debugLastEnd = startPos.add(teleportVector); //round the vector values to 1dp //compensate for hypixel rounding the end position to x.5 y.62 z.5 @@ -287,7 +297,6 @@ private static void calculateTeleportUse(Hand hand) { //add 1 to teleports ahead teleportsAhead += 1; - debugLastEnd = startPos.add(teleportVector); System.out.println(teleportsAhead); } @@ -343,25 +352,55 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { if (CLIENT.world == null) { return null; } + System.out.println(BlockPos.ofFloored(startPos.add(direction))); - for (double offset = 0; offset <= distance; offset ++) { - BlockPos checkPos = BlockPos.ofFloored(startPos.add(direction.multiply(offset))); + debugRaycastChecks.clear(); + for (double offset = 0.2; offset <= distance; offset ++) { + Vec3d nextPos = startPos.add(direction.multiply(offset)); + Vec3d lastPos = startPos.add(direction.multiply(offset-1)); + System.out.println("next"+nextPos); + BlockPos checkPos = BlockPos.ofFloored(nextPos); + BlockPos lastCheck = BlockPos.ofFloored(lastPos); + debugRaycastChecks.add(startPos.add(direction.multiply(offset))); //there are block in the way return the last location - if (!CLIENT.world.getBlockState(checkPos).isAir() || !CLIENT.world.getBlockState(checkPos.up()).isAir()) { //todo some transparent blocks can be teleported in (Buttons, carpets could be more) - if (offset == 0) { + if (!canTeleportThrough(CLIENT.world.getBlockState(checkPos)) ) { + if (offset == 0.2) { // no teleport can happen return null; } debugPos1 = startPos.add(direction.multiply(offset)); - debugPos2 = startPos.add(direction.multiply(offset -1)); //todo befoer foget spiral cheking? check +y then +x then +z ? idk tbh + debugPos2 = startPos.add(direction.multiply(offset -1)); return direction.multiply(offset - 1); } + if (!CLIENT.world.getBlockState(checkPos.up()).isAir() && (nextPos.getY() - Math.floor(nextPos.getY())) >0.495 ) { + if (offset == 0.2) { + // no teleport can happen + return null; + } + debugPos1 = startPos.add(direction.multiply(offset)); + debugPos2 = startPos.add(direction.multiply(offset -1)); + return direction.multiply(offset - 1); + } + + + } return direction.multiply(distance); } + /** + * Checks to see if a block is in the allowed list to teleport though + * Air, Buttons, carpets, water, lava, 3 or less snow layers + */ + private static Boolean canTeleportThrough(BlockState blockState) { + if (blockState.isAir()) { + return true; + } + Block block = blockState.getBlock(); + return block instanceof ButtonBlock || block instanceof CarpetBlock || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS)<=3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); + } /** * works out where they player should be based on how far though the predicted teleport time. From 7f393b866ab73444177d84d49e0bad99b88e28b4 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 12 Sep 2024 23:54:20 +0100 Subject: [PATCH 25/46] do bad client side mana calculation still debug --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 0d4e495e39..a4c3eaa91a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -21,7 +21,6 @@ import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.state.property.Properties; -import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; @@ -55,7 +54,7 @@ public class SmoothAOTE { private static Vec3d debugLastStart; private static Vec3d debugLastEnd; private static Vec3d debugPos1; - private static Vec3d debugPos2; + private static Vec3d debugPos2; private static Vec3d debugPos3; private static List debugRaycastChecks = new ArrayList<>(); @@ -68,24 +67,24 @@ public static void init() { private static void render(WorldRenderContext context) { //dev testing rendering - if (debugLastStart != null && debugLastEnd != null){ - RenderHelper.renderLinesFromPoints(context, new Vec3d[]{debugLastStart, debugLastEnd} ,new float[]{1,1,1},1,4,true); + if (debugLastStart != null && debugLastEnd != null) { + RenderHelper.renderLinesFromPoints(context, new Vec3d[]{debugLastStart, debugLastEnd}, new float[]{1, 1, 1}, 1, 4, true); } //render debug positions if (debugPos1 != null) { - RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos1), new float[] {1,0,0},0.5f, true); + RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos1), new float[]{1, 0, 0}, 0.5f, true); } if (debugPos2 != null) { - RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos2), new float[] {0,1,0},0.5f, true); + RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos2), new float[]{0, 1, 0}, 0.5f, true); } if (debugPos3 != null) { - RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos3), new float[] {0,0,1},0.5f, true); + RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos3), new float[]{0, 0, 1}, 0.5f, true); } //raycast check pos things for (Vec3d pos : debugRaycastChecks) { - RenderHelper.renderFilled(context,pos.add(0.05, 0.05, 0.05),new Vec3d(0.1,0.1,0.1), new float[] {1, 0, 0},1, true); + RenderHelper.renderFilled(context, pos.add(0.05, 0.05, 0.05), new Vec3d(0.1, 0.1, 0.1), new float[]{1, 0, 0}, 1, true); } } @@ -128,9 +127,10 @@ private static TypedActionResult onItemInteract(PlayerEntity playerEn /** * Allows shovel teleport items to be used when aiming at interactable blocks - * @param playerEntity player - * @param world world - * @param hand hand item + * + * @param playerEntity player + * @param world world + * @param hand hand item * @param blockHitResult target block * @return always pass */ @@ -165,7 +165,7 @@ private static boolean canShovelActOnBlock(Block block) { */ private static void calculateTeleportUse(Hand hand) { - System.out.println(System.currentTimeMillis()+"staring"); + System.out.println(System.currentTimeMillis() + "staring"); //stop checking if player does not exist if (CLIENT.player == null || CLIENT.world == null) { return; @@ -251,7 +251,9 @@ private static void calculateTeleportUse(Hand hand) { //make sure the player has enough mana to do the teleport Matcher manaNeeded = ItemUtils.getLoreLineIfMatch(heldItem, MANA_LORE); if (manaNeeded != null && manaNeeded.matches()) { - if (SkyblockerMod.getInstance().statusBarTracker.getMana().value() < Integer.parseInt(manaNeeded.group(1))) { // todo the players mana can lag behind as it is updated server side. client side mana calculations would help with this + int manaCost = Integer.parseInt(manaNeeded.group(1)); + int predictedMana = SkyblockerMod.getInstance().statusBarTracker.getMana().value() - teleportsAhead * manaCost ; + if ( predictedMana< manaCost) { // todo the players mana can lag behind as it is updated server side. client side mana calculations would help with this return; } } @@ -355,41 +357,39 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { System.out.println(BlockPos.ofFloored(startPos.add(direction))); debugRaycastChecks.clear(); - for (double offset = 0.2; offset <= distance; offset ++) { + for (double offset = 0.2; offset <= distance; offset++) { Vec3d nextPos = startPos.add(direction.multiply(offset)); - Vec3d lastPos = startPos.add(direction.multiply(offset-1)); - System.out.println("next"+nextPos); + Vec3d lastPos = startPos.add(direction.multiply(offset - 1)); + System.out.println("next" + nextPos); BlockPos checkPos = BlockPos.ofFloored(nextPos); BlockPos lastCheck = BlockPos.ofFloored(lastPos); debugRaycastChecks.add(startPos.add(direction.multiply(offset))); //there are block in the way return the last location - if (!canTeleportThrough(CLIENT.world.getBlockState(checkPos)) ) { + if (!canTeleportThrough(CLIENT.world.getBlockState(checkPos))) { if (offset == 0.2) { // no teleport can happen return null; } debugPos1 = startPos.add(direction.multiply(offset)); - debugPos2 = startPos.add(direction.multiply(offset -1)); + debugPos2 = startPos.add(direction.multiply(offset - 1)); return direction.multiply(offset - 1); } - if (!CLIENT.world.getBlockState(checkPos.up()).isAir() && (nextPos.getY() - Math.floor(nextPos.getY())) >0.495 ) { + if (!CLIENT.world.getBlockState(checkPos.up()).isAir() && (nextPos.getY() - Math.floor(nextPos.getY())) > 0.495) { if (offset == 0.2) { // no teleport can happen return null; } debugPos1 = startPos.add(direction.multiply(offset)); - debugPos2 = startPos.add(direction.multiply(offset -1)); + debugPos2 = startPos.add(direction.multiply(offset - 1)); return direction.multiply(offset - 1); } - - - } return direction.multiply(distance); } + /** * Checks to see if a block is in the allowed list to teleport though * Air, Buttons, carpets, water, lava, 3 or less snow layers @@ -399,7 +399,7 @@ private static Boolean canTeleportThrough(BlockState blockState) { return true; } Block block = blockState.getBlock(); - return block instanceof ButtonBlock || block instanceof CarpetBlock || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS)<=3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); + return block instanceof ButtonBlock || block instanceof CarpetBlock || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); } /** @@ -431,4 +431,4 @@ public static void updatePing(long ping) { } - } +} From baefb14f87797a84fe804be2baa60f3c8b831673 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 12 Sep 2024 23:59:05 +0100 Subject: [PATCH 26/46] only don't check head pos on first block still debug --- src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index a4c3eaa91a..07954cf8e2 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -375,11 +375,12 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { debugPos2 = startPos.add(direction.multiply(offset - 1)); return direction.multiply(offset - 1); } - if (!CLIENT.world.getBlockState(checkPos.up()).isAir() && (nextPos.getY() - Math.floor(nextPos.getY())) > 0.495) { + if (!CLIENT.world.getBlockState(checkPos.up()).isAir() && (offset != 0.2 ||( nextPos.getY() - Math.floor(nextPos.getY())) > 0.495)) { if (offset == 0.2) { // no teleport can happen return null; } + System.out.println("checking head"); debugPos1 = startPos.add(direction.multiply(offset)); debugPos2 = startPos.add(direction.multiply(offset - 1)); return direction.multiply(offset - 1); From 0804944afa4a14ccd3f57815c22a370d93bab1de Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 20:47:48 +0100 Subject: [PATCH 27/46] improve head height test still debug --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 07954cf8e2..8a4895386b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -252,8 +252,8 @@ private static void calculateTeleportUse(Hand hand) { Matcher manaNeeded = ItemUtils.getLoreLineIfMatch(heldItem, MANA_LORE); if (manaNeeded != null && manaNeeded.matches()) { int manaCost = Integer.parseInt(manaNeeded.group(1)); - int predictedMana = SkyblockerMod.getInstance().statusBarTracker.getMana().value() - teleportsAhead * manaCost ; - if ( predictedMana< manaCost) { // todo the players mana can lag behind as it is updated server side. client side mana calculations would help with this + int predictedMana = SkyblockerMod.getInstance().statusBarTracker.getMana().value() - teleportsAhead * manaCost; + if (predictedMana < manaCost) { // todo the players mana can lag behind as it is updated server side. client side mana calculations would help with this return; } } @@ -357,17 +357,15 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { System.out.println(BlockPos.ofFloored(startPos.add(direction))); debugRaycastChecks.clear(); - for (double offset = 0.2; offset <= distance; offset++) { - Vec3d nextPos = startPos.add(direction.multiply(offset)); - Vec3d lastPos = startPos.add(direction.multiply(offset - 1)); - System.out.println("next" + nextPos); - BlockPos checkPos = BlockPos.ofFloored(nextPos); - BlockPos lastCheck = BlockPos.ofFloored(lastPos); + for (double offset = 0; offset <= distance; offset++) { + BlockPos checkPos = BlockPos.ofFloored(startPos.add(direction.multiply(offset))); + + System.out.println(startPos.add(direction.multiply(offset))); debugRaycastChecks.add(startPos.add(direction.multiply(offset))); //there are block in the way return the last location if (!canTeleportThrough(CLIENT.world.getBlockState(checkPos))) { - if (offset == 0.2) { + if (offset == 0) { // no teleport can happen return null; } @@ -375,8 +373,14 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { debugPos2 = startPos.add(direction.multiply(offset - 1)); return direction.multiply(offset - 1); } - if (!CLIENT.world.getBlockState(checkPos.up()).isAir() && (offset != 0.2 ||( nextPos.getY() - Math.floor(nextPos.getY())) > 0.495)) { - if (offset == 0.2) { + //check if the block at head height is free + if (!CLIENT.world.getBlockState(checkPos.up()).isAir() ){ + if (offset == 0) { + //cancel the check if starting height is to low + Vec3d justAhead = startPos.add(direction.multiply(0.2)); + if ((justAhead.getY() - Math.floor(justAhead.getY())) <= 0.495) { + continue; + } // no teleport can happen return null; } From d3079de93f49d02ebf10f4abddfb18616f0971cc Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 21:04:44 +0100 Subject: [PATCH 28/46] add close floor check still debug --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 8a4895386b..2ec7b04934 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -21,7 +21,9 @@ import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.state.property.Properties; +import net.minecraft.text.Text; import net.minecraft.util.ActionResult; +import net.minecraft.util.Formatting; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.util.hit.BlockHitResult; @@ -97,6 +99,10 @@ public static void playerTeleported() { debugPos3 = CLIENT.player.getEyePos(); + if (startPos != null && teleportVector!= null && CLIENT.player.getEyePos().subtract(startPos.add(teleportVector)).length()>0.1){ + CLIENT.player.sendMessage(Text.literal("FAIL:"+CLIENT.player.getEyePos().subtract(startPos.add(teleportVector)).length()).formatted(Formatting.RED)); + } + //if the server is in sync in number of teleports if (teleportsAhead == 0) { //reset when player has reached the end of the teleports @@ -289,6 +295,7 @@ private static void calculateTeleportUse(Hand hand) { startPos = null; return; } + debugPos1 = startPos.add(teleportVector); debugLastEnd = startPos.add(teleportVector); //round the vector values to 1dp @@ -355,10 +362,12 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { return null; } + int closeFloorY = 1000 ; System.out.println(BlockPos.ofFloored(startPos.add(direction))); debugRaycastChecks.clear(); for (double offset = 0; offset <= distance; offset++) { - BlockPos checkPos = BlockPos.ofFloored(startPos.add(direction.multiply(offset))); + Vec3d pos = startPos.add(direction.multiply(offset)); + BlockPos checkPos = BlockPos.ofFloored(pos); System.out.println(startPos.add(direction.multiply(offset))); debugRaycastChecks.add(startPos.add(direction.multiply(offset))); @@ -369,12 +378,10 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { // no teleport can happen return null; } - debugPos1 = startPos.add(direction.multiply(offset)); - debugPos2 = startPos.add(direction.multiply(offset - 1)); return direction.multiply(offset - 1); } //check if the block at head height is free - if (!CLIENT.world.getBlockState(checkPos.up()).isAir() ){ + if (!canTeleportThrough(CLIENT.world.getBlockState(checkPos.up()))) { if (offset == 0) { //cancel the check if starting height is to low Vec3d justAhead = startPos.add(direction.multiply(0.2)); @@ -385,8 +392,18 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { return null; } System.out.println("checking head"); - debugPos1 = startPos.add(direction.multiply(offset)); - debugPos2 = startPos.add(direction.multiply(offset - 1)); + return direction.multiply(offset - 1); + } + + //if the player is close to the floor save Y and when player goes bellow this y teleport them to old pos + if (!canTeleportThrough(CLIENT.world.getBlockState(checkPos.down())) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { + System.out.println("found close floor"); + closeFloorY = checkPos.getY() - 1; + } + + //if the checking Y is same as closeY finish + if (closeFloorY == checkPos.getY()) { + System.out.println("went bellow close floor"); return direction.multiply(offset - 1); } From da279119bd18197d4f767d06a172bc06df8f1fd8 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 21:08:00 +0100 Subject: [PATCH 29/46] add can teleport though fire still debug --- .../java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 2ec7b04934..3391c439fa 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -99,8 +99,8 @@ public static void playerTeleported() { debugPos3 = CLIENT.player.getEyePos(); - if (startPos != null && teleportVector!= null && CLIENT.player.getEyePos().subtract(startPos.add(teleportVector)).length()>0.1){ - CLIENT.player.sendMessage(Text.literal("FAIL:"+CLIENT.player.getEyePos().subtract(startPos.add(teleportVector)).length()).formatted(Formatting.RED)); + if (startPos != null && teleportVector != null && CLIENT.player.getEyePos().subtract(startPos.add(teleportVector)).length() > 0.1) { + CLIENT.player.sendMessage(Text.literal("FAIL:" + CLIENT.player.getEyePos().subtract(startPos.add(teleportVector)).length()).formatted(Formatting.RED)); } //if the server is in sync in number of teleports @@ -362,7 +362,7 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { return null; } - int closeFloorY = 1000 ; + int closeFloorY = 1000; System.out.println(BlockPos.ofFloored(startPos.add(direction))); debugRaycastChecks.clear(); for (double offset = 0; offset <= distance; offset++) { @@ -421,7 +421,7 @@ private static Boolean canTeleportThrough(BlockState blockState) { return true; } Block block = blockState.getBlock(); - return block instanceof ButtonBlock || block instanceof CarpetBlock || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); + return block instanceof ButtonBlock || block instanceof CarpetBlock || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); } /** From 9e4516015a6db5f55661a3c4e070fa0bd283a157 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 21:31:52 +0100 Subject: [PATCH 30/46] add checking for diagonals still in debug --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 3391c439fa..c4ebb08e66 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -362,8 +362,22 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { return null; } + //based on which way the ray is going get the needed vector for checking diagonals + BlockPos xDiagonalOffset; + BlockPos zDiagonalOffset; + if (direction.getX() > 0) { + xDiagonalOffset = new BlockPos(-1, 0, 0); + } else { + xDiagonalOffset = new BlockPos(1, 0, 0); + } + if (direction.getZ() > 0) { + zDiagonalOffset = new BlockPos(0, 0, -1); + } else { + zDiagonalOffset = new BlockPos(0, 0, 1); + } + int closeFloorY = 1000; - System.out.println(BlockPos.ofFloored(startPos.add(direction))); + debugRaycastChecks.clear(); for (double offset = 0; offset <= distance; offset++) { Vec3d pos = startPos.add(direction.multiply(offset)); @@ -373,15 +387,16 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { debugRaycastChecks.add(startPos.add(direction.multiply(offset))); //there are block in the way return the last location - if (!canTeleportThrough(CLIENT.world.getBlockState(checkPos))) { + if (!canTeleportThrough(checkPos)) { if (offset == 0) { // no teleport can happen return null; } return direction.multiply(offset - 1); } + //check if the block at head height is free - if (!canTeleportThrough(CLIENT.world.getBlockState(checkPos.up()))) { + if (!canTeleportThrough(checkPos.up())) { if (offset == 0) { //cancel the check if starting height is to low Vec3d justAhead = startPos.add(direction.multiply(0.2)); @@ -395,12 +410,19 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { return direction.multiply(offset - 1); } - //if the player is close to the floor save Y and when player goes bellow this y teleport them to old pos - if (!canTeleportThrough(CLIENT.world.getBlockState(checkPos.down())) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { - System.out.println("found close floor"); - closeFloorY = checkPos.getY() - 1; + //check the diagonals to make sure player is not going through diagonal wall (block in the way on both sides at either height) + System.out.println((checkPos.add(xDiagonalOffset))+"||"+checkPos.add(zDiagonalOffset)); + if (offset != 0 && (!canTeleportThrough(checkPos.add(xDiagonalOffset)) || !canTeleportThrough(checkPos.up().add(xDiagonalOffset))) && (!canTeleportThrough(checkPos.add(zDiagonalOffset)) || !canTeleportThrough(checkPos.up().add(zDiagonalOffset)))){ + System.out.println("diagonal block"); + return direction.multiply(offset - 1); } + //if the player is close to the floor (including diagonally) save Y and when player goes bellow this y teleport them to old pos + if ((!canTeleportThrough(checkPos.down()) || !canTeleportThrough(checkPos.down().add(xDiagonalOffset)) || !canTeleportThrough(checkPos.down().add(zDiagonalOffset))) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { + System.out.println("found close floor"); + closeFloorY = checkPos.getY() - 1; + } + //if the checking Y is same as closeY finish if (closeFloorY == checkPos.getY()) { System.out.println("went bellow close floor"); @@ -416,7 +438,12 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { * Checks to see if a block is in the allowed list to teleport though * Air, Buttons, carpets, water, lava, 3 or less snow layers */ - private static Boolean canTeleportThrough(BlockState blockState) { + private static Boolean canTeleportThrough(BlockPos blockPos) { + if (CLIENT.world == null) { + return false; + } + + BlockState blockState = CLIENT.world.getBlockState(blockPos); if (blockState.isAir()) { return true; } From 40625c68e7606e51e79945141aed76757e3ff630 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 21:55:23 +0100 Subject: [PATCH 31/46] add new is floor check for the close floor check still debug --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index c4ebb08e66..ac540af091 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -29,6 +29,7 @@ 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.ArrayList; @@ -365,6 +366,7 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { //based on which way the ray is going get the needed vector for checking diagonals BlockPos xDiagonalOffset; BlockPos zDiagonalOffset; + System.out.println(direction.getX()); if (direction.getX() > 0) { xDiagonalOffset = new BlockPos(-1, 0, 0); } else { @@ -411,17 +413,17 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { } //check the diagonals to make sure player is not going through diagonal wall (block in the way on both sides at either height) - System.out.println((checkPos.add(xDiagonalOffset))+"||"+checkPos.add(zDiagonalOffset)); - if (offset != 0 && (!canTeleportThrough(checkPos.add(xDiagonalOffset)) || !canTeleportThrough(checkPos.up().add(xDiagonalOffset))) && (!canTeleportThrough(checkPos.add(zDiagonalOffset)) || !canTeleportThrough(checkPos.up().add(zDiagonalOffset)))){ + System.out.println((checkPos.add(xDiagonalOffset)) + "||" + checkPos.add(zDiagonalOffset)); + if (offset != 0 && (!canTeleportThrough(checkPos.add(xDiagonalOffset)) || !canTeleportThrough(checkPos.up().add(xDiagonalOffset))) && (!canTeleportThrough(checkPos.add(zDiagonalOffset)) || !canTeleportThrough(checkPos.up().add(zDiagonalOffset)))) { System.out.println("diagonal block"); return direction.multiply(offset - 1); } - //if the player is close to the floor (including diagonally) save Y and when player goes bellow this y teleport them to old pos - if ((!canTeleportThrough(checkPos.down()) || !canTeleportThrough(checkPos.down().add(xDiagonalOffset)) || !canTeleportThrough(checkPos.down().add(zDiagonalOffset))) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { - System.out.println("found close floor"); - closeFloorY = checkPos.getY() - 1; - } + //if the player is close to the floor (including diagonally) save Y and when player goes bellow this y teleport them to old pos + if (offset != 0 && (isBlockFloor(checkPos.down()) || isBlockFloor(checkPos.down().subtract(xDiagonalOffset)) || isBlockFloor(checkPos.down().subtract(zDiagonalOffset))) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { + System.out.println("found close floor"); + closeFloorY = checkPos.getY() - 1; + } //if the checking Y is same as closeY finish if (closeFloorY == checkPos.getY()) { @@ -437,6 +439,8 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { /** * Checks to see if a block is in the allowed list to teleport though * Air, Buttons, carpets, water, lava, 3 or less snow layers + * @param blockPos block location + * @return if a block location can be teleported though */ private static Boolean canTeleportThrough(BlockPos blockPos) { if (CLIENT.world == null) { @@ -451,6 +455,24 @@ private static Boolean canTeleportThrough(BlockPos blockPos) { return block instanceof ButtonBlock || block instanceof CarpetBlock || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); } + /** + * Checks to see if a block goes to the top if so class it as a floor + * @param blockPos block location + * @return if it's a floor block + */ + private static Boolean isBlockFloor(BlockPos blockPos) { + if (CLIENT.world == null) { + return false; + } + + BlockState blockState = CLIENT.world.getBlockState(blockPos); + VoxelShape shape = blockState.getOutlineShape(CLIENT.world, blockPos); + if (shape.isEmpty()) { + return false; + } + return shape.getBoundingBox().maxY == 1; + } + /** * works out where they player should be based on how far though the predicted teleport time. * From edd09485eacbec7c8b57be23e93f810467b883c0 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 22:49:58 +0100 Subject: [PATCH 32/46] update allowed blocks and improve diagonal collision still debug --- .../java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index ac540af091..8efac3e3e3 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -418,9 +418,8 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { System.out.println("diagonal block"); return direction.multiply(offset - 1); } - //if the player is close to the floor (including diagonally) save Y and when player goes bellow this y teleport them to old pos - if (offset != 0 && (isBlockFloor(checkPos.down()) || isBlockFloor(checkPos.down().subtract(xDiagonalOffset)) || isBlockFloor(checkPos.down().subtract(zDiagonalOffset))) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { + if (offset != 0 && (isBlockFloor(checkPos.down()) || (isBlockFloor(checkPos.down().subtract(xDiagonalOffset)) && isBlockFloor(checkPos.down().subtract(zDiagonalOffset)))) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { System.out.println("found close floor"); closeFloorY = checkPos.getY() - 1; } @@ -438,7 +437,8 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { /** * Checks to see if a block is in the allowed list to teleport though - * Air, Buttons, carpets, water, lava, 3 or less snow layers + * Air, Buttons, carpets, crops, mushrooms, nether wart, redstone, ladder, water, fire, lava, 3 or less snow layers + * * @param blockPos block location * @return if a block location can be teleported though */ @@ -452,11 +452,12 @@ private static Boolean canTeleportThrough(BlockPos blockPos) { return true; } Block block = blockState.getBlock(); - return block instanceof ButtonBlock || block instanceof CarpetBlock || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); + return block instanceof ButtonBlock || block instanceof CarpetBlock || block instanceof CropBlock || block.equals(Blocks.BROWN_MUSHROOM) || block.equals(Blocks.RED_MUSHROOM) || block.equals(Blocks.NETHER_WART) || block.equals(Blocks.REDSTONE_WIRE)|| block.equals(Blocks.LADDER) || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); } /** * Checks to see if a block goes to the top if so class it as a floor + * * @param blockPos block location * @return if it's a floor block */ @@ -466,7 +467,7 @@ private static Boolean isBlockFloor(BlockPos blockPos) { } BlockState blockState = CLIENT.world.getBlockState(blockPos); - VoxelShape shape = blockState.getOutlineShape(CLIENT.world, blockPos); + VoxelShape shape = blockState.getCollisionShape(CLIENT.world, blockPos); if (shape.isEmpty()) { return false; } From 6fa2c6cca1be92e6d0a4ffc36630a9b3f5d14c88 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 22:58:58 +0100 Subject: [PATCH 33/46] diagonals only work if its floor block still debug --- src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 8efac3e3e3..094be80883 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -414,7 +414,7 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { //check the diagonals to make sure player is not going through diagonal wall (block in the way on both sides at either height) System.out.println((checkPos.add(xDiagonalOffset)) + "||" + checkPos.add(zDiagonalOffset)); - if (offset != 0 && (!canTeleportThrough(checkPos.add(xDiagonalOffset)) || !canTeleportThrough(checkPos.up().add(xDiagonalOffset))) && (!canTeleportThrough(checkPos.add(zDiagonalOffset)) || !canTeleportThrough(checkPos.up().add(zDiagonalOffset)))) { + if (offset != 0 && (isBlockFloor(checkPos.add(xDiagonalOffset)) || isBlockFloor(checkPos.up().add(xDiagonalOffset))) && (isBlockFloor(checkPos.add(zDiagonalOffset)) || isBlockFloor(checkPos.up().add(zDiagonalOffset)))) { System.out.println("diagonal block"); return direction.multiply(offset - 1); } From 2050b2e3d8ea48b1c5cbef7023e14f6e247e218d Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 23:07:24 +0100 Subject: [PATCH 34/46] java docs --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 094be80883..e56c03000b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -91,6 +91,9 @@ private static void render(WorldRenderContext context) { } } + /** + * 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); @@ -123,7 +126,13 @@ private static int extractTunedCustomData(NbtCompound customData, int baseRange) return customData != null && customData.contains("tuned_transmission") ? baseRange + customData.getInt("tuned_transmission") : baseRange; } - + /** + * When an item is right-clicked send of to calculate teleport with the clicked item + * @param playerEntity player + * @param world world + * @param hand held item + * @return pass + */ private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { if (CLIENT.player == null) { return null; @@ -157,7 +166,11 @@ private static boolean isShovel(ItemStack itemStack) { itemStack.isOf(Items.DIAMOND_SHOVEL); } - // Helper method to check if the block is one that the shovel can turn into a path (e.g., grass or dirt) + /** + * 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 || @@ -310,6 +323,12 @@ private static void calculateTeleportUse(Hand hand) { System.out.println(teleportsAhead); } + /** + * Rounds a value to the nearest 0.5 + * + * @param input number to round + * @return rounded number + */ private static double roundToCenter(double input) { return Math.round(input - 0.5) + 0.5; } @@ -353,7 +372,7 @@ private static boolean isAllowedLocation() { } /** - * custom raycast hopefully more like hypxiels checks the player can be at every block of the raycast then when one is hit set pos to block before + * Custom raycast for teleporting checks for blocks for each 1 block forward in teleport. (very similar to hypixels method) * * @param distance maximum distance * @return teleport vector @@ -378,9 +397,11 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { zDiagonalOffset = new BlockPos(0, 0, 1); } + //initilise the closest floor value outside of possible values int closeFloorY = 1000; debugRaycastChecks.clear(); + //loop though each block of a teleport checking each block if there are blocks in the way for (double offset = 0; offset <= distance; offset++) { Vec3d pos = startPos.add(direction.multiply(offset)); BlockPos checkPos = BlockPos.ofFloored(pos); @@ -388,7 +409,7 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { System.out.println(startPos.add(direction.multiply(offset))); debugRaycastChecks.add(startPos.add(direction.multiply(offset))); - //there are block in the way return the last location + //check if there is a block at the check location if (!canTeleportThrough(checkPos)) { if (offset == 0) { // no teleport can happen @@ -412,13 +433,14 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { return direction.multiply(offset - 1); } - //check the diagonals to make sure player is not going through diagonal wall (block in the way on both sides at either height) + //check the diagonals to make sure player is not going through diagonal wall (full height block in the way on both sides at either height) System.out.println((checkPos.add(xDiagonalOffset)) + "||" + checkPos.add(zDiagonalOffset)); if (offset != 0 && (isBlockFloor(checkPos.add(xDiagonalOffset)) || isBlockFloor(checkPos.up().add(xDiagonalOffset))) && (isBlockFloor(checkPos.add(zDiagonalOffset)) || isBlockFloor(checkPos.up().add(zDiagonalOffset)))) { System.out.println("diagonal block"); return direction.multiply(offset - 1); } - //if the player is close to the floor (including diagonally) save Y and when player goes bellow this y teleport them to old pos + + //if the player is close to the floor (including diagonally) save Y and when player goes bellow this y finish teleport if (offset != 0 && (isBlockFloor(checkPos.down()) || (isBlockFloor(checkPos.down().subtract(xDiagonalOffset)) && isBlockFloor(checkPos.down().subtract(zDiagonalOffset)))) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { System.out.println("found close floor"); closeFloorY = checkPos.getY() - 1; @@ -429,9 +451,9 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { System.out.println("went bellow close floor"); return direction.multiply(offset - 1); } - - } + + //return full distance if no collision found return direction.multiply(distance); } @@ -452,7 +474,7 @@ private static Boolean canTeleportThrough(BlockPos blockPos) { return true; } Block block = blockState.getBlock(); - return block instanceof ButtonBlock || block instanceof CarpetBlock || block instanceof CropBlock || block.equals(Blocks.BROWN_MUSHROOM) || block.equals(Blocks.RED_MUSHROOM) || block.equals(Blocks.NETHER_WART) || block.equals(Blocks.REDSTONE_WIRE)|| block.equals(Blocks.LADDER) || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); + return block instanceof ButtonBlock || block instanceof CarpetBlock || block instanceof CropBlock || block.equals(Blocks.BROWN_MUSHROOM) || block.equals(Blocks.RED_MUSHROOM) || block.equals(Blocks.NETHER_WART) || block.equals(Blocks.REDSTONE_WIRE) || block.equals(Blocks.LADDER) || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); } /** From ab59033146020e64cf9590c636629d0fa5d84736 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 23:12:34 +0100 Subject: [PATCH 35/46] remove debug --- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 73 ++----------------- 1 file changed, 5 insertions(+), 68 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index e56c03000b..a586803c23 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -8,9 +8,6 @@ import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Location; import de.hysky.skyblocker.utils.Utils; -import de.hysky.skyblocker.utils.render.RenderHelper; -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; -import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.fabricmc.fabric.api.event.player.UseBlockCallback; import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.minecraft.block.*; @@ -21,9 +18,7 @@ import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.state.property.Properties; -import net.minecraft.text.Text; import net.minecraft.util.ActionResult; -import net.minecraft.util.Formatting; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.util.hit.BlockHitResult; @@ -32,8 +27,6 @@ import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -53,42 +46,10 @@ public class SmoothAOTE { private static long lastTeleportTime; private static boolean teleportDisabled; - - private static Vec3d debugLastStart; - private static Vec3d debugLastEnd; - private static Vec3d debugPos1; - private static Vec3d debugPos2; - private static Vec3d debugPos3; - private static List debugRaycastChecks = new ArrayList<>(); - @Init public static void init() { UseItemCallback.EVENT.register(SmoothAOTE::onItemInteract); UseBlockCallback.EVENT.register(SmoothAOTE::onBlockInteract); - WorldRenderEvents.AFTER_TRANSLUCENT.register(SmoothAOTE::render); - } - - private static void render(WorldRenderContext context) { - //dev testing rendering - if (debugLastStart != null && debugLastEnd != null) { - RenderHelper.renderLinesFromPoints(context, new Vec3d[]{debugLastStart, debugLastEnd}, new float[]{1, 1, 1}, 1, 4, true); - } - - //render debug positions - if (debugPos1 != null) { - RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos1), new float[]{1, 0, 0}, 0.5f, true); - } - if (debugPos2 != null) { - RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos2), new float[]{0, 1, 0}, 0.5f, true); - } - if (debugPos3 != null) { - RenderHelper.renderFilled(context, BlockPos.ofFloored(debugPos3), new float[]{0, 0, 1}, 0.5f, true); - } - //raycast check pos things - - for (Vec3d pos : debugRaycastChecks) { - RenderHelper.renderFilled(context, pos.add(0.05, 0.05, 0.05), new Vec3d(0.1, 0.1, 0.1), new float[]{1, 0, 0}, 1, true); - } } /** @@ -101,12 +62,6 @@ public static void playerTeleported() { lastTeleportTime = System.currentTimeMillis(); teleportDisabled = false; - debugPos3 = CLIENT.player.getEyePos(); - - if (startPos != null && teleportVector != null && CLIENT.player.getEyePos().subtract(startPos.add(teleportVector)).length() > 0.1) { - CLIENT.player.sendMessage(Text.literal("FAIL:" + CLIENT.player.getEyePos().subtract(startPos.add(teleportVector)).length()).formatted(Formatting.RED)); - } - //if the server is in sync in number of teleports if (teleportsAhead == 0) { //reset when player has reached the end of the teleports @@ -128,9 +83,10 @@ private static int extractTunedCustomData(NbtCompound customData, int baseRange) /** * When an item is right-clicked send of to calculate teleport with the clicked item + * * @param playerEntity player - * @param world world - * @param hand held item + * @param world world + * @param hand held item * @return pass */ private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { @@ -168,6 +124,7 @@ private static boolean isShovel(ItemStack itemStack) { /** * 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 */ @@ -185,7 +142,6 @@ private static boolean canShovelActOnBlock(Block block) { */ private static void calculateTeleportUse(Hand hand) { - System.out.println(System.currentTimeMillis() + "staring"); //stop checking if player does not exist if (CLIENT.player == null || CLIENT.world == null) { return; @@ -195,7 +151,6 @@ private static void calculateTeleportUse(Hand hand) { //make sure it's not disabled if (teleportDisabled) { - System.out.println("disabled not teleporting"); return; } @@ -277,7 +232,6 @@ private static void calculateTeleportUse(Hand hand) { return; } } - System.out.println("starting the teleport"); //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one if (teleportsAhead == 0 || startPos == null || teleportVector == null) { @@ -285,11 +239,9 @@ private static void calculateTeleportUse(Hand hand) { startPos = CLIENT.player.getPos().add(0, 1.62, 0); // the eye poss should not be affected by crouching cameraStartPos = CLIENT.player.getEyePos(); lastTeleportTime = System.currentTimeMillis(); - debugLastStart = startPos; } else { //add to the end of the teleport sequence startPos = startPos.add(teleportVector); - debugLastStart = startPos; //set the camera start pos to how far though the teleport the player is to make is smoother cameraStartPos = getInterpolatedPos(); } @@ -309,9 +261,6 @@ private static void calculateTeleportUse(Hand hand) { startPos = null; return; } - debugPos1 = startPos.add(teleportVector); - debugLastEnd = startPos.add(teleportVector); - //round the vector values to 1dp //compensate for hypixel rounding the end position to x.5 y.62 z.5 Vec3d predictedEnd = startPos.add(teleportVector); @@ -319,8 +268,6 @@ private static void calculateTeleportUse(Hand hand) { teleportVector = teleportVector.subtract(offsetVec); //add 1 to teleports ahead teleportsAhead += 1; - - System.out.println(teleportsAhead); } /** @@ -385,7 +332,6 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { //based on which way the ray is going get the needed vector for checking diagonals BlockPos xDiagonalOffset; BlockPos zDiagonalOffset; - System.out.println(direction.getX()); if (direction.getX() > 0) { xDiagonalOffset = new BlockPos(-1, 0, 0); } else { @@ -397,18 +343,14 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { zDiagonalOffset = new BlockPos(0, 0, 1); } - //initilise the closest floor value outside of possible values + //initialise the closest floor value outside of possible values int closeFloorY = 1000; - debugRaycastChecks.clear(); //loop though each block of a teleport checking each block if there are blocks in the way for (double offset = 0; offset <= distance; offset++) { Vec3d pos = startPos.add(direction.multiply(offset)); BlockPos checkPos = BlockPos.ofFloored(pos); - System.out.println(startPos.add(direction.multiply(offset))); - debugRaycastChecks.add(startPos.add(direction.multiply(offset))); - //check if there is a block at the check location if (!canTeleportThrough(checkPos)) { if (offset == 0) { @@ -429,26 +371,21 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { // no teleport can happen return null; } - System.out.println("checking head"); return direction.multiply(offset - 1); } //check the diagonals to make sure player is not going through diagonal wall (full height block in the way on both sides at either height) - System.out.println((checkPos.add(xDiagonalOffset)) + "||" + checkPos.add(zDiagonalOffset)); if (offset != 0 && (isBlockFloor(checkPos.add(xDiagonalOffset)) || isBlockFloor(checkPos.up().add(xDiagonalOffset))) && (isBlockFloor(checkPos.add(zDiagonalOffset)) || isBlockFloor(checkPos.up().add(zDiagonalOffset)))) { - System.out.println("diagonal block"); return direction.multiply(offset - 1); } //if the player is close to the floor (including diagonally) save Y and when player goes bellow this y finish teleport if (offset != 0 && (isBlockFloor(checkPos.down()) || (isBlockFloor(checkPos.down().subtract(xDiagonalOffset)) && isBlockFloor(checkPos.down().subtract(zDiagonalOffset)))) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { - System.out.println("found close floor"); closeFloorY = checkPos.getY() - 1; } //if the checking Y is same as closeY finish if (closeFloorY == checkPos.getY()) { - System.out.println("went bellow close floor"); return direction.multiply(offset - 1); } } From e6ee1ee09fbf8011630267fb9330779169e934b8 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 23:20:02 +0100 Subject: [PATCH 36/46] can teleport though pots --- src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index a586803c23..08ff3a76e8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -262,7 +262,7 @@ private static void calculateTeleportUse(Hand hand) { return; } - //compensate for hypixel rounding the end position to x.5 y.62 z.5 + //compensate for hypixel round to center of block (to x.5 y.62 z.5) Vec3d predictedEnd = startPos.add(teleportVector); Vec3d offsetVec = new Vec3d(predictedEnd.x - roundToCenter(predictedEnd.x), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - roundToCenter(predictedEnd.z)); teleportVector = teleportVector.subtract(offsetVec); @@ -396,7 +396,7 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { /** * Checks to see if a block is in the allowed list to teleport though - * Air, Buttons, carpets, crops, mushrooms, nether wart, redstone, ladder, water, fire, lava, 3 or less snow layers + * Air, Buttons, carpets, crops, pots, mushrooms, nether wart, redstone, ladder, water, fire, lava, 3 or less snow layers * * @param blockPos block location * @return if a block location can be teleported though @@ -411,7 +411,7 @@ private static Boolean canTeleportThrough(BlockPos blockPos) { return true; } Block block = blockState.getBlock(); - return block instanceof ButtonBlock || block instanceof CarpetBlock || block instanceof CropBlock || block.equals(Blocks.BROWN_MUSHROOM) || block.equals(Blocks.RED_MUSHROOM) || block.equals(Blocks.NETHER_WART) || block.equals(Blocks.REDSTONE_WIRE) || block.equals(Blocks.LADDER) || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); + return block instanceof ButtonBlock || block instanceof CarpetBlock || block instanceof CropBlock || block instanceof FlowerPotBlock || block.equals(Blocks.BROWN_MUSHROOM) || block.equals(Blocks.RED_MUSHROOM) || block.equals(Blocks.NETHER_WART) || block.equals(Blocks.REDSTONE_WIRE) || block.equals(Blocks.LADDER) || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); } /** From b79fb4409898781ebd5f10b01ae30dd295c223bf Mon Sep 17 00:00:00 2001 From: olim Date: Sat, 14 Sep 2024 19:55:13 +0100 Subject: [PATCH 37/46] Update SmoothAOTE.java --- src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 08ff3a76e8..147d5a4b46 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -404,14 +404,14 @@ private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { private static Boolean canTeleportThrough(BlockPos blockPos) { if (CLIENT.world == null) { return false; - } + } BlockState blockState = CLIENT.world.getBlockState(blockPos); if (blockState.isAir()) { return true; } Block block = blockState.getBlock(); - return block instanceof ButtonBlock || block instanceof CarpetBlock || block instanceof CropBlock || block instanceof FlowerPotBlock || block.equals(Blocks.BROWN_MUSHROOM) || block.equals(Blocks.RED_MUSHROOM) || block.equals(Blocks.NETHER_WART) || block.equals(Blocks.REDSTONE_WIRE) || block.equals(Blocks.LADDER) || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); + return block instanceof ButtonBlock || block instanceof CarpetBlock || block instanceof CropBlock || block instanceof FlowerPotBlock || block.equals(Blocks.BROWN_MUSHROOM) || block.equals(Blocks.RED_MUSHROOM) || block.equals(Blocks.NETHER_WART) || block.equals(Blocks.REDSTONE_WIRE) || block.equals(Blocks.LADDER) || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); } /** From c8d30dd3f249b779b2c82c9bf09a3b75fb9d92b7 Mon Sep 17 00:00:00 2001 From: Kevin <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 15 Sep 2024 12:49:23 +0800 Subject: [PATCH 38/46] Apply suggestions from code review --- .../skyblocker/mixins/ClientPlayNetworkHandlerMixin.java | 2 +- src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index 064dba2900..5e8359a047 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -169,7 +169,7 @@ private boolean shouldShowPacketSizeAndPingCharts(DebugHud instance, Operation Date: Wed, 18 Sep 2024 21:03:32 +0100 Subject: [PATCH 39/46] apply suggested changes --- .../mixins/ClientPlayNetworkHandlerMixin.java | 6 +- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 856 +++++++++--------- .../assets/skyblocker/lang/en_us.json | 14 +- 3 files changed, 438 insertions(+), 438 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index 5e8359a047..3cf614bd37 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -162,14 +162,14 @@ private void onPlayerTeleported(PlayerPositionLookS2CPacket packet, CallbackInfo SmoothAOTE.playerTeleported(); } - @WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowPacketSizeAndPingCharts()Z")) - private boolean shouldShowPacketSizeAndPingCharts(DebugHud instance, Operation original) { + @ModifyExpressionValue(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowPacketSizeAndPingCharts()Z")) + private boolean shouldShowPacketSizeAndPingCharts(boolean original) { //make the f3+3 screen always send ping packets even when closed //this is needed to make smooth AOTE work if (Utils.isOnSkyblock()) { return true; } - return original.call(instance); + return original; } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 0fcbaaa846..2e34bef6ad 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -32,434 +32,434 @@ 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 int teleportsAhead; - private static long lastTeleportTime; - private 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) { - //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") : 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 TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { - if (CLIENT.player == null) { - return null; - } - calculateTeleportUse(hand); - return TypedActionResult.pass(CLIENT.player.getStackInHand(hand)); - } - - /** - * 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") == 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.group(1)); - int predictedMana = SkyblockerMod.getInstance().statusBarTracker.getMana().value() - teleportsAhead * manaCost; - if (predictedMana < manaCost) { // todo the players mana can lag behind as it is updated server side. client side mana calculations would help with this - return; - } - } - - //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one - if (teleportsAhead == 0 || startPos == null || teleportVector == null) { - //start of teleport sequence - startPos = CLIENT.player.getPos().add(0, 1.62, 0); // the eye poss should not be affected by crouching - cameraStartPos = CLIENT.player.getEyePos(); - lastTeleportTime = System.currentTimeMillis(); - } else { - //add to the end of the teleport sequence - startPos = startPos.add(teleportVector); - //set the camera start pos to how far though the teleport the player is to make is smoother - cameraStartPos = getInterpolatedPos(); - } - - startTime = System.currentTimeMillis(); - - - // calculate the vector the player will follow for the teleport - //get direction - float pitch = CLIENT.player.getPitch(); - float yaw = CLIENT.player.getYaw(); - Vec3d look = CLIENT.player.getRotationVector(pitch, yaw); - - //find target location depending on how far the item they are using takes them - teleportVector = raycast(distance, look, startPos); - if (teleportVector == null) { - startPos = null; - return; - } - - //compensate for hypixel round to center of block (to x.5 y.62 z.5) - Vec3d predictedEnd = startPos.add(teleportVector); - Vec3d offsetVec = new Vec3d(predictedEnd.x - roundToCenter(predictedEnd.x), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - roundToCenter(predictedEnd.z)); - teleportVector = teleportVector.subtract(offsetVec); - //add 1 to teleports ahead - teleportsAhead += 1; - } - - /** - * Rounds a value to the nearest 0.5 - * - * @param input number to round - * @return rounded number - */ - private static double roundToCenter(double input) { - return Math.round(input - 0.5) + 0.5; - } - - /** - * Works out if the players location lets them use teleportation or not - * - * @return if the player should be allowed to teleport - */ - private static boolean isAllowedLocation() { - //check mines shafts - if (Utils.getMap().equals("Mineshaft")) { - return false; - } else if (Utils.getIslandArea().equals("⏣ Jungle Temple")) { //do not allow in jungle temple - return false; - } else if (Utils.getLocation() == Location.PRIVATE_ISLAND && !Utils.getIslandArea().equals("⏣ Your Island")) { //do not allow it when visiting - return false; - } else if (Utils.isInDungeons()) { //check places in dungeons where you can't teleport - if (DungeonManager.isInBoss() && DungeonManager.getBoss() == DungeonBoss.MAXOR) { - return false; - } - //make sure the player is in a room then check for disallowed rooms - if (!DungeonManager.isCurrentRoomMatched()) { - return true; - } - //does not work in boulder room - if (DungeonManager.getCurrentRoom().getName().equals("boxes-room")) { - return false; - } - //does not work in teleport maze room - if (DungeonManager.getCurrentRoom().getName().equals("teleport-pad-room")) { - return false; - } - //does not work in trap room - if (DungeonManager.getCurrentRoom().getName().startsWith("trap")) { - return false; - } - } - - return true; - } - - /** - * Custom raycast for teleporting checks for blocks for each 1 block forward in teleport. (very similar to hypixels method) - * - * @param distance maximum distance - * @return teleport vector - */ - private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { - if (CLIENT.world == null) { - return null; - } - - //based on which way the ray is going get the needed vector for checking diagonals - BlockPos xDiagonalOffset; - BlockPos zDiagonalOffset; - if (direction.getX() > 0) { - xDiagonalOffset = new BlockPos(-1, 0, 0); - } else { - xDiagonalOffset = new BlockPos(1, 0, 0); - } - if (direction.getZ() > 0) { - zDiagonalOffset = new BlockPos(0, 0, -1); - } else { - zDiagonalOffset = new BlockPos(0, 0, 1); - } - - //initialise the closest floor value outside of possible values - int closeFloorY = 1000; - - //loop though each block of a teleport checking each block if there are blocks in the way - for (double offset = 0; offset <= distance; offset++) { - Vec3d pos = startPos.add(direction.multiply(offset)); - BlockPos checkPos = BlockPos.ofFloored(pos); - - //check if there is a block at the check location - if (!canTeleportThrough(checkPos)) { - if (offset == 0) { - // no teleport can happen - return null; - } - return direction.multiply(offset - 1); - } - - //check if the block at head height is free - if (!canTeleportThrough(checkPos.up())) { - if (offset == 0) { - //cancel the check if starting height is too low - Vec3d justAhead = startPos.add(direction.multiply(0.2)); - if ((justAhead.getY() - Math.floor(justAhead.getY())) <= 0.495) { - continue; - } - // no teleport can happen - return null; - } - return direction.multiply(offset - 1); - } - - //check the diagonals to make sure player is not going through diagonal wall (full height block in the way on both sides at either height) - if (offset != 0 && (isBlockFloor(checkPos.add(xDiagonalOffset)) || isBlockFloor(checkPos.up().add(xDiagonalOffset))) && (isBlockFloor(checkPos.add(zDiagonalOffset)) || isBlockFloor(checkPos.up().add(zDiagonalOffset)))) { - return direction.multiply(offset - 1); - } - - //if the player is close to the floor (including diagonally) save Y and when player goes bellow this y finish teleport - if (offset != 0 && (isBlockFloor(checkPos.down()) || (isBlockFloor(checkPos.down().subtract(xDiagonalOffset)) && isBlockFloor(checkPos.down().subtract(zDiagonalOffset)))) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { - closeFloorY = checkPos.getY() - 1; - } - - //if the checking Y is same as closeY finish - if (closeFloorY == checkPos.getY()) { - return direction.multiply(offset - 1); - } - } - - //return full distance if no collision found - return direction.multiply(distance); - } - - /** - * Checks to see if a block is in the allowed list to teleport though - * Air, Buttons, carpets, crops, pots, mushrooms, nether wart, redstone, ladder, water, fire, lava, 3 or less snow layers - * - * @param blockPos block location - * @return if a block location can be teleported though - */ - private static Boolean canTeleportThrough(BlockPos blockPos) { - if (CLIENT.world == null) { - return false; - } - - BlockState blockState = CLIENT.world.getBlockState(blockPos); - if (blockState.isAir()) { - return true; - } - Block block = blockState.getBlock(); - return block instanceof ButtonBlock || block instanceof CarpetBlock || block instanceof CropBlock || block instanceof FlowerPotBlock || block.equals(Blocks.BROWN_MUSHROOM) || block.equals(Blocks.RED_MUSHROOM) || block.equals(Blocks.NETHER_WART) || block.equals(Blocks.REDSTONE_WIRE) || block.equals(Blocks.LADDER) || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); - } - - /** - * Checks to see if a block goes to the top if so class it as a floor - * - * @param blockPos block location - * @return if it's a floor block - */ - private static Boolean isBlockFloor(BlockPos blockPos) { - if (CLIENT.world == null) { - return false; - } - - BlockState blockState = CLIENT.world.getBlockState(blockPos); - VoxelShape shape = blockState.getCollisionShape(CLIENT.world, blockPos); - if (shape.isEmpty()) { - return false; - } - return shape.getBoundingBox().maxY == 1; - } - - /** - * works out where they player should be based on how far though the predicted teleport time. - * - * @return the camera position for the interpolated pos - */ - - public static Vec3d getInterpolatedPos() { - if (CLIENT.player == null || teleportVector == null || startPos == null || teleportDisabled) { - return null; - } - long gap = System.currentTimeMillis() - startTime; - //make sure the player is actually getting teleported if not disable teleporting until they are teleported again - if (System.currentTimeMillis() - lastTeleportTime > 1000) { - teleportDisabled = true; - startPos = null; - teleportVector = null; - teleportsAhead = 0; - return null; - } - double percentage = Math.min((double) (gap) / Math.min(lastPing, MAX_TELEPORT_TIME), 1); - - return cameraStartPos.add(teleportVector.multiply(percentage)); - } - - public static void updatePing(long ping) { - lastPing = ping; - } + 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 int teleportsAhead; + private static long lastTeleportTime; + private 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) { + //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") : 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 TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { + if (CLIENT.player == null) { + return null; + } + calculateTeleportUse(hand); + return TypedActionResult.pass(CLIENT.player.getStackInHand(hand)); + } + + /** + * 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") == 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.group(1)); + int predictedMana = SkyblockerMod.getInstance().statusBarTracker.getMana().value() - teleportsAhead * manaCost; + if (predictedMana < manaCost) { // todo the players mana can lag behind as it is updated server side. client side mana calculations would help with this + return; + } + } + + //work out start pos of warp and set start time. if there is an active warp going on make the end of that the start of the next one + if (teleportsAhead == 0 || startPos == null || teleportVector == null) { + //start of teleport sequence + startPos = CLIENT.player.getPos().add(0, 1.62, 0); // the eye poss should not be affected by crouching + cameraStartPos = CLIENT.player.getEyePos(); + lastTeleportTime = System.currentTimeMillis(); + } else { + //add to the end of the teleport sequence + startPos = startPos.add(teleportVector); + //set the camera start pos to how far though the teleport the player is to make is smoother + cameraStartPos = getInterpolatedPos(); + } + + startTime = System.currentTimeMillis(); + + + // calculate the vector the player will follow for the teleport + //get direction + float pitch = CLIENT.player.getPitch(); + float yaw = CLIENT.player.getYaw(); + Vec3d look = CLIENT.player.getRotationVector(pitch, yaw); + + //find target location depending on how far the item they are using takes them + teleportVector = raycast(distance, look, startPos); + if (teleportVector == null) { + startPos = null; + return; + } + + //compensate for hypixel round to center of block (to x.5 y.62 z.5) + Vec3d predictedEnd = startPos.add(teleportVector); + Vec3d offsetVec = new Vec3d(predictedEnd.x - roundToCenter(predictedEnd.x), predictedEnd.y - (Math.ceil(predictedEnd.y) + 0.62), predictedEnd.z - roundToCenter(predictedEnd.z)); + teleportVector = teleportVector.subtract(offsetVec); + //add 1 to teleports ahead + teleportsAhead += 1; + } + + /** + * Rounds a value to the nearest 0.5 + * + * @param input number to round + * @return rounded number + */ + private static double roundToCenter(double input) { + return Math.round(input - 0.5) + 0.5; + } + + /** + * Works out if the players location lets them use teleportation or not + * + * @return if the player should be allowed to teleport + */ + private static boolean isAllowedLocation() { + //check mines shafts + if (Utils.getMap().equals("Mineshaft")) { + return false; + } else if (Utils.getIslandArea().equals("⏣ Jungle Temple")) { //do not allow in jungle temple + return false; + } else if (Utils.getLocation() == Location.PRIVATE_ISLAND && !Utils.getIslandArea().equals("⏣ Your Island")) { //do not allow it when visiting + return false; + } else if (Utils.isInDungeons()) { //check places in dungeons where you can't teleport + if (DungeonManager.isInBoss() && DungeonManager.getBoss() == DungeonBoss.MAXOR) { + return false; + } + //make sure the player is in a room then check for disallowed rooms + if (!DungeonManager.isCurrentRoomMatched()) { + return true; + } + //does not work in boulder room + if (DungeonManager.getCurrentRoom().getName().equals("boxes-room")) { + return false; + } + //does not work in teleport maze room + if (DungeonManager.getCurrentRoom().getName().equals("teleport-pad-room")) { + return false; + } + //does not work in trap room + if (DungeonManager.getCurrentRoom().getName().startsWith("trap")) { + return false; + } + } + + return true; + } + + /** + * Custom raycast for teleporting checks for blocks for each 1 block forward in teleport. (very similar to hypixels method) + * + * @param distance maximum distance + * @return teleport vector + */ + private static Vec3d raycast(int distance, Vec3d direction, Vec3d startPos) { + if (CLIENT.world == null || direction == null || startPos == null) { + return null; + } + + //based on which way the ray is going get the needed vector for checking diagonals + BlockPos xDiagonalOffset; + BlockPos zDiagonalOffset; + if (direction.getX() > 0) { + xDiagonalOffset = new BlockPos(-1, 0, 0); + } else { + xDiagonalOffset = new BlockPos(1, 0, 0); + } + if (direction.getZ() > 0) { + zDiagonalOffset = new BlockPos(0, 0, -1); + } else { + zDiagonalOffset = new BlockPos(0, 0, 1); + } + + //initialise the closest floor value outside of possible values + int closeFloorY = 1000; + + //loop though each block of a teleport checking each block if there are blocks in the way + for (double offset = 0; offset <= distance; offset++) { + Vec3d pos = startPos.add(direction.multiply(offset)); + BlockPos checkPos = BlockPos.ofFloored(pos); + + //check if there is a block at the check location + if (!canTeleportThrough(checkPos)) { + if (offset == 0) { + // no teleport can happen + return null; + } + return direction.multiply(offset - 1); + } + + //check if the block at head height is free + if (!canTeleportThrough(checkPos.up())) { + if (offset == 0) { + //cancel the check if starting height is too low + Vec3d justAhead = startPos.add(direction.multiply(0.2)); + if ((justAhead.getY() - Math.floor(justAhead.getY())) <= 0.495) { + continue; + } + // no teleport can happen + return null; + } + return direction.multiply(offset - 1); + } + + //check the diagonals to make sure player is not going through diagonal wall (full height block in the way on both sides at either height) + if (offset != 0 && (isBlockFloor(checkPos.add(xDiagonalOffset)) || isBlockFloor(checkPos.up().add(xDiagonalOffset))) && (isBlockFloor(checkPos.add(zDiagonalOffset)) || isBlockFloor(checkPos.up().add(zDiagonalOffset)))) { + return direction.multiply(offset - 1); + } + + //if the player is close to the floor (including diagonally) save Y and when player goes bellow this y finish teleport + if (offset != 0 && (isBlockFloor(checkPos.down()) || (isBlockFloor(checkPos.down().subtract(xDiagonalOffset)) && isBlockFloor(checkPos.down().subtract(zDiagonalOffset)))) && (pos.getY() - Math.floor(pos.getY())) < 0.31) { + closeFloorY = checkPos.getY() - 1; + } + + //if the checking Y is same as closeY finish + if (closeFloorY == checkPos.getY()) { + return direction.multiply(offset - 1); + } + } + + //return full distance if no collision found + return direction.multiply(distance); + } + + /** + * Checks to see if a block is in the allowed list to teleport though + * Air, Buttons, carpets, crops, pots, mushrooms, nether wart, redstone, ladder, water, fire, lava, 3 or less snow layers + * + * @param blockPos block location + * @return if a block location can be teleported though + */ + private static Boolean canTeleportThrough(BlockPos blockPos) { + if (CLIENT.world == null) { + return false; + } + + BlockState blockState = CLIENT.world.getBlockState(blockPos); + if (blockState.isAir()) { + return true; + } + Block block = blockState.getBlock(); + return block instanceof ButtonBlock || block instanceof CarpetBlock || block instanceof CropBlock || block instanceof FlowerPotBlock || block.equals(Blocks.BROWN_MUSHROOM) || block.equals(Blocks.RED_MUSHROOM) || block.equals(Blocks.NETHER_WART) || block.equals(Blocks.REDSTONE_WIRE) || block.equals(Blocks.LADDER) || block.equals(Blocks.FIRE) || (block.equals(Blocks.SNOW) && blockState.get(Properties.LAYERS) <= 3) || block.equals(Blocks.WATER) || block.equals(Blocks.LAVA); + } + + /** + * Checks to see if a block goes to the top if so class it as a floor + * + * @param blockPos block location + * @return if it's a floor block + */ + private static Boolean isBlockFloor(BlockPos blockPos) { + if (CLIENT.world == null) { + return false; + } + + BlockState blockState = CLIENT.world.getBlockState(blockPos); + VoxelShape shape = blockState.getCollisionShape(CLIENT.world, blockPos); + if (shape.isEmpty()) { + return false; + } + return shape.getBoundingBox().maxY == 1; + } + + /** + * works out where they player should be based on how far though the predicted teleport time. + * + * @return the camera position for the interpolated pos + */ + + public static Vec3d getInterpolatedPos() { + if (CLIENT.player == null || teleportVector == null || startPos == null || teleportDisabled) { + return null; + } + long gap = System.currentTimeMillis() - startTime; + //make sure the player is actually getting teleported if not disable teleporting until they are teleported again + if (System.currentTimeMillis() - lastTeleportTime > Math.min(2 * lastPing, MAX_TELEPORT_TIME)) { + teleportDisabled = true; + startPos = null; + teleportVector = null; + teleportsAhead = 0; + return null; + } + double percentage = Math.min((double) (gap) / Math.min(lastPing, MAX_TELEPORT_TIME), 1); + + return cameraStartPos.add(teleportVector.multiply(percentage)); + } + + public static void updatePing(long ping) { + lastPing = ping; + } } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 2a48061391..1349eba58d 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -888,17 +888,17 @@ "skyblocker.config.uiAndVisuals.showEquipmentInInventory": "Show Equipment in Inventory", "skyblocker.config.uiAndVisuals.smoothAOTE": "Smooth AOTE", - "skyblocker.config.uiAndVisuals.smoothAOTE.@Tooltip": "Smooths out teleporting with right click teleport ability's", + "skyblocker.config.uiAndVisuals.smoothAOTE.@Tooltip": "Smooths out teleporting with right click teleport abilities.", "skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission": "Enable Ether Transmission", - "skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission.@Tooltip": "for: Etherwarp Conduit and Ether Merged", - "skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission": "Enable Instant Transmission ", - "skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission.@Tooltip": "for: AOTE and AOTV ", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableEtherTransmission.@Tooltip": "For: Etherwarp Conduit and Ether Merged.", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission": "Enable Instant Transmission", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableInstantTransmission.@Tooltip": "For: AOTE and AOTV.", "skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission": "Enable Sinrecall Transmission", - "skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission.@Tooltip": "for: Sinseeker Scythe", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableSinrecallTransmission.@Tooltip": "For: Sinseeker Scythe.", "skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission": "Enable Weird Transmission", - "skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission.@Tooltip": "for: Aspect of the Leech 1 and 2", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission.@Tooltip": "For: Aspect of the Leech.", "skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact": "Enable Wither Impact", - "skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact.@Tooltip": "for: Necron Blade, Hyperion, Scylla, Valkyrie", + "skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact.@Tooltip": "For: Necron's Blade, Hyperion, Astraea, Scylla, and Valkyrie.", "skyblocker.config.uiAndVisuals.tabHud": "Fancy HUD and TAB", From c502f259fd10a5a9fa6a4acfaf8efd03a9442ab9 Mon Sep 17 00:00:00 2001 From: olim Date: Sun, 29 Sep 2024 19:55:29 +0100 Subject: [PATCH 40/46] add check to see if smoothing is enabled --- .../mixins/ClientPlayNetworkHandlerMixin.java | 23 +++++++++---------- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index 3cf614bd37..564157f191 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -2,11 +2,10 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.config.configs.SlayersConfig; +import de.hysky.skyblocker.config.configs.UIAndVisualsConfig; import de.hysky.skyblocker.skyblock.CompactDamage; import de.hysky.skyblocker.skyblock.FishingHelper; import de.hysky.skyblocker.skyblock.SmoothAOTE; @@ -25,7 +24,6 @@ import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual; import de.hysky.skyblocker.utils.Utils; import net.minecraft.block.Blocks; -import net.minecraft.client.gui.hud.DebugHud; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; @@ -162,14 +160,15 @@ private void onPlayerTeleported(PlayerPositionLookS2CPacket packet, CallbackInfo SmoothAOTE.playerTeleported(); } - @ModifyExpressionValue(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowPacketSizeAndPingCharts()Z")) - private boolean shouldShowPacketSizeAndPingCharts(boolean original) { - //make the f3+3 screen always send ping packets even when closed - //this is needed to make smooth AOTE work - if (Utils.isOnSkyblock()) { - return true; - } - return original; + @ModifyExpressionValue(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowPacketSizeAndPingCharts()Z")) + private boolean shouldShowPacketSizeAndPingCharts(boolean original) { + //make the f3+3 screen always send ping packets even when closed + //this is needed to make smooth AOTE work so check if its enabled + UIAndVisualsConfig.SmoothAOTE options = SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE; + if (Utils.isOnSkyblock() && !SmoothAOTE.teleportDisabled && (options.enableWeirdTransmission || options.enableEtherTransmission || options.enableInstantTransmission || options.enableSinrecallTransmission || options.enableWitherImpact)) { + return true; + } + return original; - } + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 2e34bef6ad..7a42f3eac7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -44,7 +44,7 @@ public class SmoothAOTE { private static long lastPing; private static int teleportsAhead; private static long lastTeleportTime; - private static boolean teleportDisabled; + public static boolean teleportDisabled; @Init public static void init() { From 3b311e7be5448a991cd0e0bdb2678512942c5027 Mon Sep 17 00:00:00 2001 From: olim Date: Wed, 30 Oct 2024 20:38:15 +0000 Subject: [PATCH 41/46] fix rebase --- .../skyblocker/mixins/ClientPlayNetworkHandlerMixin.java | 1 - src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index 564157f191..b11a046c2c 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -23,7 +23,6 @@ import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListManager; import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual; import de.hysky.skyblocker.utils.Utils; -import net.minecraft.block.Blocks; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 7a42f3eac7..23eaf83e41 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -20,7 +20,6 @@ import net.minecraft.state.property.Properties; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -89,12 +88,12 @@ private static int extractTunedCustomData(NbtCompound customData, int baseRange) * @param hand held item * @return pass */ - private static TypedActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { + private static ActionResult onItemInteract(PlayerEntity playerEntity, World world, Hand hand) { if (CLIENT.player == null) { return null; } calculateTeleportUse(hand); - return TypedActionResult.pass(CLIENT.player.getStackInHand(hand)); + return ActionResult.PASS; } /** From 357dbd49eb6e1243ae30c5927d61e631eabfc784 Mon Sep 17 00:00:00 2001 From: olim Date: Sat, 11 Jan 2025 20:24:30 +0000 Subject: [PATCH 42/46] make the setting off by default --- .../skyblocker/config/configs/UIAndVisualsConfig.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java index 7ee27459e6..6feed6a466 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -334,19 +334,19 @@ public static class TeleportOverlay { public static class SmoothAOTE { @SerialEntry - public boolean enableWeirdTransmission = true; + public boolean enableWeirdTransmission = false; @SerialEntry - public boolean enableInstantTransmission = true; + public boolean enableInstantTransmission = false; @SerialEntry - public boolean enableEtherTransmission = true; + public boolean enableEtherTransmission = false; @SerialEntry - public boolean enableSinrecallTransmission = true; + public boolean enableSinrecallTransmission = false; @SerialEntry - public boolean enableWitherImpact = true; + public boolean enableWitherImpact = false; } public static class SearchOverlay { From 55259bbd99cb87328c2f6c8176224bad2e059954 Mon Sep 17 00:00:00 2001 From: olim Date: Sat, 11 Jan 2025 20:52:36 +0000 Subject: [PATCH 43/46] fix some glitchyness with changing ping by not updating the teleport duration while teleporting. this was causing the camera to jump if your ping changed mid teleport --- .../de/hysky/skyblocker/skyblock/SmoothAOTE.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 23eaf83e41..570f451ddc 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -18,6 +18,7 @@ import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.state.property.Properties; +import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -41,6 +42,7 @@ public class SmoothAOTE { 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; @@ -238,16 +240,19 @@ private static void calculateTeleportUse(Hand hand) { startPos = CLIENT.player.getPos().add(0, 1.62, 0); // the eye poss should not be affected by crouching cameraStartPos = CLIENT.player.getEyePos(); lastTeleportTime = System.currentTimeMillis(); + // update the ping used for the teleport + currentTeleportPing = lastPing; } else { //add to the end of the teleport sequence startPos = startPos.add(teleportVector); //set the camera start pos to how far though the teleport the player is to make is smoother cameraStartPos = getInterpolatedPos(); + //update the ping used for this part of the teleport + currentTeleportPing = lastPing; } startTime = System.currentTimeMillis(); - // calculate the vector the player will follow for the teleport //get direction float pitch = CLIENT.player.getPitch(); @@ -444,14 +449,15 @@ public static Vec3d getInterpolatedPos() { } long gap = System.currentTimeMillis() - startTime; //make sure the player is actually getting teleported if not disable teleporting until they are teleported again - if (System.currentTimeMillis() - lastTeleportTime > Math.min(2 * lastPing, MAX_TELEPORT_TIME)) { + if (System.currentTimeMillis() - lastTeleportTime > Math.min(2 * Math.max(lastPing, currentTeleportPing), MAX_TELEPORT_TIME)) { + System.out.println("sdf;lk"); teleportDisabled = true; startPos = null; teleportVector = null; teleportsAhead = 0; return null; } - double percentage = Math.min((double) (gap) / Math.min(lastPing, MAX_TELEPORT_TIME), 1); + double percentage = Math.min((double) (gap) / Math.min(currentTeleportPing, MAX_TELEPORT_TIME), 1); return cameraStartPos.add(teleportVector.multiply(percentage)); } From d17d92efec59a081d509c9ea1d75c0cac5314e97 Mon Sep 17 00:00:00 2001 From: olim Date: Sat, 11 Jan 2025 21:23:05 +0000 Subject: [PATCH 44/46] add option to smooth teleport more give the user the option to let the annimation lag behind the game so it does not jump to the end --- .../config/categories/UIAndVisualsCategory.java | 8 ++++++++ .../config/configs/UIAndVisualsConfig.java | 3 +++ .../de/hysky/skyblocker/skyblock/SmoothAOTE.java | 16 ++++++++++++++-- .../resources/assets/skyblocker/lang/en_us.json | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java index 227e1ae7e4..615401711d 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -443,6 +443,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.uiAndVisuals.smoothAOTE.enableWitherImpact = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag.@Tooltip"))) + .binding(defaults.uiAndVisuals.smoothAOTE.maximumAddedLag, + () -> config.uiAndVisuals.smoothAOTE.maximumAddedLag, + newValue -> config.uiAndVisuals.smoothAOTE.maximumAddedLag = newValue) + .controller(opt -> IntegerSliderControllerBuilder.create(opt).range(0, 500).step(1)) + .build()) .build()) //Search overlay diff --git a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java index 6feed6a466..ffe0dcce2a 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -347,6 +347,9 @@ public static class SmoothAOTE { @SerialEntry public boolean enableWitherImpact = false; + + @SerialEntry + public int maximumAddedLag = 100; } public static class SearchOverlay { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index 570f451ddc..fe9f94f788 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -18,7 +18,6 @@ import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.state.property.Properties; -import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -65,9 +64,15 @@ public static void playerTeleported() { //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; + } } @@ -450,7 +455,6 @@ public static Vec3d getInterpolatedPos() { long gap = System.currentTimeMillis() - startTime; //make sure the player is actually getting teleported if not disable teleporting until they are teleported again if (System.currentTimeMillis() - lastTeleportTime > Math.min(2 * Math.max(lastPing, currentTeleportPing), MAX_TELEPORT_TIME)) { - System.out.println("sdf;lk"); teleportDisabled = true; startPos = null; teleportVector = null; @@ -459,6 +463,14 @@ public static Vec3d getInterpolatedPos() { } double percentage = Math.min((double) (gap) / Math.min(currentTeleportPing, MAX_TELEPORT_TIME), 1); + //if the animation is done and the player has finished the teleport server side finish the teleport + if (teleportsAhead == 0 && percentage == 1) { + //reset when player has reached the end of the teleports + startPos = null; + teleportVector = null; + return null; + } + return cameraStartPos.add(teleportVector.multiply(percentage)); } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 1349eba58d..bde2904a2a 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -899,6 +899,8 @@ "skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission.@Tooltip": "For: Aspect of the Leech.", "skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact": "Enable Wither Impact", "skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact.@Tooltip": "For: Necron's Blade, Hyperion, Astraea, Scylla, and Valkyrie.", + "skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag": "Maximum Added Lag", + "skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag.@Tooltip": "How long the animation is allowed to get behind the game (if set to 0 smoothing will not had any lag).", "skyblocker.config.uiAndVisuals.tabHud": "Fancy HUD and TAB", From 6492415dd899601774903d4227416aed3ac0f226 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:04:43 -0500 Subject: [PATCH 45/46] Clean up ClientPlayNetworkHandlerMixin --- .../mixins/ClientPlayNetworkHandlerMixin.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index b11a046c2c..75604f72d8 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -42,6 +42,9 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +/** + * All mixins in this file should be arranged in the order of the methods they inject into. + */ @Mixin(ClientPlayNetworkHandler.class) public abstract class ClientPlayNetworkHandlerMixin { @Shadow @@ -75,6 +78,12 @@ public abstract class ClientPlayNetworkHandlerMixin { } } + @Inject(method = "onPlayerPositionLook", at = @At("TAIL")) + private void onPlayerTeleported(PlayerPositionLookS2CPacket packet, CallbackInfo ci) { + //player has been teleported by the server tell the smooth AOTE this + SmoothAOTE.playerTeleported(); + } + @ModifyVariable(method = "onItemPickupAnimation", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;removeEntity(ILnet/minecraft/entity/Entity$RemovalReason;)V", ordinal = 0)) private ItemEntity skyblocker$onItemPickup(ItemEntity itemEntity) { DungeonManager.onItemPickup(itemEntity); @@ -153,12 +162,6 @@ public abstract class ClientPlayNetworkHandlerMixin { WishingCompassSolver.onParticle(packet); } - @Inject(method = "onPlayerPositionLook", at = @At("TAIL")) - private void onPlayerTeleported(PlayerPositionLookS2CPacket packet, CallbackInfo ci) { - //player has been teleported by the server tell the smooth AOTE this - SmoothAOTE.playerTeleported(); - } - @ModifyExpressionValue(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowPacketSizeAndPingCharts()Z")) private boolean shouldShowPacketSizeAndPingCharts(boolean original) { //make the f3+3 screen always send ping packets even when closed @@ -168,6 +171,5 @@ private boolean shouldShowPacketSizeAndPingCharts(boolean original) { return true; } return original; - } } From 2e80c41e42896ddeba7dc8b695a9de2a33e600c4 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:38:27 -0500 Subject: [PATCH 46/46] Fix camera flashing when animation finishes before server teleports player --- src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 7 ++++--- src/main/resources/assets/skyblocker/lang/en_us.json | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java index fe9f94f788..73def44c8e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java @@ -454,17 +454,18 @@ public static Vec3d getInterpolatedPos() { } long gap = System.currentTimeMillis() - startTime; //make sure the player is actually getting teleported if not disable teleporting until they are teleported again - if (System.currentTimeMillis() - lastTeleportTime > Math.min(2 * Math.max(lastPing, currentTeleportPing), MAX_TELEPORT_TIME)) { + if (System.currentTimeMillis() - lastTeleportTime > Math.min(Math.max(lastPing, currentTeleportPing) + SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.maximumAddedLag, MAX_TELEPORT_TIME)) { teleportDisabled = true; startPos = null; teleportVector = null; teleportsAhead = 0; return null; } - double percentage = Math.min((double) (gap) / Math.min(currentTeleportPing, MAX_TELEPORT_TIME), 1); + long estimatedTeleportTime = Math.min(currentTeleportPing, MAX_TELEPORT_TIME); + double percentage = Math.clamp((double) (gap) / estimatedTeleportTime, 0, 1); // Sanity clamp //if the animation is done and the player has finished the teleport server side finish the teleport - if (teleportsAhead == 0 && percentage == 1) { + if (teleportsAhead == 0 && gap >= estimatedTeleportTime + SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.maximumAddedLag) { //reset when player has reached the end of the teleports startPos = null; teleportVector = null; diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index bde2904a2a..0a7dac78c4 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -899,8 +899,8 @@ "skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission.@Tooltip": "For: Aspect of the Leech.", "skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact": "Enable Wither Impact", "skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact.@Tooltip": "For: Necron's Blade, Hyperion, Astraea, Scylla, and Valkyrie.", - "skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag": "Maximum Added Lag", - "skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag.@Tooltip": "How long the animation is allowed to get behind the game (if set to 0 smoothing will not had any lag).", + "skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag": "Maximum Added Lag (ms)", + "skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag.@Tooltip": "How long the animation is allowed to get behind the game in milliseconds. (If set to 0, smoothing will not have any lag, but stuttering will likely occur. Increase this value if you're experiencing flashing.)", "skyblocker.config.uiAndVisuals.tabHud": "Fancy HUD and TAB",