Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Часть функционала AutoLes умный | monoton ready.

ну хз тогда
у меня все гуд
по 100 монет в секунду с незера 5эфф
так и не получилось
всё также, просто подхожу к дерево и что бы я не делал ничего не происходит, а вручную, как обычно ломается
вот решил код ниже приложу, может кто найдет ошибку. Я вчера 2 нейросети насиловал так и не нашли...
чудо код авто леса на 1.16.5:
Expand Collapse Copy
package ru.cheat.modules.impl.player;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

import com.google.common.eventbus.Subscribe;
import net.minecraft.block.BlockState;
import net.minecraft.network.play.client.CPlayerDiggingPacket;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import ru.cheat.events.EventUpdate;
import ru.cheat.modules.api.Category;
import ru.cheat.modules.api.ModuleRegister;
import ru.cheat.modules.api.Module;
import ru.cheat.modules.settings.impl.*;
import ru.cheat.utils.math.StopWatch;

@ModuleRegister(name = "AutoLes", category = Category.Player, description = "Быстро ломает деревья на RW")
public class AutoLes extends Module {
    private BlockPos targetPos;
    private static final double MAX_RANGE_SQ = 16.0D;

    private final ModeSetting breakMode = new ModeSetting("Режим", "Default", "Default", "Fast");
    private final SliderSetting packetsPerSecond = new SliderSetting("Пакетов/сек", 20.0f, 1.0f, 100.0f, 1.0f)
            .setVisible(() -> breakMode.is("Fast"));
    private final SliderSetting breakRadius = new SliderSetting("Радиус", 4.0f, 1.0f, 6.0f, 0.5f);

    private final BooleanSetting swing = new BooleanSetting("Махать рукой", true);

    private final BooleanSetting autoWood = new BooleanSetting("Авто-сдача", true);

    private final BooleanSetting autoPay = new BooleanSetting("AutoPay", false);

    private final StringSetting namePay = new StringSetting("Ник для перевода", "name", "Ник для перевода").setVisible(() -> autoPay.get());

    private final SliderSetting valuePay = new SliderSetting("Кол-во монет для перевода", 1000, 500, 25000,1000).setVisible(() -> autoPay.get());

    private final SliderSetting timer = new SliderSetting("Расписание/c", 20, 1, 60, 1).setVisible(() -> autoPay.get());

    private final StopWatch sellTimer = new StopWatch();
    private final StopWatch payTimer = new StopWatch();
    private final StopWatch breakTimer = new StopWatch();
    private int packetsSent = 0;
    private long lastBreakTime = 0;

    public AutoLes() {
        addSettings(breakMode, packetsPerSecond, breakRadius, swing, autoPay, autoWood, namePay, valuePay, timer);
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        this.updateNuker();
        this.autoSell();
        this.autoPay();
    }

    public void autoSell() {
        if (autoWood.get() && sellTimer.hasTimeElapsed(timer.getValue().intValue() * 500L, false)) {
            mc.player.sendChatMessage("/sellwood");
            sellTimer.reset();
        }
    }

    public void autoPay() {
        if (autoPay.get() && payTimer.hasTimeElapsed((timer.getValue().intValue() * 500) + 200, false)) {
            mc.player.sendChatMessage("/pay " + namePay.get() + " " + valuePay.getValue().intValue());
            payTimer.reset();
        }
    }

    private void updateNuker() {
        if (mc.player == null || mc.world == null) {
            targetPos = null;
            packetsSent = 0;
            return;
        }

        if (targetPos != null &&
                (!isLog(targetPos) || !isInRange(targetPos) || !isVisible(targetPos))) {
            targetPos = null;
        }

        if (targetPos != null) {
            breakBlock();
        } else {
            findAndBreakNewTarget();
        }
    }

    private void findAndBreakNewTarget() {
        BlockPos playerPos = mc.player.getPosition();

        int radius = (int) breakRadius.getValue().floatValue();
        BlockPos from = playerPos.add(-radius, -radius, -radius);
        BlockPos to = playerPos.add(radius, radius, radius);

        List<BlockPos> blocks = getAllInBox(from, to);

        targetPos = blocks.stream()
                .filter(this::isLog)
                .filter(this::isInRange)
                .filter(this::isVisible)
                .min(Comparator.comparing(pos ->
                        mc.player.getDistanceSq(Vector3d.copyCentered(pos))
                ))
                .orElse(null);

        if (targetPos != null) {
            breakBlock();
        }
    }

