Search in sources :

Example 1 with Rotate

use of me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate in project 3arthh4ck by 3arthqu4ke.

the class ListenerMotion method start.

public static void start(Surround module, MotionUpdateEvent event) {
    module.rotations = null;
    module.attacking = null;
    module.blocksPlaced = 0;
    module.center();
    if (module.updatePosAndBlocks()) {
        // confirmed blocks can now be checked for blockstate changes.
        module.placed.removeAll(module.confirmed);
        boolean hasPlaced = false;
        // ensure that we attack the pos with the crystal first before
        // the others, so we dont have to deal with switchcooldown.
        Optional<BlockPos> crystalPos = module.targets.stream().filter(pos -> !mc.world.getEntitiesWithinAABB(EntityEnderCrystal.class, new AxisAlignedBB(pos)).isEmpty() && mc.world.getBlockState(pos).getMaterial().isReplaceable()).findFirst();
        if (crystalPos.isPresent()) {
            BlockPos pos = crystalPos.get();
            module.confirmed.remove(pos);
            hasPlaced = module.placeBlock(pos);
        }
        if (!hasPlaced || !module.crystalCheck.getValue()) {
            List<BlockPos> surrounding = new ArrayList<>(module.targets);
            if (module.getPlayer().motionX != 0.0 || module.getPlayer().motionZ != 0.0) {
                // place in front of us first to stop our movement.
                // I am aware that this looks really bad
                BlockPos pos = new BlockPos(module.getPlayer()).add(module.getPlayer().motionX * 10000, 0, module.getPlayer().motionZ * 10000);
                surrounding.sort(Comparator.comparingDouble(p -> p.distanceSq(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5)));
            }
            for (BlockPos pos : surrounding) {
                if (!module.placed.contains(pos) && mc.world.getBlockState(pos).getMaterial().isReplaceable()) {
                    module.confirmed.remove(pos);
                    if (module.placeBlock(pos)) {
                        break;
                    }
                }
            }
        }
    }
    if (module.blocksPlaced == 0) {
        module.placed.clear();
    }
    if (module.rotate.getValue() != Rotate.None) {
        if (module.rotations != null) {
            Managers.ROTATION.setBlocking(true);
            event.setYaw(module.rotations[0]);
            event.setPitch(module.rotations[1]);
            if (Surround.FREECAM.isEnabled()) {
                Surround.FREECAM.get().rotate(module.rotations[0], module.rotations[1]);
            }
        }
    } else if (module.setPosition) {
        // if we dont need to rotate and are centered, send immediately.
        Locks.acquire(Locks.PLACE_SWITCH_LOCK, module::execute);
    }
}
Also used : ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) Managers(me.earth.earthhack.impl.managers.Managers) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) Rotate(me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BlockPos(net.minecraft.util.math.BlockPos) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) ArrayList(java.util.ArrayList) List(java.util.List) Stage(me.earth.earthhack.api.event.events.Stage) Optional(java.util.Optional) Comparator(java.util.Comparator) Locks(me.earth.earthhack.impl.util.thread.Locks) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Optional (java.util.Optional)1 Stage (me.earth.earthhack.api.event.events.Stage)1 MotionUpdateEvent (me.earth.earthhack.impl.event.events.network.MotionUpdateEvent)1 ModuleListener (me.earth.earthhack.impl.event.listeners.ModuleListener)1 Managers (me.earth.earthhack.impl.managers.Managers)1 Rotate (me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate)1 Locks (me.earth.earthhack.impl.util.thread.Locks)1 EntityEnderCrystal (net.minecraft.entity.item.EntityEnderCrystal)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1