Search in sources :

Example 1 with HELPER

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

the class ListenerMotion method doObby.

private void doObby(MotionUpdateEvent event, Vec3i[] offsets) {
    if (event.getStage() == Stage.PRE) {
        // TODO: this looks very similar to AutoTrap,
        // maybe its possible to abstract this even further?
        module.rotations = null;
        module.blocksPlaced = 0;
        for (BlockPos confirmed : module.confirmed) {
            module.placed.remove(confirmed);
        }
        module.placed.entrySet().removeIf(entry -> System.currentTimeMillis() - entry.getValue() >= module.confirm.getValue());
        BlockPos playerPos = PositionUtil.getPosition();
        BlockPos[] positions = new BlockPos[offsets.length];
        for (int i = 0; i < offsets.length; i++) {
            Vec3i offset = offsets[i];
            if (module.mode.getValue() == AntiTrapMode.Fill) {
                if (mc.world.getBlockState(playerPos.add(offset.getX() / 2, 0, offset.getZ() / 2)).getBlock() == Blocks.BEDROCK) {
                    continue;
                }
            }
            positions[i] = playerPos.add(offset);
        }
        if (module.offhand.getValue()) {
            if (!InventoryUtil.isHolding(Blocks.OBSIDIAN)) {
                module.previous = OFFHAND.returnIfPresent(Offhand::getMode, null);
                OFFHAND.computeIfPresent(o -> o.setMode(OffhandMode.CRYSTAL));
                return;
            }
        } else {
            module.slot = InventoryUtil.findHotbarBlock(Blocks.OBSIDIAN);
            if (module.slot == -1) {
                ModuleUtil.disable(module, TextColor.RED + "No Obsidian found.");
                return;
            }
        }
        boolean done = true;
        List<BlockPos> toPlace = new LinkedList<>();
        for (BlockPos pos : positions) {
            if (pos == null) {
                continue;
            }
            if (module.mode.getValue() == AntiTrapMode.Fill && !module.highFill.getValue() && pos.getY() > playerPos.getY()) {
                continue;
            }
            if (mc.world.getBlockState(pos).getMaterial().isReplaceable()) {
                toPlace.add(pos);
                done = false;
            }
        }
        if (done) {
            module.disable();
            return;
        }
        boolean hasPlaced = false;
        Optional<BlockPos> crystalPos = toPlace.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();
            hasPlaced = module.placeBlock(pos);
        }
        // Only after here we need to use the Helper to get the BlockStates.
        if (!hasPlaced) {
            for (BlockPos pos : toPlace) {
                if (!module.placed.containsKey(pos) && HELPER.getBlockState(pos).getMaterial().isReplaceable()) {
                    module.confirmed.remove(pos);
                    if (module.placeBlock(pos)) {
                        break;
                    }
                }
            }
        }
        if (module.rotate.getValue() != Rotate.None) {
            if (module.rotations != null) {
                event.setYaw(module.rotations[0]);
                event.setPitch(module.rotations[1]);
            }
        } else {
            Locks.acquire(Locks.PLACE_SWITCH_LOCK, module::execute);
        }
    } else {
        Locks.acquire(Locks.PLACE_SWITCH_LOCK, module::execute);
    }
}
Also used : RayTraceUtil(me.earth.earthhack.impl.util.math.RayTraceUtil) Blocks(net.minecraft.init.Blocks) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) Rotate(me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ModuleCache(me.earth.earthhack.api.cache.ModuleCache) RotationUtil(me.earth.earthhack.impl.util.math.rotation.RotationUtil) BlockUtil(me.earth.earthhack.impl.util.minecraft.blocks.BlockUtil) EnumHand(net.minecraft.util.EnumHand) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) PositionUtil(me.earth.earthhack.impl.util.math.position.PositionUtil) CPacketPlayerTryUseItemOnBlock(net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock) Vec3i(net.minecraft.util.math.Vec3i) CPacketAnimation(net.minecraft.network.play.client.CPacketAnimation) Stage(me.earth.earthhack.api.event.events.Stage) AntiTrapMode(me.earth.earthhack.impl.modules.combat.antitrap.util.AntiTrapMode) Caches(me.earth.earthhack.impl.modules.Caches) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) ModuleUtil(me.earth.earthhack.impl.util.client.ModuleUtil) LinkedList(java.util.LinkedList) HELPER(me.earth.earthhack.impl.util.helpers.blocks.ObbyModule.HELPER) ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) TextColor(me.earth.earthhack.impl.util.text.TextColor) Items(net.minecraft.init.Items) BlockPos(net.minecraft.util.math.BlockPos) OffhandMode(me.earth.earthhack.impl.modules.combat.offhand.modes.OffhandMode) List(java.util.List) Swing(me.earth.earthhack.impl.util.minecraft.Swing) Offhand(me.earth.earthhack.impl.modules.combat.offhand.Offhand) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Optional(java.util.Optional) CPacketPlayer(net.minecraft.network.play.client.CPacketPlayer) Comparator(java.util.Comparator) EntityUtil(me.earth.earthhack.impl.util.minecraft.entity.EntityUtil) Locks(me.earth.earthhack.impl.util.thread.Locks) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vec3i(net.minecraft.util.math.Vec3i) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) BlockPos(net.minecraft.util.math.BlockPos) LinkedList(java.util.LinkedList)

Aggregations

Comparator (java.util.Comparator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Optional (java.util.Optional)1 ModuleCache (me.earth.earthhack.api.cache.ModuleCache)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 Caches (me.earth.earthhack.impl.modules.Caches)1 AntiTrapMode (me.earth.earthhack.impl.modules.combat.antitrap.util.AntiTrapMode)1 Offhand (me.earth.earthhack.impl.modules.combat.offhand.Offhand)1 OffhandMode (me.earth.earthhack.impl.modules.combat.offhand.modes.OffhandMode)1 ModuleUtil (me.earth.earthhack.impl.util.client.ModuleUtil)1 HELPER (me.earth.earthhack.impl.util.helpers.blocks.ObbyModule.HELPER)1 Rotate (me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate)1 RayTraceUtil (me.earth.earthhack.impl.util.math.RayTraceUtil)1 PositionUtil (me.earth.earthhack.impl.util.math.position.PositionUtil)1 RotationUtil (me.earth.earthhack.impl.util.math.rotation.RotationUtil)1 InventoryUtil (me.earth.earthhack.impl.util.minecraft.InventoryUtil)1 Swing (me.earth.earthhack.impl.util.minecraft.Swing)1