1
0
Fork 0
mirror of https://github.com/Miasmusa/Shadow.git synced 2025-04-15 05:34:25 -04:00
This commit is contained in:
Saturn5Vfive 2022-05-01 12:28:18 -05:00
parent e509b51f23
commit 305b1b3d31
3 changed files with 124 additions and 11 deletions
src/main/java/net/shadow/client
feature/module/impl/movement
helper/util
mixin

View file

@ -7,6 +7,7 @@ package net.shadow.client.feature.module.impl.movement;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
import net.minecraft.network.packet.c2s.play.KeepAliveC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.math.Vec3d;
@ -16,11 +17,17 @@ import net.shadow.client.feature.config.DoubleSetting;
import net.shadow.client.feature.config.EnumSetting;
import net.shadow.client.feature.module.Module;
import net.shadow.client.feature.module.ModuleType;
import net.shadow.client.helper.event.EventListener;
import net.shadow.client.helper.event.EventType;
import net.shadow.client.helper.event.Events;
import net.shadow.client.helper.event.events.PacketEvent;
import net.shadow.client.helper.render.Renderer;
import net.shadow.client.helper.util.Utils;
import net.shadow.client.helper.Timer;
import net.minecraft.network.Packet;
import java.util.ArrayList;
import java.util.List;
import java.awt.Color;
import java.util.Objects;
@ -32,8 +39,13 @@ public class Flight extends Module {
final BooleanSetting bypassVanillaAc = this.config.create(new BooleanSetting.Builder(true).name("Bypass vanilla AC").description("Whether to bypass the vanilla anticheat").get());
final DoubleSetting speed = this.config.create(new DoubleSetting.Builder(1).name("Speed").description("How fast you fly").min(0).max(10).get());
Timer lag = new Timer();
boolean capturePackets = false;
int bypassTimer = 0;
boolean flewBefore = false;
final List<Packet<?>> queue = new ArrayList<>();
public Flight() {
super("Flight", "Allows you to fly without having permission to", ModuleType.MOVEMENT);
@ -50,6 +62,7 @@ public class Flight extends Module {
@Override
public void tick() {
Utils.setClientTps(20F);
if (ShadowMain.client.player == null || ShadowMain.client.world == null || ShadowMain.client.getNetworkHandler() == null) {
return;
}
@ -64,11 +77,11 @@ public class Flight extends Module {
}
}
switch (mode.getValue()) {
case Vanilla:
case Vanilla -> {
ShadowMain.client.player.getAbilities().setFlySpeed((float) (this.speed.getValue() + 0f) / 20f);
ShadowMain.client.player.getAbilities().flying = true;
break;
case Static:
}
case Static -> {
GameOptions go = ShadowMain.client.options;
float y = ShadowMain.client.player.getYaw();
int mx = 0, my = 0, mz = 0;
@ -101,8 +114,8 @@ public class Flight extends Module {
nz += ts * mx * -s;
Vec3d nv3 = new Vec3d(nx, ny, nz);
ShadowMain.client.player.setVelocity(nv3);
break;
case Jetpack:
}
case Jetpack -> {
if (ShadowMain.client.options.jumpKey.isPressed()) {
assert ShadowMain.client.player != null;
ShadowMain.client.player.addVelocity(0, speed / 30, 0);
@ -112,26 +125,114 @@ public class Flight extends Module {
ShadowMain.client.world.addImportantParticle(ParticleTypes.SOUL_FIRE_FLAME, true, vp.x, vp.y, vp.z, (r.nextDouble() * 0.25) - .125, (r.nextDouble() * 0.25) - .125, (r.nextDouble() * 0.25) - .125);
}
}
break;
case ThreeD:
ShadowMain.client.player.setVelocity(ShadowMain.client.player.getRotationVector().multiply(speed)
.multiply(ShadowMain.client.player.input.pressingForward ? 1 : (ShadowMain.client.player.input.pressingBack ? -1 : 0)));
break;
}
case Walk -> {
if(lag.hasExpired(490L)){
lag.reset();
for(int i = 0; i < 3; i++){
if(!queue.isEmpty()){
Utils.sendPacket(queue.get(0));
queue.remove(0);
}
}
}
GameOptions go = ShadowMain.client.options;
float y = ShadowMain.client.player.getYaw();
client.player.setOnGround(true);
client.player.setSprinting(true);
client.player.strideDistance = 0.1F;
Utils.setClientTps(10F);
ShadowMain.client.player.getAbilities().flying = false;
int mx = 0, my = 0, mz = 0;
if (go.jumpKey.isPressed()) {
my++;
}
if (go.backKey.isPressed()) {
mz++;
}
if (go.leftKey.isPressed()) {
mx--;
}
if (go.rightKey.isPressed()) {
mx++;
}
if (go.sneakKey.isPressed()) {
my--;
}
if (go.forwardKey.isPressed()) {
mz--;
}
double ts = speed / 2;
double s = Math.sin(Math.toRadians(y));
double c = Math.cos(Math.toRadians(y));
double nx = ts * mz * s;
double nz = ts * mz * -c;
double ny = ts * my;
nx += ts * mx * -c;
nz += ts * mx * -s;
Vec3d nv3 = new Vec3d(nx, ny, nz);
ShadowMain.client.player.setVelocity(nv3);
}
}
}
private void applyDamage(int amount) {
Vec3d pos = ShadowMain.client.player.getPos();
sendPosition(pos.x, pos.y + amount + 2.1, pos.z, false);
sendPosition(pos.x, pos.y + 0.05, pos.z, false);
sendPosition(pos.x, pos.y, pos.z, true);
}
private void sendPosition(double x, double y, double z, boolean onGround) {
ShadowMain.client.player.networkHandler.sendPacket(
new PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, onGround));
}
@Override
public void enable() {
if(mode.getValue() == FlightMode.Walk){
applyDamage(1);
applyDamage(1);
}
bypassTimer = 0;
flewBefore = Objects.requireNonNull(ShadowMain.client.player).getAbilities().flying;
ShadowMain.client.player.setOnGround(false);
Objects.requireNonNull(ShadowMain.client.getNetworkHandler()).sendPacket(new ClientCommandC2SPacket(ShadowMain.client.player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY));
}
@EventListener(type=EventType.PACKET_SEND)
void giveTwoShits(PacketEvent event){
if(mode.getValue() == FlightMode.Walk){
if (!this.isEnabled()) {
return;
}
if (client.player == null || client.world == null) {
setEnabled(false);
return;
}
if (event.getPacket() instanceof KeepAliveC2SPacket) {
return;
}
queue.add(event.getPacket());
event.setCancelled(true);
}
}
@Override
public void disable() {
Objects.requireNonNull(ShadowMain.client.player).getAbilities().flying = flewBefore;
ShadowMain.client.player.getAbilities().setFlySpeed(0.05f);
Utils.setClientTps(20F);
if (client.player == null || client.getNetworkHandler() == null) {
queue.clear();
return;
}
for (Packet<?> packet : queue.toArray(new Packet<?>[0])) {
client.getNetworkHandler().sendPacket(packet);
}
queue.clear();
}
@Override
@ -154,6 +255,6 @@ public class Flight extends Module {
}
public enum FlightMode { // = (MultiValue) this.config.create("Mode", "Static", "Vanilla", "Static", "3D", "Jetpack")
Vanilla, Static, ThreeD, Jetpack
Vanilla, Static, ThreeD, Jetpack, Walk
}
}

View file

@ -13,6 +13,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.StringNbtReader;
import net.minecraft.network.Packet;
import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.text.LiteralText;
@ -59,6 +60,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class Utils {
public static boolean sendPackets = true;
public static void sleep(long ms) {
try {
Thread.sleep(ms);
@ -91,6 +94,12 @@ public class Utils {
}
public static void sendPacket(Packet packet){
sendPackets = false;
ShadowMain.client.player.networkHandler.sendPacket(packet);
sendPackets = true;
}
public static void setClientTps(float tps) {
IRenderTickCounterAccessor accessor = ((IRenderTickCounterAccessor) ((IMinecraftClientAccessor) ShadowMain.client).getRenderTickCounter());
accessor.setTickTime(1000f / tps);

View file

@ -13,6 +13,8 @@ import net.shadow.client.feature.module.impl.misc.AntiPacketKick;
import net.shadow.client.helper.event.EventType;
import net.shadow.client.helper.event.Events;
import net.shadow.client.helper.event.events.PacketEvent;
import net.shadow.client.helper.util.Utils;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -36,6 +38,7 @@ public class ClientConnectionMixin {
@Inject(method = "send(Lnet/minecraft/network/Packet;)V", cancellable = true, at = @At("HEAD"))
public void dispatchPacketSend(Packet<?> packet, CallbackInfo ci) {
if(!Utils.sendPackets) return;
if (Events.fireEvent(EventType.PACKET_SEND, new PacketEvent(packet))) {
ci.cancel();
}