    private void breakBlock() {
        if (targetPos == null) return;

        if (breakMode.is("Default")) {
            if (breakTimer.hasTimeElapsed(3, false)) {
                mc.playerController.spoofInstantDig(targetPos, Direction.UP);
                mc.playerController.onPlayerDestroyBlock(targetPos);
                if (swing.get()){
                    mc.player.swingArm(Hand.MAIN_HAND);
                }
                breakTimer.reset();
                lastBreakTime = System.currentTimeMillis();
            }
        } else if (breakMode.is("Fast")) {
            performFastBreak(targetPos);
        }
    }

    private void performFastBreak(BlockPos pos) {
        if (mc.player == null || mc.world == null || mc.getConnection() == null) return;

        mc.getConnection().sendPacket(new CPlayerDiggingPacket(
                CPlayerDiggingPacket.Action.START_DESTROY_BLOCK,
                pos,
                Direction.UP
        ));
        mc.getConnection().sendPacket(new CPlayerDiggingPacket(
                CPlayerDiggingPacket.Action.STOP_DESTROY_BLOCK,
                pos,
                Direction.UP
        ));
        mc.player.swingArm(Hand.MAIN_HAND);
    }

    private boolean isInRange(BlockPos pos) {
        if (mc.player == null) return false;

        double distanceSq = mc.player.getDistanceSq(
                pos.getX() + 0.5,
                pos.getY() + 0.5,
                pos.getZ() + 0.5
        );

        return distanceSq <= MAX_RANGE_SQ;
    }

    private boolean isVisible(BlockPos pos) {
        if (mc.world == null || mc.player == null) return false;

        return true;
    }

    private boolean isLog(BlockPos pos) {
        if (mc.world == null) return false;

        BlockState state = mc.world.getBlockState(pos);
        return state.isIn(BlockTags.LOGS);
    }

    public static List<BlockPos> getAllInBox(BlockPos from, BlockPos to) {
        List<BlockPos> blocks = new ArrayList<>();
        int minX = Math.min(from.getX(), to.getX());
        int minY = Math.min(from.getY(), to.getY());
        int minZ = Math.min(from.getZ(), to.getZ());
        int maxX = Math.max(from.getX(), to.getX());
        int maxY = Math.max(from.getY(), to.getY());
        int maxZ = Math.max(from.getZ(), to.getZ());

        for (int x = minX; x <= maxX; x++) {
            for (int y = minY; y <= maxY; y++) {
                for (int z = minZ; z <= maxZ; z++) {
                    blocks.add(new BlockPos(x, y, z));
                }
            }
        }
        return blocks;
    }

    @Override
    public boolean onDisable() {
        targetPos = null;
        packetsSent = 0;
        super.onDisable();
        return false;
    }
}

ну либо я тупой очень -_-
 
Привет форум. Я еще не видел чтобы сливали подобную функцию, буду первым. Умный AutoLes который фармит, сдает, переводит.

Пожалуйста, авторизуйтесь для просмотра ссылки.


Fast я не дам так как он ну слишком много добывает за секунду.
AutoLes:
Expand Collapse Copy
package monoton.module.impl.player;

import java.util.Comparator;
import java.util.List;
import monoton.control.events.client.Event;
import monoton.control.events.player.EventUpdate;
import monoton.module.TypeList;
import monoton.module.api.Annotation;
import monoton.module.api.Module;
import monoton.module.settings.Setting;
import monoton.module.settings.imp.BooleanOption;
import monoton.module.settings.imp.ModeSetting;
import monoton.module.settings.imp.SliderSetting;
import monoton.module.settings.imp.TextSetting;
import monoton.utils.IMinecraft;
import monoton.utils.other.StopWatch;
import monoton.utils.world.WorldUtils;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.network.play.client.CPlayerDiggingPacket;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;

@Annotation(
        name = "AutoLes",
        type = TypeList.Player,
        desc = "Автоматически ломает брёвна в радиусе 4 блоков"
)
public class AutoLes extends Module implements IMinecraft {
    private BlockPos targetPos;
    private static final double MAX_RANGE = 4.0D;
    private static final double MAX_RANGE_SQ = 16.0D;

    private final ModeSetting breakMode = new ModeSetting("Режим", "Default", "Default");
    private final SliderSetting packetsPerSecond = new SliderSetting("Пакетов/сек", 20.0f, 1.0f, 100.0f, 1.0f)
            .setVisible(() -> breakMode.is("Fast"));
    private final SliderSetting breakRadius = new SliderSetting("Радиус", 4.0f, 1.0f, 6.0f, 0.5f);

