Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Small clarification #8

Closed
el1anbtw opened this issue Jun 22, 2024 · 9 comments
Closed

Small clarification #8

el1anbtw opened this issue Jun 22, 2024 · 9 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@el1anbtw
Copy link

@xia-mc What you are doing is really cool, these are interesting updates and improvements, the client is getting better, but I would like to clarify. You add a lot of options for customization, a lot of sliders, but their meaning is not always clear. For example, in the function HitSelect, what is the delay slider for? I would like to ask, if you add such customization, then set the best settings from the code and add a description, at least in the list of changes, what it means and what values ​​are best to use. Thank you!

@xia-mc
Copy link
Owner

xia-mc commented Jun 22, 2024

Thanks for the suggestion!
HitSelect's delay slider is used to control the interval between each attack, this is because judging by HurtTime is inaccurate at high latency. The default value (420ms) works well at about 200ms ping

@el1anbtw
Copy link
Author

Thanks for the suggestion! HitSelect's delay slider is used to control the interval between each attack, this is because judging by HurtTime is inaccurate at high latency. The default value (420ms) works well at about 200ms ping

Okay, thanks for the clarification, but what if the ping is less, for example 40?

@xia-mc
Copy link
Owner

xia-mc commented Jun 22, 2024

400ms? I tested it on a 30 ping server.
BTW this slider should start at 400ms xd.

@el1anbtw
Copy link
Author

400ms? I tested it on a 30 ping server. BTW this slider should start at 400ms xd.

Ok, I'll try. I saw in Vape V4 there is an "Active" HitSelect, do you think of doing the same?

@xia-mc
Copy link
Owner

xia-mc commented Jun 22, 2024

Actually, I don't know how the Active mode of the Vape V4 works... I'll try.

@el1anbtw
Copy link
Author

Actually, I don't know how the Active mode of the Vape V4 works... I'll try.

Thanks, by the way, I checked the new function Block IN, it is already done well, but sometimes it still places the blocks not quite correctly, especially the top block, and in order to place it perfectly, you need to stand in the center of the block, and during the game you will achieve this hard.

@xia-mc
Copy link
Owner

xia-mc commented Jun 22, 2024

Actually, I don't know how the Active mode of the Vape V4 works... I'll try.

Thanks, by the way, I checked the new function Block IN, it is already done well, but sometimes it still places the blocks not quite correctly, especially the top block, and in order to place it perfectly, you need to stand in the center of the block, and during the game you will achieve this hard.

Vape's block-in moves the player to the center of the block, unfortunately I don't know how to simulate the correct movement...
Block mode has no ray casting check, so it may incorrectly place the top block.

I saw in Vape V4 there is an "Active" HitSelect, do you think of doing the same?

will add in next release.. GrimAC didn't flag me, i think watchdog won't too.

@el1anbtw
Copy link
Author

Actually, I don't know how the Active mode of the Vape V4 works... I'll try.

Thanks, by the way, I checked the new function Block IN, it is already done well, but sometimes it still places the blocks not quite correctly, especially the top block, and in order to place it perfectly, you need to stand in the center of the block, and during the game you will achieve this hard.

Vape's block-in moves the player to the center of the block, unfortunately I don't know how to simulate the correct movement... Block mode has no ray casting check, so it may incorrectly place the top block.

