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

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

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
17 Дек 2023
Сообщения
27
Реакции
1
Выберите загрузчик игры
  1. Vanilla
  2. OptiFine
  3. Прочие моды
Привет форум. Я еще не видел чтобы сливали подобную функцию, буду первым. Умный 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 нормальный закинул, прошлый крашал.
 
Последнее редактирование:
Привет форум. Я еще не видел чтобы сливали подобную функцию, буду первым. Умный 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 нормальный закинул, прошлый крашал.
годно
 
Привет форум. Я еще не видел чтобы сливали подобную функцию, буду первым. Умный 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 нормальный закинул, прошлый крашал.
ну дай пж код фаста а то так не интересно, ну или как его сделать хоть(((
 
ну дай пж код фаста а то так не интересно, ну или как его сделать хоть(((
дефолтный тоже быстро фармит.

фаст там делать не очень сложно, но он в несколько раз лучше.
1770608952521.png
 
Последнее редактирование:
Привет форум. Я еще не видел чтобы сливали подобную функцию, буду первым. Умный 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 нормальный закинул, прошлый крашал.
а чем он отличаеться от обычного ?
 
все нашел
вроде прикольно,но у меня багается а fast воообще анворк
ну прикольно, ща буду точь в точь переносить на рич а то я так себе перенес
 
Последнее редактирование:
Назад
Сверху Снизу