    BooleanOption swing = new BooleanOption("Махать рукой", true);

    BooleanOption autoWood = new BooleanOption("Авто-сдача", true);

    BooleanOption autoPay = new BooleanOption("AutoPay", false);

    TextSetting namePay = new TextSetting("Ник для перевода", "name").setVisible(() -> autoPay.get());

    SliderSetting valuePay = new SliderSetting("Кол-во монет для перевода", 1000, 500, 25000,1000).setVisible(() -> autoPay.get());

    SliderSetting timer = new SliderSetting("Расписание/c", 20, 1, 60, 1).setVisible(() -> autoPay.get());

    private final StopWatch sellTimer = new StopWatch();
    private final StopWatch payTimer = new StopWatch();
    private final StopWatch breakTimer = new StopWatch();
    private final StopWatch packetTimer = new StopWatch();
    private int packetsSent = 0;
    private long lastBreakTime = 0;

    public AutoLes() {
        addSettings(breakMode, packetsPerSecond, breakRadius, swing, autoPay, autoWood, namePay, valuePay, timer);
    }

    public boolean onEvent(Event event) {
        if (event instanceof EventUpdate) {
            this.updateNuker();
            this.autoSell();
            this.autoPay();
        }
        return false;
    }

    public void autoSell() {
        if (autoWood.get() && sellTimer.hasPassed(timer.getValue().intValue() * 500)) {
            mc.player.sendChatMessage("/sellwood");
            sellTimer.reset();
        }
    }

    public void autoPay() {
        if (autoPay.get() && payTimer.hasPassed((timer.getValue().intValue() * 500) + 200)) {
            mc.player.sendChatMessage("/pay " + namePay.get() + " " + valuePay.getValue().intValue());
            payTimer.reset();
        }
    }

    private void updateNuker() {
        if (mc.player == null || mc.world == null) {
            targetPos = null;
            packetsSent = 0;
            return;
        }

        if (targetPos != null &&
                (!isLog(targetPos) || !isInRange(targetPos) || !isVisible(targetPos))) {
            targetPos = null;
        }

        if (targetPos != null) {
            breakBlock();
        } else {
            findAndBreakNewTarget();
        }
    }

    private void findAndBreakNewTarget() {
        BlockPos playerPos = mc.player.getPosition();

        int radius = (int) breakRadius.getValue().floatValue();
        BlockPos from = playerPos.add(-radius, -radius, -radius);
        BlockPos to = playerPos.add(radius, radius, radius);

        List<BlockPos> blocks = WorldUtils.Blocks.getAllInBox(from, to);

        targetPos = blocks.stream()
                .filter(this::isLog)
                .filter(this::isInRange)
                .filter(this::isVisible)
                .min(Comparator.comparing(pos ->
                        mc.player.getDistanceSq(Vector3d.copyCentered(pos))
                ))
                .orElse(null);

        if (targetPos != null) {
            breakBlock();
        }
    }

    private void breakBlock() {
        if (targetPos == null) return;

        if (breakMode.is("Default")) {
            if (breakTimer.hasPassed(3)) {
                mc.playerController.spoofInstantDig(targetPos, Direction.UP);
                mc.playerController.onPlayerDestroyBlock(targetPos);
                if (swing.get()){
                mc.player.swingArm(Hand.MAIN_HAND);
                }
                breakTimer.reset();
                lastBreakTime = System.currentTimeMillis();
            }
        }
    }

    private boolean isInRange(BlockPos pos) {
        if (mc.player == null) return false;

        double distanceSq = mc.player.getDistanceSq(
                pos.getX() + 0.5,
                pos.getY() + 0.5,
                pos.getZ() + 0.5
        );

        return distanceSq <= MAX_RANGE_SQ;
    }

    private boolean isVisible(BlockPos pos) {
        if (mc.world == null || mc.player == null) return false;

        return true;
    }

    private boolean isLog(BlockPos pos) {
        if (mc.world == null) return false;

        BlockState state = mc.world.getBlockState(pos);
        return state.isIn(BlockTags.LOGS);
    }

    @Override
    public void onDisable() {
        targetPos = null;
        packetsSent = 0;
        super.onDisable();
    }
}

Вот еще код чтобы визуально блок после поломки оставался на стороне клиента


Visualization:
Expand Collapse Copy
package monoton.module.impl.misc;

import monoton.control.events.client.Event;
import monoton.control.events.packet.EventPacket;
import monoton.control.events.player.EventUpdate;
import monoton.module.TypeList;
import monoton.module.api.Annotation;
import monoton.module.api.Module;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.play.client.CPlayerDiggingPacket;
import net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket;
import net.minecraft.network.play.server.SChangeBlockPacket;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