maybe this will help?
`package keystrokesmod.module.impl.world;

import akka.japi.Pair;
import keystrokesmod.event.PreMotionEvent;
import keystrokesmod.module.Module;
import keystrokesmod.module.impl.other.anticheats.utils.phys.Vec2;
import keystrokesmod.module.impl.other.anticheats.utils.world.PlayerRotation;
import keystrokesmod.module.setting.impl.ButtonSetting;
import keystrokesmod.module.setting.impl.DescriptionSetting;
import keystrokesmod.module.setting.impl.SliderSetting;
import keystrokesmod.script.classes.Vec3;
import keystrokesmod.utility.AimSimulator;
import keystrokesmod.utility.BlockUtils;
import keystrokesmod.utility.RotationUtils;
import keystrokesmod.utility.Utils;
import net.minecraft.item.ItemBlock;
import net.minecraft.network.play.client.C0APacketAnimation;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.jetbrains.annotations.NotNull;

import java.util.*;

public class BlockIn extends Module {
private static final String[] rotationModes = new String[]{"None", "Block", "Strict"};
private final SliderSetting rotationMode;
private final SliderSetting aimSpeed;
private final ButtonSetting lookView;
private final SliderSetting placeDelay;
private final ButtonSetting silentSwing;

private Vec2 currentRot = null;
private long lastPlace = 0;

public BlockIn() {
    super("Block-In", category.world);
    this.registerSetting(new DescriptionSetting("make you block in."));
    this.registerSetting(rotationMode = new SliderSetting("Rotation mode", rotationModes, 1));
    this.registerSetting(aimSpeed = new SliderSetting("Aim speed", 5, 0, 5, 0.05));
    this.registerSetting(lookView = new ButtonSetting("Look view", false));
    this.registerSetting(placeDelay = new SliderSetting("Place delay", 50, 0, 500, 1, "ms"));
    this.registerSetting(silentSwing = new ButtonSetting("Silent swing", false));
}

@Override
public void onDisable() {
    currentRot = null;
    lastPlace = 0;
}

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPreMotion(PreMotionEvent event) {
    if (currentRot == null) return;
    if (rotationMode.getInput() == 0) {
        currentRot = null;
        return;
    }
    if (!lookView.isToggled()) {
        event.setYaw(currentRot.x);
        event.setPitch(currentRot.y);
    }
}

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onRender(TickEvent.RenderTickEvent event) {
    // Ensure the player is centered in the block before proceeding
    if (!centerPlayerInBlock()) return;

    try {
        if (!(mc.thePlayer.getHeldItem().getItem() instanceof ItemBlock)) {
            Utils.sendMessage("No blocks found.");
            disable();
            return;
        }
    } catch (Exception e) {
        Utils.sendMessage("No blocks found.");
        disable();
        return;
    }

    long currentTime = System.currentTimeMillis();
    if (currentTime - lastPlace < placeDelay.getInput()) return;

    int placed = 0;
    boolean rotating = false;
    for (BlockPos blockPos : getBlockInBlocks()) {
        if (currentTime - lastPlace < placeDelay.getInput()) return;
        if (!BlockUtils.replaceable(blockPos)) continue;

        Pair<BlockPos, EnumFacing> placeSideBlock;
        try {
            placeSideBlock = getPlaceSide(blockPos).orElseThrow(NoSuchElementException::new);
        } catch (NoSuchElementException e) {
            continue;
        }

        Vec3 hitPos = new Vec3(
                placeSideBlock.first().getX() + 0.5,
                placeSideBlock.first().getY() + 1,
                placeSideBlock.first().getZ() + 0.5
        );
        Vec2 rotation = new Vec2(PlayerRotation.getYaw(hitPos), PlayerRotation.getPitch(hitPos));

        if ((int) rotationMode.getInput() == 2) {
            MovingObjectPosition hitResult = RotationUtils.rayCast(4.5, rotation.x, rotation.y);
            if (hitPos.distanceTo(hitResult.hitVec) > 0.05) continue;
        }

        if (currentRot == null) {
            currentRot = new Vec2(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
        }
        if (rotationMode.getInput() != 0 && !currentRot.equals(rotation)) {
            if (aimSpeed.getInput() == 5) {
                currentRot = rotation;
            } else {
                currentRot = new Vec2(
                        AimSimulator.rotMove(rotation.x, currentRot.x, (float) aimSpeed.getInput()),
                        AimSimulator.rotMove(rotation.y, currentRot.y, (float) aimSpeed.getInput())
                );
                rotating = true;
            }

            if (lookView.isToggled()) {
                mc.thePlayer.rotationYaw = currentRot.x;
                mc.thePlayer.rotationPitch = currentRot.y;
            }
            if (rotating) return;
        }

        if (rotationMode.getInput() == 0 || currentRot.equals(rotation)) {
            mc.playerController.onPlayerRightClick(
                    mc.thePlayer, mc.theWorld,
                    mc.thePlayer.getHeldItem(),
                    placeSideBlock.first(), placeSideBlock.second(),
                    hitPos.toVec3()
            );

            if (silentSwing.isToggled()) {
                mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation());
            } else {
                mc.thePlayer.swingItem();
                mc.getItemRenderer().resetEquippedProgress();
            }

            lastPlace = currentTime;
            placed++;
        }
    }
    if (placed == 0) disable();
}

private boolean centerPlayerInBlock() {
    // Get the player's current position
    double playerX = mc.thePlayer.posX;
    double playerY = mc.thePlayer.posY;
    double playerZ = mc.thePlayer.posZ;

    // Calculate the block's center
    int blockX = (int) Math.floor(playerX);
    int blockZ = (int) Math.floor(playerZ);

    double centerX = blockX + 0.5;
    double centerZ = blockZ + 0.5;

    // Set the player's position to the block's center if necessary
    if (playerX != centerX || playerZ != centerZ) {
        mc.thePlayer.setPosition(centerX, playerY, centerZ);
        return false; // Return false to delay the block placement until next tick
    }
    return true; // Return true if player is already centered
}

private @NotNull Set<BlockPos> getBlockInBlocks() {
    Set<BlockPos> surroundBlocks = BlockUtils.getSurroundBlocks(mc.thePlayer);

    int maxX = Integer.MIN_VALUE, maxY = Integer.MIN_VALUE, maxZ = Integer.MIN_VALUE;
    for (BlockPos block : surroundBlocks) {
        maxX = Math.max(block.getX(), maxX);
        maxY = Math.max(block.getY(), maxY);
        maxZ = Math.max(block.getZ(), maxZ);
    }

    surroundBlocks.add(new BlockPos(maxX - 1, maxY, maxZ));
    return surroundBlocks;
}

private @NotNull Optional<Pair<BlockPos, EnumFacing>> getPlaceSide(@NotNull BlockPos blockPos) {
    final List<BlockPos> possible = Arrays.asList(
            blockPos.down(), blockPos.east(), blockPos.west(),
            blockPos.north(), blockPos.south(), blockPos.up()
    );

    for (BlockPos pos : possible) {
        if (BlockUtils.getBlockState(pos).getBlock().isFullBlock()) {
            EnumFacing facing;
            if (pos.getY() < blockPos.getY()) facing = EnumFacing.UP;
            else if (pos.getX() > blockPos.getX()) facing = EnumFacing.EAST;
            else if (pos.getX() < blockPos.getX()) facing = EnumFacing.WEST;
            else if (pos.getZ() < blockPos.getZ()) facing = EnumFacing.NORTH;
            else if (pos.getZ() > blockPos.getZ()) facing = EnumFacing.SOUTH;
            else facing = EnumFacing.DOWN;

            return Optional.of(new Pair<>(pos, facing));
        }
    }
    return Optional.empty();
}

}
`

@xia-mc
Copy link
Owner

xia-mc commented Jun 23, 2024

if just "setPosition" then AntiCheat will flag you xd
because thats a impossible movement.

@xia-mc xia-mc added documentation Improvements or additions to documentation enhancement New feature or request labels Jun 23, 2024
@xia-mc xia-mc closed this as completed Jun 23, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants