Skip to content

Commit

Permalink
add option to smooth teleport more
Browse files Browse the repository at this point in the history
give the user the option to let the annimation lag behind the game so it does not jump to the end
  • Loading branch information
olim88 committed Jan 11, 2025
1 parent 55259bb commit d17d92e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,14 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.uiAndVisuals.smoothAOTE.enableWitherImpact = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Integer>createBuilder()
.name(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag.@Tooltip")))
.binding(defaults.uiAndVisuals.smoothAOTE.maximumAddedLag,
() -> config.uiAndVisuals.smoothAOTE.maximumAddedLag,
newValue -> config.uiAndVisuals.smoothAOTE.maximumAddedLag = newValue)
.controller(opt -> IntegerSliderControllerBuilder.create(opt).range(0, 500).step(1))
.build())
.build())

//Search overlay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ public static class SmoothAOTE {

@SerialEntry
public boolean enableWitherImpact = false;

@SerialEntry
public int maximumAddedLag = 100;
}

public static class SearchOverlay {
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/de/hysky/skyblocker/skyblock/SmoothAOTE.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.state.property.Properties;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
Expand Down Expand Up @@ -65,9 +64,15 @@ public static void playerTeleported() {

//if the server is in sync in number of teleports
if (teleportsAhead == 0) {
//see if the teleport has a small amount left to continue animating instead of jumping to the end
long timeLeft = (currentTeleportPing - (System.currentTimeMillis() - startTime));
if (timeLeft > 0 && timeLeft <= SkyblockerConfigManager.get().uiAndVisuals.smoothAOTE.maximumAddedLag) {
return;
}
//reset when player has reached the end of the teleports
startPos = null;
teleportVector = null;

}
}

Expand Down Expand Up @@ -450,7 +455,6 @@ public static Vec3d getInterpolatedPos() {
long gap = System.currentTimeMillis() - startTime;
//make sure the player is actually getting teleported if not disable teleporting until they are teleported again
if (System.currentTimeMillis() - lastTeleportTime > Math.min(2 * Math.max(lastPing, currentTeleportPing), MAX_TELEPORT_TIME)) {
System.out.println("sdf;lk");
teleportDisabled = true;
startPos = null;
teleportVector = null;
Expand All @@ -459,6 +463,14 @@ public static Vec3d getInterpolatedPos() {
}
double percentage = Math.min((double) (gap) / Math.min(currentTeleportPing, MAX_TELEPORT_TIME), 1);

//if the animation is done and the player has finished the teleport server side finish the teleport
if (teleportsAhead == 0 && percentage == 1) {
//reset when player has reached the end of the teleports
startPos = null;
teleportVector = null;
return null;
}

return cameraStartPos.add(teleportVector.multiply(percentage));
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,8 @@
"skyblocker.config.uiAndVisuals.smoothAOTE.enableWeirdTransmission.@Tooltip": "For: Aspect of the Leech.",
"skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact": "Enable Wither Impact",
"skyblocker.config.uiAndVisuals.smoothAOTE.enableWitherImpact.@Tooltip": "For: Necron's Blade, Hyperion, Astraea, Scylla, and Valkyrie.",
"skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag": "Maximum Added Lag",
"skyblocker.config.uiAndVisuals.smoothAOTE.maximumAddedLag.@Tooltip": "How long the animation is allowed to get behind the game (if set to 0 smoothing will not had any lag).",


"skyblocker.config.uiAndVisuals.tabHud": "Fancy HUD and TAB",
Expand Down

0 comments on commit d17d92e

Please sign in to comment.