@Annotation(
name = "Visualization",
type = TypeList.Misc,
desc = "Визуализация блоков на клиенте"
)
public class Visualization extends Module {

private final Set<BlockPos> protectedBlocks = new HashSet<>();
private final Map<BlockPos, BlockState> preservedBlocks = new HashMap<>();
private final Map<BlockPos, Long> lastUpdateTime = new HashMap<>();

@Override
    public boolean onEvent(Event event) {
if (event instanceof EventPacket) {
            handlePacket((EventPacket) event);
 return false;
        }

if (event instanceof EventUpdate) {
            updateVisualization();
 return false;
        }

 return false;
    }

private void handlePacket(EventPacket event) {
if (mc.player == null || mc.world == null) return;

 if (event.isSend()) {
            handleSendPacket(event);
} else if (event.isReceive()) {
            handleReceivePacket(event);
        }
    }

private void handleSendPacket(EventPacket event) {
if (event.getPacket() instanceof CPlayerDiggingPacket) {
            CPlayerDiggingPacket packet = (CPlayerDiggingPacket) event.getPacket();
            BlockPos pos = packet.getPosition();

if (packet.getAction() == CPlayerDiggingPacket.Action.STOP_DESTROY_BLOCK) {
                handleBlockBreak(pos);
} else if (packet.getAction() == CPlayerDiggingPacket.Action.START_DESTROY_BLOCK) {
                handleStartBreaking(pos);
            }
} else if (event.getPacket() instanceof CPlayerTryUseItemOnBlockPacket) {
            CPlayerTryUseItemOnBlockPacket packet = (CPlayerTryUseItemOnBlockPacket) event.getPacket();
            BlockRayTraceResult hitResult = packet.func_218794_c();
            BlockPos placementPos = hitResult.getPos().offset(hitResult.getFace());

            Hand hand = packet.getHand();
if (hand != null && mc.player.getHeldItem(hand).getItem() instanceof net.minecraft.item.BlockItem) {
if (!protectedBlocks.contains(placementPos)) {
 protectedBlocks.add(placementPos);
 preservedBlocks.remove(placementPos);
 lastUpdateTime.remove(placementPos);
                }
            }
        }
    }

private void handleBlockBreak(BlockPos brokenPos) {
if (!preservedBlocks.containsKey(brokenPos)) {
BlockState currentState = mc.world.getBlockState(brokenPos);
if (currentState != null && !currentState.isAir()) {
 preservedBlocks.put(brokenPos, currentState);
lastUpdateTime.put(brokenPos, System.currentTimeMillis());

                Minecraft.getInstance().execute(() -> {
if (mc.world != null && mc.world instanceof ClientWorld) {
((ClientWorld) mc.world).setBlockState(brokenPos, currentState, 0);
                    }
                });
            }
        }
    }

private void handleStartBreaking(BlockPos breakingPos) {
BlockState state = mc.world.getBlockState(breakingPos);
if (state != null && !state.isAir()) {
float miningSpeed = mc.player.getDigSpeed(state);
float hardness = state.getBlockHardness(mc.world, breakingPos);

if (hardness >= 0 && miningSpeed / hardness >= 30) {
 preservedBlocks.put(breakingPos, state);
lastUpdateTime.put(breakingPos, System.currentTimeMillis());

                Minecraft.getInstance().execute(() -> {
if (mc.world != null && mc.world instanceof ClientWorld) {
((ClientWorld) mc.world).setBlockState(breakingPos, state, 0);
                    }
                });
            }
        }
    }

private void handleReceivePacket(EventPacket event) {
if (event.getPacket() instanceof SChangeBlockPacket) {
            SChangeBlockPacket packet = (SChangeBlockPacket) event.getPacket();
            BlockPos pos = packet.getPos();
            BlockState serverState = packet.getState();

if (serverState == null) return;

if (preservedBlocks.containsKey(pos)) {
                handlePreservedBlockUpdate(event, pos, serverState);
} else if (protectedBlocks.contains(pos)) {
                handleProtectedBlockUpdate(event, pos, serverState);
            }
        }
    }

private void handlePreservedBlockUpdate(EventPacket event, BlockPos pos, BlockState serverState) {
 if (serverState.isAir()) {
            event.cancel();
BlockState savedState = preservedBlocks.get(pos);
if (savedState != null && !savedState.isAir()) {
                Minecraft.getInstance().execute(() -> {
if (mc.world != null && mc.world instanceof ClientWorld) {
((ClientWorld) mc.world).setBlockState(pos, savedState, 0);
                    }
                });
            }
} else {
BlockState savedState = preservedBlocks.get(pos);
if (savedState != null && !serverState.equals(savedState)) {
                event.cancel();
 if (!savedState.isAir()) {
                    Minecraft.getInstance().execute(() -> {
if (mc.world != null && mc.world instanceof ClientWorld) {
((ClientWorld) mc.world).setBlockState(pos, savedState, 0);
                        }
                    });
                }
            }
        }
    }

private void handleProtectedBlockUpdate(EventPacket event, BlockPos pos, BlockState serverState) {
 if (serverState.isAir()) {
            event.cancel();
            Minecraft.getInstance().execute(() -> {
if (mc.world != null && mc.world instanceof ClientWorld) {
ClientWorld clientWorld = (ClientWorld) mc.world;
BlockState currentState = clientWorld.getBlockState(pos);
if (currentState != null && !currentState.isAir()) {
clientWorld.setBlockState(pos, currentState, 0);
                    }
                }
            });
} else if (!serverState.isAir()) {
            event.cancel();
            Minecraft.getInstance().execute(() -> {
if (mc.world != null && mc.world instanceof ClientWorld) {
ClientWorld clientWorld = (ClientWorld) mc.world;
BlockState currentState = clientWorld.getBlockState(pos);
if (currentState != null) {
clientWorld.setBlockState(pos, currentState, 0);
                    }
                }
            });
        }
    }

private void updateVisualization() {
if (mc.player == null || mc.world == null) return;
if (!(mc.world instanceof ClientWorld)) return;

ClientWorld clientWorld = (ClientWorld) mc.world;
long currentTime = System.currentTimeMillis();

        for (Map.Entry<BlockPos, BlockState> entry : preservedBlocks.entrySet()) {
            BlockPos pos = entry.getKey();
            BlockState savedState = entry.getValue();

if (pos == null || savedState == null) continue;

            BlockState currentClientState = clientWorld.getBlockState(pos);
if (currentClientState == null || !currentClientState.equals(savedState)) {
clientWorld.setBlockState(pos, savedState, 0);
if (currentClientState != null && !currentClientState.isAir()) {
 lastUpdateTime.put(pos, currentTime);
                }
            }

            for (Direction direction : Direction.values()) {
if (direction == null) continue;

                BlockPos neighborPos = pos.offset(direction);
if (preservedBlocks.containsKey(neighborPos)) {
BlockState neighborSavedState = preservedBlocks.get(neighborPos);
                    BlockState neighborCurrentState = clientWorld.getBlockState(neighborPos);
if (neighborCurrentState != null && neighborSavedState != null &&
                            !neighborCurrentState.equals(neighborSavedState)) {
clientWorld.setBlockState(neighborPos, neighborSavedState, 0);
                    }
                }
            }
        }

        Set<BlockPos> toRemove = new HashSet<>();
for (Map.Entry<BlockPos, Long> entry : lastUpdateTime.entrySet()) {
            BlockPos pos = entry.getKey();
            Long timestamp = entry.getValue();

if (pos == null || timestamp == null) continue;

if (currentTime - timestamp > 300000) { // 5 минут
                BlockState serverState = clientWorld.getBlockState(pos);
BlockState savedState = preservedBlocks.get(pos);

if (serverState == null || serverState.isAir() ||
(savedState != null && !serverState.equals(savedState))) {
                    toRemove.add(pos);
                }
            }
        }

 for (BlockPos pos : toRemove) {
if (pos != null) {
 preservedBlocks.remove(pos);
 lastUpdateTime.remove(pos);
            }
        }
    }

@Override
    public void onEnable() {
 protectedBlocks.clear();
 preservedBlocks.clear();
 lastUpdateTime.clear();
 super.onEnable();
    }

@Override
    public void onDisable() {
 super.onDisable();

 protectedBlocks.clear();

        Minecraft.getInstance().execute(() -> {
if (mc.world instanceof ClientWorld) {
ClientWorld clientWorld = (ClientWorld) mc.world;
for (BlockPos pos : preservedBlocks.keySet()) {
if (pos != null) {
clientWorld.setBlockState(pos, net.minecraft.block.Blocks.AIR.getDefaultState(), 0);
                    }
                }
            }
        });

 preservedBlocks.clear();
 lastUpdateTime.clear();
    }
}

upd visualization нормальный закинул, прошлый крашал.
+rep
 
Назад
Сверху Снизу