Skip to content

Commit 693fd7b

Browse files
committed
[fix] make fix smarter
1 parent bf29ad9 commit 693fd7b

File tree

1 file changed

+30
-4
lines changed
  • src/main/java/meteordevelopment/meteorclient/systems/modules/movement

1 file changed

+30
-4
lines changed

src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Step.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.google.common.collect.Streams;
99
import meteordevelopment.meteorclient.events.world.TickEvent;
10+
import meteordevelopment.meteorclient.mixininterface.IVec3d;
1011
import meteordevelopment.meteorclient.pathing.PathManagers;
1112
import meteordevelopment.meteorclient.settings.*;
1213
import meteordevelopment.meteorclient.systems.modules.Categories;
@@ -17,6 +18,8 @@
1718
import net.minecraft.entity.attribute.EntityAttributes;
1819
import net.minecraft.entity.decoration.EndCrystalEntity;
1920
import net.minecraft.util.math.Box;
21+
import net.minecraft.util.math.Vec2f;
22+
import net.minecraft.util.math.Vec3d;
2023

2124
import java.util.OptionalDouble;
2225

@@ -105,25 +108,48 @@ private boolean isSafe() {
105108
return ((getHealth() > stepHealth.get() && getHealth() - getExplosionDamage() > stepHealth.get()));
106109
}
107110

111+
private boolean isSaferThanWith(double damage) {
112+
return (isSafe() || getExplosionDamage() - damage <= 0);
113+
}
114+
108115
private double getMaxSafeHeight() {
109-
if (!safeStep.get() || !isSafe()) return height.get();
116+
if (!safeStep.get()) return height.get();
110117
double max = height.get();
111118
double h = 0;
119+
double currentDamage =getExplosionDamage();
112120
Box initial = mc.player.getBoundingBox();
121+
122+
// all of this is to avoid running into crystals which are behind
123+
// one block when holding a movement key because standing on the
124+
// near edge of that block is technically safe
125+
126+
Vec3d inputOffset = mc.player.getRotationVector();
127+
Vec2f input = mc.player.input.getMovementInput();
128+
((IVec3d) inputOffset).meteor$setY(0);
129+
inputOffset = inputOffset.normalize().multiply(1.2);
130+
double zdot = inputOffset.z;
131+
double xdot = inputOffset.x;
132+
inputOffset = new Vec3d(input.y * xdot + input.x * zdot, 0, input.x * xdot + input.y * zdot);
133+
113134
for (int i = 1; i < max; i++) {
114135
mc.player.setBoundingBox(initial.offset(0, i, 0));
115-
if (!isSafe()) {
136+
if (!isSaferThanWith(currentDamage)) {
137+
mc.player.setBoundingBox(initial);
138+
return h;
139+
}
140+
141+
mc.player.setBoundingBox(mc.player.getBoundingBox().offset(inputOffset));
142+
if (!isSaferThanWith(currentDamage)) {
116143
mc.player.setBoundingBox(initial);
117144
return h;
118145
}
119146
h += 1;
120147
}
121148
mc.player.setBoundingBox(initial.offset(0, max, 0));
122149

123-
if (isSafe()) h = max;
150+
if (isSaferThanWith(currentDamage)) h = max;
124151

125152
mc.player.setBoundingBox(initial);
126-
127153
return h;
128154
}
129155

0 commit comments

Comments
 (0)