From 0921dd362a49e36fbbe84838a44020a3b4d61381 Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 20 Aug 2024 19:59:45 +0100 Subject: [PATCH 01/41] 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 fe35e7d2d6..2da70a7127 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.crimson.slayer.FirePillarAnnouncer; @@ -27,6 +28,7 @@ import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.network.packet.s2c.play.*; 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; @@ -135,4 +137,10 @@ public abstract class ClientPlayNetworkHandlerMixin { private void skyblocker$onEntityEquip(EntityEquipmentUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) { EggFinder.checkIfEgg(entity); } + + @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 b011be6d59..0ea5e2776d 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 ee3707a5c2fce575b14aa1acee1e6bf124439a48 Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 20 Aug 2024 21:49:57 +0100 Subject: [PATCH 02/41] 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 | 3 +++ 6 files changed, 54 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 fa9bf37648..7961702edd 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -295,6 +295,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 598cbf5498..c59ba54259 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -55,6 +55,9 @@ public class UIAndVisualsConfig { @SerialEntry public TeleportOverlay teleportOverlay = new TeleportOverlay(); + @SerialEntry + public SmoothAOTE smoothAOTE = new SmoothAOTE(); + @SerialEntry public SearchOverlay searchOverlay = new SearchOverlay(); @@ -223,6 +226,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 2da70a7127..47d49c6276 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; @@ -20,6 +22,8 @@ import de.hysky.skyblocker.skyblock.slayers.SlayerEntitiesGlow; 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; @@ -143,4 +147,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 eea3fd24b0..28fbf34c87 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -778,6 +778,9 @@ "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 tab HUD (Temporarily disabled outside dungeons)", "skyblocker.config.uiAndVisuals.tabHud.enableHudBackground": "Enable HUD Background", "skyblocker.config.uiAndVisuals.tabHud.enableHudBackground.@Tooltip": "Enables the background of the non-tab HUD.", From be16f78fbd66b08c1516dcb6804fecdfe34e5916 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 22 Aug 2024 21:32:08 +0100 Subject: [PATCH 03/41] 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 7961702edd..14138b30c6 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -307,6 +307,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 c59ba54259..73489b87d3 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -230,6 +230,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 28fbf34c87..268fa41a3d 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -779,7 +779,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 tab HUD (Temporarily disabled outside dungeons)", "skyblocker.config.uiAndVisuals.tabHud.enableHudBackground": "Enable HUD Background", From a4f885f7971a70f0479ef4542c8b64c127b31584 Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 26 Aug 2024 22:16:42 +0100 Subject: [PATCH 04/41] 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 f80becd03f0da6f9fd6d3e3c5e329f7bb89e79a3 Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 27 Aug 2024 12:14:56 +0100 Subject: [PATCH 05/41] 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 f204392d85c85de198cd4def52360c849fdfea39 Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 27 Aug 2024 12:36:30 +0100 Subject: [PATCH 06/41] 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 14138b30c6..c2430f4267 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -298,15 +298,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 73489b87d3..c892a82f23 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -227,8 +227,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 47d49c6276..90d13d6187 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -144,13 +144,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 268fa41a3d..0eb1a13716 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -779,8 +779,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 b82c18bdf5d2e2b6cf6cad30c210d1fba80f7171 Mon Sep 17 00:00:00 2001 From: olim Date: Tue, 27 Aug 2024 21:37:12 +0100 Subject: [PATCH 07/41] 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 6615a4620588a7de8355494cd37b061de02886ed Mon Sep 17 00:00:00 2001 From: olim Date: Wed, 28 Aug 2024 10:55:47 +0100 Subject: [PATCH 08/41] clean --- .../skyblocker/config/configs/UIAndVisualsConfig.java | 1 - src/main/java/de/hysky/skyblocker/mixins/CameraMixin.java | 1 - .../skyblocker/mixins/ClientPlayNetworkHandlerMixin.java | 7 ++++--- .../java/de/hysky/skyblocker/mixins/PingMeasurerMixin.java | 1 - src/main/resources/assets/skyblocker/lang/en_us.json | 2 +- 5 files changed, 5 insertions(+), 7 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 c892a82f23..4daad52538 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -242,7 +242,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 90d13d6187..62564a6212 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -15,8 +15,9 @@ import de.hysky.skyblocker.skyblock.crimson.slayer.FirePillarAnnouncer; import de.hysky.skyblocker.skyblock.dungeon.DungeonScore; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager; -import de.hysky.skyblocker.skyblock.dwarven.WishingCompassSolver; import de.hysky.skyblocker.skyblock.dwarven.CrystalsChestHighlighter; +import de.hysky.skyblocker.skyblock.dwarven.WishingCompassSolver; +import de.hysky.skyblocker.skyblock.end.BeaconHighlighter; import de.hysky.skyblocker.skyblock.end.EnderNodes; import de.hysky.skyblocker.skyblock.end.TheEnd; import de.hysky.skyblocker.skyblock.slayers.SlayerEntitiesGlow; @@ -32,7 +33,6 @@ import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.network.packet.s2c.play.*; 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; @@ -127,7 +127,8 @@ public abstract class ClientPlayNetworkHandlerMixin { } } - if (SkyblockerConfigManager.get().slayers.blazeSlayer.firePillarCountdown != SlayersConfig.BlazeSlayer.FirePillar.OFF) FirePillarAnnouncer.checkFirePillar(entity); + if (SkyblockerConfigManager.get().slayers.blazeSlayer.firePillarCountdown != SlayersConfig.BlazeSlayer.FirePillar.OFF) + FirePillarAnnouncer.checkFirePillar(entity); EggFinder.checkIfEgg(armorStandEntity); try { //Prevent packet handling fails if something goes wrong so that entity trackers still update, just without compact damage numbers 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 0eb1a13716..0aa1c16afc 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -779,7 +779,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 24a6898fe4614797c096ef8746273d1189983e56 Mon Sep 17 00:00:00 2001 From: olim Date: Wed, 28 Aug 2024 11:05:20 +0100 Subject: [PATCH 09/41] 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 3b2123e60635086f03be526670bf3711de6a5b45 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 29 Aug 2024 11:19:45 +0100 Subject: [PATCH 10/41] 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 62564a6212..84396ff78f 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -153,7 +153,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 0aa1c16afc..f517e67b7e 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -781,10 +781,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 tab HUD (Temporarily disabled outside dungeons)", "skyblocker.config.uiAndVisuals.tabHud.enableHudBackground": "Enable HUD Background", From 6b443c0bae1fafb0e8054dabd4be8470571e1497 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 29 Aug 2024 11:28:28 +0100 Subject: [PATCH 11/41] 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 4f0431d35f8224bdae02513149a1d7200967bd57 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 29 Aug 2024 11:35:16 +0100 Subject: [PATCH 12/41] 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 8c5232cea6158ec24d3dc1de18cdb2abb70d31bf Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 29 Aug 2024 11:37:41 +0100 Subject: [PATCH 13/41] 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 c2430f4267..7b3f60d940 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -295,6 +295,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")) @@ -302,6 +303,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) @@ -309,6 +311,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) @@ -316,6 +319,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) @@ -323,6 +327,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) @@ -330,6 +335,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 dbb3b665932f3285ea7645dfe731492717f7254f Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 29 Aug 2024 11:46:33 +0100 Subject: [PATCH 14/41] 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 84396ff78f..11fb91a128 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -146,7 +146,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 fbfaec0e74844b73865bbce4e3841bda7edb5363 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/41] 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 11fb91a128..f3ff67d04f 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -156,7 +156,7 @@ private boolean shouldShowPacketSizeAndPingCharts(DebugHud instance, Operation Date: Thu, 29 Aug 2024 22:33:16 +0100 Subject: [PATCH 16/41] 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 7daca34f631cadaec55286033c972fc48644a7c0 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 30 Aug 2024 12:01:44 +0100 Subject: [PATCH 17/41] 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 03ad7433f0af29359d86d4dd869afcd50ded92b6 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 30 Aug 2024 12:16:02 +0100 Subject: [PATCH 18/41] 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 afcdd33a9b4af74463ffc0b64eb54f383ae4fa28 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 30 Aug 2024 12:30:17 +0100 Subject: [PATCH 19/41] 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 f81386a0df7a80054b815651bd5d2e080c11a787 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 30 Aug 2024 12:38:09 +0100 Subject: [PATCH 20/41] 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 055f7102ff80ea245a8be02c80db75986128062e Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 30 Aug 2024 13:01:31 +0100 Subject: [PATCH 21/41] 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 7924e1eec7f7be49cfe0dc8a627ed0a3e00e4c70 Mon Sep 17 00:00:00 2001 From: olim Date: Wed, 4 Sep 2024 15:54:37 +0100 Subject: [PATCH 22/41] 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 a9f591eba9f3fac5a7e0ec4ed6d2111d6fbbd0b3 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 12 Sep 2024 16:29:49 +0100 Subject: [PATCH 23/41] 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 b6ed1a5347b65bd2b423fd50c7d227aeee18768f Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 12 Sep 2024 23:50:29 +0100 Subject: [PATCH 24/41] 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 91bc40447d3c2eda0f486e37594772d6da5e0d67 Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 12 Sep 2024 23:54:20 +0100 Subject: [PATCH 25/41] 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 5e930dda6324af608ccb53c676d2918e0bad5d8a Mon Sep 17 00:00:00 2001 From: olim Date: Thu, 12 Sep 2024 23:59:05 +0100 Subject: [PATCH 26/41] 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 0d59dabeee1cd34562485231d69482de92dfd222 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 20:47:48 +0100 Subject: [PATCH 27/41] 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 61cf9fb618e5ac8098be7ac1932a37eeb02cd4f5 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 21:04:44 +0100 Subject: [PATCH 28/41] 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 66fd33f87c4e2d2de60c0375f3d7751d681d3dde Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 21:08:00 +0100 Subject: [PATCH 29/41] 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 6f1e96783be42af15924e6e43217c6cf57541e3f Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 21:31:52 +0100 Subject: [PATCH 30/41] 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 94d08a841654d69039caf25b71c79de9ce7c7d1a Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 21:55:23 +0100 Subject: [PATCH 31/41] 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 68bb2a33f8636e6dd03b26bca66c28d83a862ed0 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 22:49:58 +0100 Subject: [PATCH 32/41] 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 4413d74a95b14e6bf13389eba1ca0012b24f94c9 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 22:58:58 +0100 Subject: [PATCH 33/41] 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 b1130e923fddfea6164419b68fcbae10afe4c863 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 23:07:24 +0100 Subject: [PATCH 34/41] 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 0e467091da72c7168f7f7875f0d7375ecdc576fa Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 23:12:34 +0100 Subject: [PATCH 35/41] 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 23f09cfdf63259be334257369d85cd14df589eef Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 13 Sep 2024 23:20:02 +0100 Subject: [PATCH 36/41] 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 96abfd87aa455e7fb7e3f759651e1916e9cb291b Mon Sep 17 00:00:00 2001 From: olim Date: Sat, 14 Sep 2024 19:55:13 +0100 Subject: [PATCH 37/41] 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 48361f1c74127c7597ffb4a5005edddd239b60fb 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/41] 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 f3ff67d04f..fbb7a653d0 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -156,7 +156,7 @@ private boolean shouldShowPacketSizeAndPingCharts(DebugHud instance, Operation Date: Wed, 18 Sep 2024 21:03:32 +0100 Subject: [PATCH 39/41] 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 fbb7a653d0..9243f20841 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -149,14 +149,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 f517e67b7e..a531fabbc1 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -779,17 +779,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 tab HUD (Temporarily disabled outside dungeons)", "skyblocker.config.uiAndVisuals.tabHud.enableHudBackground": "Enable HUD Background", From ea2840572e340f14a903c9558a5983ae6bd7502f Mon Sep 17 00:00:00 2001 From: olim Date: Sun, 29 Sep 2024 19:55:29 +0100 Subject: [PATCH 40/41] add check to see if smoothing is enabled --- .../mixins/ClientPlayNetworkHandlerMixin.java | 213 +++++++++--------- .../hysky/skyblocker/skyblock/SmoothAOTE.java | 2 +- 2 files changed, 107 insertions(+), 108 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index 9243f20841..87e8ffd48f 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; @@ -24,7 +23,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; @@ -47,9 +45,9 @@ public abstract class ClientPlayNetworkHandlerMixin { @Shadow private ClientWorld world; - @Shadow - @Final - private static Logger LOGGER; + @Shadow + @Final + private static Logger LOGGER; @Inject(method = "method_64896", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;removeEntity(ILnet/minecraft/entity/Entity$RemovalReason;)V")) private void skyblocker$onItemDestroy(int entityId, CallbackInfo ci) { @@ -58,105 +56,106 @@ public abstract class ClientPlayNetworkHandlerMixin { } } - @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); - return itemEntity; - } - - @WrapWithCondition(method = "onEntityPassengersSet", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;)V", remap = false)) - private boolean skyblocker$cancelEntityPassengersWarning(Logger instance, String msg) { - return !Utils.isOnHypixel(); - } - - @WrapWithCondition(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false)) - private boolean skyblocker$cancelPlayerListWarning(Logger instance, String format, Object arg1, Object arg2) { - return !Utils.isOnHypixel(); - } - - @Inject(method = "onPlaySound", at = @At("RETURN")) - private void skyblocker$onPlaySound(PlaySoundS2CPacket packet, CallbackInfo ci) { - FishingHelper.onSound(packet); - CrystalsChestHighlighter.onSound(packet); - } - - @WrapWithCondition(method = "warnOnUnknownPayload", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) - private boolean skyblocker$dropBadlionPacketWarnings(Logger instance, String message, Object identifier) { - return !(Utils.isOnHypixel() && ((Identifier) identifier).getNamespace().equals("badlion")); - } - - @WrapWithCondition(method = {"onScoreboardScoreUpdate", "onScoreboardScoreReset"}, at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) - private boolean skyblocker$cancelUnknownScoreboardObjectiveWarnings(Logger instance, String message, Object objectiveName) { - return !Utils.isOnHypixel(); - } - - @WrapWithCondition(method = "onTeam", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;[Ljava/lang/Object;)V", remap = false)) - private boolean skyblocker$cancelTeamWarning(Logger instance, String format, Object... arg) { - return !Utils.isOnHypixel(); - } - - @Inject(method = "onParticle", at = @At("RETURN")) - private void skyblocker$onParticle(ParticleS2CPacket packet, CallbackInfo ci) { - MythologicalRitual.onParticle(packet); - DojoManager.onParticle(packet); - CrystalsChestHighlighter.onParticle(packet); - EnderNodes.onParticle(packet); - WishingCompassSolver.onParticle(packet); - } - - @ModifyExpressionValue(method = "onEntityStatus", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/EntityStatusS2CPacket;getEntity(Lnet/minecraft/world/World;)Lnet/minecraft/entity/Entity;")) - private Entity skyblocker$onEntityDeath(Entity entity, @Local(argsOnly = true) EntityStatusS2CPacket packet) { - if (packet.getStatus() == EntityStatuses.PLAY_DEATH_SOUND_OR_ADD_PROJECTILE_HIT_PARTICLES) { - DungeonScore.handleEntityDeath(entity); - TheEnd.onEntityDeath(entity); - SlayerEntitiesGlow.onEntityDeath(entity); - } - return entity; - } - - @Inject(method = "onEntityTrackerUpdate", at = @At("TAIL")) - private void skyblocker$onEntityTrackerUpdate(EntityTrackerUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) { - if (!(entity instanceof ArmorStandEntity armorStandEntity)) return; - - if (SkyblockerConfigManager.get().slayers.highlightMinis == SlayersConfig.HighlightSlayerEntities.GLOW && SlayerEntitiesGlow.isSlayerMiniMob(armorStandEntity) - || SkyblockerConfigManager.get().slayers.highlightBosses == SlayersConfig.HighlightSlayerEntities.GLOW && SlayerEntitiesGlow.isSlayer(armorStandEntity)) { - if (armorStandEntity.isDead()) { - SlayerEntitiesGlow.cleanupArmorstand(armorStandEntity); - } else { - SlayerEntitiesGlow.setSlayerMobGlow(armorStandEntity); - } - } - - if (SkyblockerConfigManager.get().slayers.blazeSlayer.firePillarCountdown != SlayersConfig.BlazeSlayer.FirePillar.OFF) - FirePillarAnnouncer.checkFirePillar(entity); - - EggFinder.checkIfEgg(armorStandEntity); - try { //Prevent packet handling fails if something goes wrong so that entity trackers still update, just without compact damage numbers - CompactDamage.compactDamage(armorStandEntity); - } catch (Exception e) { - LOGGER.error("[Skyblocker Compact Damage] Failed to compact damage number", e); - } - } - - @Inject(method = "onEntityEquipmentUpdate", at = @At(value = "TAIL")) - private void skyblocker$onEntityEquip(EntityEquipmentUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) { - EggFinder.checkIfEgg(entity); - } - - @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 - //this is needed to make smooth AOTE work - if (Utils.isOnSkyblock()) { - return true; - } - return original; - - } + @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); + return itemEntity; + } + + @WrapWithCondition(method = "onEntityPassengersSet", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;)V", remap = false)) + private boolean skyblocker$cancelEntityPassengersWarning(Logger instance, String msg) { + return !Utils.isOnHypixel(); + } + + @WrapWithCondition(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false)) + private boolean skyblocker$cancelPlayerListWarning(Logger instance, String format, Object arg1, Object arg2) { + return !Utils.isOnHypixel(); + } + + @Inject(method = "onPlaySound", at = @At("RETURN")) + private void skyblocker$onPlaySound(PlaySoundS2CPacket packet, CallbackInfo ci) { + FishingHelper.onSound(packet); + CrystalsChestHighlighter.onSound(packet); + } + + @WrapWithCondition(method = "warnOnUnknownPayload", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) + private boolean skyblocker$dropBadlionPacketWarnings(Logger instance, String message, Object identifier) { + return !(Utils.isOnHypixel() && ((Identifier) identifier).getNamespace().equals("badlion")); + } + + @WrapWithCondition(method = {"onScoreboardScoreUpdate", "onScoreboardScoreReset"}, at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false)) + private boolean skyblocker$cancelUnknownScoreboardObjectiveWarnings(Logger instance, String message, Object objectiveName) { + return !Utils.isOnHypixel(); + } + + @WrapWithCondition(method = "onTeam", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;[Ljava/lang/Object;)V", remap = false)) + private boolean skyblocker$cancelTeamWarning(Logger instance, String format, Object... arg) { + return !Utils.isOnHypixel(); + } + + @Inject(method = "onParticle", at = @At("RETURN")) + private void skyblocker$onParticle(ParticleS2CPacket packet, CallbackInfo ci) { + MythologicalRitual.onParticle(packet); + DojoManager.onParticle(packet); + CrystalsChestHighlighter.onParticle(packet); + EnderNodes.onParticle(packet); + WishingCompassSolver.onParticle(packet); + } + + @ModifyExpressionValue(method = "onEntityStatus", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/EntityStatusS2CPacket;getEntity(Lnet/minecraft/world/World;)Lnet/minecraft/entity/Entity;")) + private Entity skyblocker$onEntityDeath(Entity entity, @Local(argsOnly = true) EntityStatusS2CPacket packet) { + if (packet.getStatus() == EntityStatuses.PLAY_DEATH_SOUND_OR_ADD_PROJECTILE_HIT_PARTICLES) { + DungeonScore.handleEntityDeath(entity); + TheEnd.onEntityDeath(entity); + SlayerEntitiesGlow.onEntityDeath(entity); + } + return entity; + } + + @Inject(method = "onEntityTrackerUpdate", at = @At("TAIL")) + private void skyblocker$onEntityTrackerUpdate(EntityTrackerUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) { + if (!(entity instanceof ArmorStandEntity armorStandEntity)) return; + + if (SkyblockerConfigManager.get().slayers.highlightMinis == SlayersConfig.HighlightSlayerEntities.GLOW && SlayerEntitiesGlow.isSlayerMiniMob(armorStandEntity) + || SkyblockerConfigManager.get().slayers.highlightBosses == SlayersConfig.HighlightSlayerEntities.GLOW && SlayerEntitiesGlow.isSlayer(armorStandEntity)) { + if (armorStandEntity.isDead()) { + SlayerEntitiesGlow.cleanupArmorstand(armorStandEntity); + } else { + SlayerEntitiesGlow.setSlayerMobGlow(armorStandEntity); + } + } + + if (SkyblockerConfigManager.get().slayers.blazeSlayer.firePillarCountdown != SlayersConfig.BlazeSlayer.FirePillar.OFF) + FirePillarAnnouncer.checkFirePillar(entity); + + EggFinder.checkIfEgg(armorStandEntity); + try { //Prevent packet handling fails if something goes wrong so that entity trackers still update, just without compact damage numbers + CompactDamage.compactDamage(armorStandEntity); + } catch (Exception e) { + LOGGER.error("[Skyblocker Compact Damage] Failed to compact damage number", e); + } + } + + @Inject(method = "onEntityEquipmentUpdate", at = @At(value = "TAIL")) + private void skyblocker$onEntityEquip(EntityEquipmentUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) { + EggFinder.checkIfEgg(entity); + } + + @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 + //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 466a2dfa45ba363f868617209b269af0e3bec3c9 Mon Sep 17 00:00:00 2001 From: olim Date: Wed, 30 Oct 2024 20:38:15 +0000 Subject: [PATCH 41/41] fix rebase --- .../skyblocker/mixins/ClientPlayNetworkHandlerMixin.java | 2 -- src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java | 5 ++--- 2 files changed, 2 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 87e8ffd48f..8e231a2a53 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -16,13 +16,11 @@ import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager; import de.hysky.skyblocker.skyblock.dwarven.CrystalsChestHighlighter; import de.hysky.skyblocker.skyblock.dwarven.WishingCompassSolver; -import de.hysky.skyblocker.skyblock.end.BeaconHighlighter; import de.hysky.skyblocker.skyblock.end.EnderNodes; import de.hysky.skyblocker.skyblock.end.TheEnd; import de.hysky.skyblocker.skyblock.slayers.SlayerEntitiesGlow; 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; } /**