Skip to content

Commit

Permalink
修复速度buff误判
Browse files Browse the repository at this point in the history
fix speed
  • Loading branch information
xia-mc committed Apr 5, 2024
1 parent 3765f7f commit 819b050
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range;
Expand Down Expand Up @@ -31,6 +32,7 @@ public class TRPlayer {
public boolean hasSetback = false;
public boolean jumping = false;
public boolean lastUsingItem = false;
public double speedMul = 1;

public TimeTaskManager timeTask = new TimeTaskManager();

Expand All @@ -50,6 +52,9 @@ public void update(AbstractClientPlayer player) {
if (fabricPlayer == null) return;

currentPos = fabricPlayer.position();
speedMul = fabricPlayer.getActiveEffectsMap().containsKey(MobEffects.MOVEMENT_SPEED)
? fabricPlayer.getActiveEffectsMap().get(MobEffects.MOVEMENT_SPEED).getAmplifier() * 0.2 + 1
: 1;
updatePoses();
if (fabricPlayer.onGround()) {
lastOnGroundPos = currentPos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void _onTick() {

final double secSpeed = PlayerMove.getXzSecSpeed(player.lastPos, player.currentPos);

if (secSpeed > SLOW_SPEED.get(itemUseTick) * (1 + player.fabricPlayer.getSpeed()) + CONFIG().getThreshold()) {
if (secSpeed > SLOW_SPEED.get(itemUseTick) * player.speedMul + CONFIG().getThreshold()) {
flag();
}
if (itemUseTick < SLOW_SPEED.size() - 1) itemUseTick++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ else if (player.fabricPlayer.isSilent())
maxSecSpeed = 4.317;

final double speed = PlayerMove.getXzSecSpeed(player.lastPos, player.currentPos);
if (speed > (maxSecSpeed * (1 + player.fabricPlayer.getSpeed()) + CONFIG().getThreshold())) {
if (speed > (maxSecSpeed * player.speedMul + CONFIG().getThreshold())) {
flag(String.valueOf(speed));
}
}
Expand Down

0 comments on commit 819b050

Please sign in to comment.