|
7 | 7 |
|
8 | 8 | import com.google.common.collect.Streams; |
9 | 9 | import meteordevelopment.meteorclient.events.world.TickEvent; |
| 10 | +import meteordevelopment.meteorclient.mixininterface.IVec3d; |
10 | 11 | import meteordevelopment.meteorclient.pathing.PathManagers; |
11 | 12 | import meteordevelopment.meteorclient.settings.*; |
12 | 13 | import meteordevelopment.meteorclient.systems.modules.Categories; |
|
17 | 18 | import net.minecraft.entity.attribute.EntityAttributes; |
18 | 19 | import net.minecraft.entity.decoration.EndCrystalEntity; |
19 | 20 | import net.minecraft.util.math.Box; |
| 21 | +import net.minecraft.util.math.Vec2f; |
| 22 | +import net.minecraft.util.math.Vec3d; |
20 | 23 |
|
21 | 24 | import java.util.OptionalDouble; |
22 | 25 |
|
@@ -105,25 +108,48 @@ private boolean isSafe() { |
105 | 108 | return ((getHealth() > stepHealth.get() && getHealth() - getExplosionDamage() > stepHealth.get())); |
106 | 109 | } |
107 | 110 |
|
| 111 | + private boolean isSaferThanWith(double damage) { |
| 112 | + return (isSafe() || getExplosionDamage() - damage <= 0); |
| 113 | + } |
| 114 | + |
108 | 115 | private double getMaxSafeHeight() { |
109 | | - if (!safeStep.get() || !isSafe()) return height.get(); |
| 116 | + if (!safeStep.get()) return height.get(); |
110 | 117 | double max = height.get(); |
111 | 118 | double h = 0; |
| 119 | + double currentDamage =getExplosionDamage(); |
112 | 120 | 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 | + |
113 | 134 | for (int i = 1; i < max; i++) { |
114 | 135 | 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)) { |
116 | 143 | mc.player.setBoundingBox(initial); |
117 | 144 | return h; |
118 | 145 | } |
119 | 146 | h += 1; |
120 | 147 | } |
121 | 148 | mc.player.setBoundingBox(initial.offset(0, max, 0)); |
122 | 149 |
|
123 | | - if (isSafe()) h = max; |
| 150 | + if (isSaferThanWith(currentDamage)) h = max; |
124 | 151 |
|
125 | 152 | mc.player.setBoundingBox(initial); |
126 | | - |
127 | 153 | return h; |
128 | 154 | } |
129 | 155 |
|
|
0 commit comments