This commit is contained in:
parent
b30867a07e
commit
870e342a8f
3 changed files with 146 additions and 6 deletions
|
@ -6,11 +6,7 @@ import de.com.baseband.client.feature.modules.chat.*;
|
|||
import de.com.baseband.client.feature.modules.client.*;
|
||||
import de.com.baseband.client.feature.modules.combat.AutoKill;
|
||||
import de.com.baseband.client.feature.modules.combat.AutoTotem;
|
||||
import de.com.baseband.client.feature.modules.movement.ElytraBot;
|
||||
import de.com.baseband.client.feature.modules.movement.ElytraFly;
|
||||
import de.com.baseband.client.feature.modules.movement.NoSlowDown;
|
||||
import de.com.baseband.client.feature.modules.movement.Velocity;
|
||||
import de.com.baseband.client.feature.modules.movement.AntiLevitation;
|
||||
import de.com.baseband.client.feature.modules.movement.*;
|
||||
import de.com.baseband.client.feature.modules.ingame.AutoRespawn;
|
||||
import de.com.baseband.client.feature.modules.ingame.InteractionTweaks;
|
||||
import de.com.baseband.client.feature.modules.render.*;
|
||||
|
@ -67,6 +63,7 @@ public class Setup {
|
|||
new InteractionTweaks.FastUse(),
|
||||
new MidClick(),
|
||||
new Nametags(),
|
||||
new NoFall(),
|
||||
new NoRender(),
|
||||
new NoSlowDown(),
|
||||
new Notifier(),
|
||||
|
|
|
@ -180,7 +180,7 @@ public abstract class Feature extends ToggleButton implements SetCommand {
|
|||
String[] r = rStep[0].split("\\.\\.");
|
||||
float min = Float.parseFloat(r[0]);
|
||||
float max = Float.parseFloat(r[1]);
|
||||
float step = rStep.length == 1 ? 1f : Float.parseFloat(rStep[1]);
|
||||
float step = rStep.length == 1 ? 0.01f : Float.parseFloat(rStep[1]);
|
||||
addComponent(sections, section, new Slider(config.value(), settings, path + config.value(), n -> String.valueOf(Math.round(n * 100) / 100f), max - min, min, step).gate(gate).hover(description));
|
||||
} else {
|
||||
throw new RuntimeException("No range specified for slider");
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
package de.com.baseband.client.feature.modules.movement;
|
||||
|
||||
import de.com.baseband.client.BaseBand;
|
||||
import de.com.baseband.client.event.events.PacketEvent;
|
||||
import de.com.baseband.client.feature.Feature;
|
||||
import de.com.baseband.client.feature.category.Movement;
|
||||
import de.com.baseband.client.registry.annotation.Config;
|
||||
import de.com.baseband.client.registry.annotation.Description;
|
||||
import de.com.baseband.client.registry.annotation.Gate;
|
||||
import de.com.baseband.client.registry.annotation.Range;
|
||||
import de.com.baseband.client.util.adapt.FieldFinder;
|
||||
import de.com.baseband.client.util.adapt.Marker;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.datasync.DataParameter;
|
||||
import net.minecraft.network.play.client.CPacketEntityAction;
|
||||
import net.minecraft.network.play.client.CPacketPlayer;
|
||||
import net.minecraft.network.play.server.SPacketEntityMetadata;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@Movement
|
||||
public class NoFall extends Feature {
|
||||
|
||||
public enum Mode {
|
||||
NeverTouch,
|
||||
AlwaysTouch,
|
||||
Elytra,
|
||||
}
|
||||
|
||||
@Config("NoFall mode")
|
||||
public Mode mode = Mode.AlwaysTouch;
|
||||
@Marker(1)
|
||||
boolean modeIsElytra = false;
|
||||
|
||||
@Config("Engage upon impact")
|
||||
@Description("Runs in sync with outgoing packets instead of using a periodic check.")
|
||||
@Gate(1)
|
||||
public boolean engageOnImpact = false;
|
||||
|
||||
@Config("Disengage time")
|
||||
@Description("Directly depends on how performant the server is. If it's always 20TPS, this can be 2, otherwise higher.")
|
||||
@Range("2..10")
|
||||
@Gate(1)
|
||||
public int disengageTime = 2;
|
||||
|
||||
boolean lastOnGround = true;
|
||||
float lastFallDist = 0;
|
||||
|
||||
int cancelElytraNT = 0;
|
||||
boolean ranThisFall = false;
|
||||
|
||||
public void onSend(PacketEvent.Send event) {
|
||||
if (!(event.getPacket() instanceof CPacketPlayer) || mc.player.isElytraFlying())
|
||||
return;
|
||||
CPacketPlayer packet = (CPacketPlayer) event.getPacket();
|
||||
|
||||
// rotations will mess with resetting fall distance when using the elytra!
|
||||
if(mode == Mode.Elytra && cancelElytraNT != 0) {
|
||||
if(packet instanceof CPacketPlayer.Rotation) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(packet instanceof CPacketPlayer.PositionRotation) {
|
||||
mc.player.connection.sendPacket(new CPacketPlayer.Position(packet.getX(0), packet.getY(0), packet.getZ(0), packet.isOnGround()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// we check the fall damage so we dont interfere with things that require server-side onground, **LAMBDA**!
|
||||
if(mode == Mode.NeverTouch || ((mode == Mode.Elytra || mode == Mode.AlwaysTouch) && lastFallDist > 2)) {
|
||||
try {
|
||||
FieldFinder.findUnmarked(CPacketPlayer.class, boolean.class, 0).set(packet, mode == Mode.AlwaysTouch);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onReceive(PacketEvent.Receive event) {
|
||||
if(event.getPacket() instanceof SPacketEntityMetadata) {
|
||||
SPacketEntityMetadata packet = (SPacketEntityMetadata) event.getPacket();
|
||||
if(mode == Mode.Elytra && cancelElytraNT != 0 && packet.getEntityId() == mc.player.getEntityId()) {
|
||||
try {
|
||||
DataParameter<Byte> FLAGS = (DataParameter<Byte>) FieldFinder.findUnmarked(Entity.class, DataParameter.class, 0).get(null);
|
||||
packet.getDataManagerEntries().removeIf(x -> x.getKey().equals(FLAGS)); // remove FallFlying tag
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEveryTick() {
|
||||
modeIsElytra = mode == Mode.Elytra;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
if(mc.player.onGround)
|
||||
ranThisFall = false;
|
||||
lastOnGround = mc.player.onGround;
|
||||
lastFallDist = mc.player.fallDistance;
|
||||
if(mode == Mode.Elytra && !engageOnImpact) {
|
||||
int i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
BlockPos down = mc.player.getPosition().down(i + 1);
|
||||
if(mc.world.getBlockState(down).isSideSolid(mc.world, down, EnumFacing.UP))
|
||||
break;
|
||||
}
|
||||
if(i > 3 && cancelElytraNT == 0 && ranThisFall) {
|
||||
ranThisFall = false;
|
||||
mc.player.fallDistance = 0;
|
||||
}
|
||||
if(!ranThisFall && mc.player.fallDistance > 3 && i <= mc.player.fallDistance / 4) {
|
||||
engageElytra();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (cancelElytraNT > 0) {
|
||||
mc.player.motionY = 0.1;
|
||||
cancelElytraNT--;
|
||||
}
|
||||
}
|
||||
|
||||
private void engageElytra() {
|
||||
ranThisFall = true;
|
||||
BaseBand.notify("Caught fall with Elytra.");
|
||||
mc.player.motionY = 0;
|
||||
// start elytra
|
||||
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_FALL_FLYING));
|
||||
// send fake rotation
|
||||
mc.player.connection.sendPacket(new CPacketPlayer.PositionRotation(mc.player.posX, mc.player.posY, mc.player.posZ, mc.player.rotationYaw, 0, false));
|
||||
cancelElytraNT = disengageTime + 10;
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NoFall";
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue