Search in sources :

Example 1 with PathFinder

use of net.wurstclient.ai.PathFinder in project Wurst7 by Wurst-Imperium.

the class FollowHack method onEnable.

@Override
public void onEnable() {
    WURST.getHax().fightBotHack.setEnabled(false);
    WURST.getHax().protectHack.setEnabled(false);
    WURST.getHax().tunnellerHack.setEnabled(false);
    if (entity == null) {
        Stream<Entity> stream = StreamSupport.stream(MC.world.getEntities().spliterator(), true).filter(e -> !e.isRemoved()).filter(e -> e instanceof LivingEntity && ((LivingEntity) e).getHealth() > 0 || e instanceof AbstractMinecartEntity).filter(e -> e != MC.player).filter(e -> !(e instanceof FakePlayerEntity));
        if (filterPlayers.isChecked())
            stream = stream.filter(e -> !(e instanceof PlayerEntity));
        if (filterSleeping.isChecked())
            stream = stream.filter(e -> !(e instanceof PlayerEntity && ((PlayerEntity) e).isSleeping()));
        if (filterFlying.getValue() > 0)
            stream = stream.filter(e -> {
                if (!(e instanceof PlayerEntity))
                    return true;
                Box box = e.getBoundingBox();
                box = box.union(box.offset(0, -filterFlying.getValue(), 0));
                return !MC.world.isSpaceEmpty(box);
            });
        if (filterMonsters.isChecked())
            stream = stream.filter(e -> !(e instanceof Monster));
        if (filterPigmen.isChecked())
            stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
        if (filterEndermen.isChecked())
            stream = stream.filter(e -> !(e instanceof EndermanEntity));
        if (filterAnimals.isChecked())
            stream = stream.filter(e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity || e instanceof WaterCreatureEntity));
        if (filterBabies.isChecked())
            stream = stream.filter(e -> !(e instanceof PassiveEntity && ((PassiveEntity) e).isBaby()));
        if (filterPets.isChecked())
            stream = stream.filter(e -> !(e instanceof TameableEntity && ((TameableEntity) e).isTamed())).filter(e -> !(e instanceof HorseBaseEntity && ((HorseBaseEntity) e).isTame()));
        if (filterTraders.isChecked())
            stream = stream.filter(e -> !(e instanceof MerchantEntity));
        if (filterGolems.isChecked())
            stream = stream.filter(e -> !(e instanceof GolemEntity));
        if (filterInvisible.isChecked())
            stream = stream.filter(e -> !e.isInvisible());
        if (filterStands.isChecked())
            stream = stream.filter(e -> !(e instanceof ArmorStandEntity));
        if (filterCarts.isChecked())
            stream = stream.filter(e -> !(e instanceof AbstractMinecartEntity));
        entity = stream.min(Comparator.comparingDouble(e -> MC.player.squaredDistanceTo(e))).orElse(null);
        if (entity == null) {
            ChatUtils.error("Could not find a valid entity.");
            setEnabled(false);
            return;
        }
    }
    pathFinder = new EntityPathFinder();
    EVENTS.add(UpdateListener.class, this);
    EVENTS.add(RenderListener.class, this);
    ChatUtils.message("Now following " + entity.getName().getString());
}
Also used : Category(net.wurstclient.Category) GolemEntity(net.minecraft.entity.passive.GolemEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) ChatUtils(net.wurstclient.util.ChatUtils) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) ArrayList(java.util.ArrayList) ValueDisplay(net.wurstclient.settings.SliderSetting.ValueDisplay) Vec3d(net.minecraft.util.math.Vec3d) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity) StreamSupport(java.util.stream.StreamSupport) RenderListener(net.wurstclient.events.RenderListener) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Entity(net.minecraft.entity.Entity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) PathFinder(net.wurstclient.ai.PathFinder) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) Box(net.minecraft.util.math.Box) GameRenderer(net.minecraft.client.render.GameRenderer) MatrixStack(net.minecraft.client.util.math.MatrixStack) BlockPos(net.minecraft.util.math.BlockPos) Hack(net.wurstclient.hack.Hack) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) PathCmd(net.wurstclient.commands.PathCmd) SliderSetting(net.wurstclient.settings.SliderSetting) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) PathPos(net.wurstclient.ai.PathPos) Stream(java.util.stream.Stream) CheckboxSetting(net.wurstclient.settings.CheckboxSetting) Monster(net.minecraft.entity.mob.Monster) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) PathProcessor(net.wurstclient.ai.PathProcessor) UpdateListener(net.wurstclient.events.UpdateListener) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) DontSaveState(net.wurstclient.hack.DontSaveState) Comparator(java.util.Comparator) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) GolemEntity(net.minecraft.entity.passive.GolemEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Entity(net.minecraft.entity.Entity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Box(net.minecraft.util.math.Box) GolemEntity(net.minecraft.entity.passive.GolemEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) Monster(net.minecraft.entity.mob.Monster) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity)

Example 2 with PathFinder

use of net.wurstclient.ai.PathFinder in project Wurst7 by Wurst-Imperium.

the class GoToCmd method call.

@Override
public void call(String[] args) throws CmdException {
    // disable if enabled
    if (enabled) {
        disable();
        if (args.length == 0)
            return;
    }
    // set PathFinder
    if (args.length == 1 && args[0].equals("-path")) {
        BlockPos goal = WURST.getCmds().pathCmd.getLastGoal();
        if (goal == null)
            throw new CmdError("No previous position on .path.");
        pathFinder = new PathFinder(goal);
    } else {
        BlockPos goal = argsToPos(args);
        pathFinder = new PathFinder(goal);
    }
    // start
    enabled = true;
    EVENTS.add(UpdateListener.class, this);
    EVENTS.add(RenderListener.class, this);
}
Also used : CmdError(net.wurstclient.command.CmdError) BlockPos(net.minecraft.util.math.BlockPos) PathFinder(net.wurstclient.ai.PathFinder)

Example 3 with PathFinder

use of net.wurstclient.ai.PathFinder in project Wurst-MC-1.12 by Wurst-Imperium.

the class ExcavatorMod method excavate.

private void excavate() {
    boolean legit = mode.getSelected() == 1;
    currentBlock = null;
    // get valid blocks
    Iterable<BlockPos> validBlocks = BlockUtils.getValidBlocksByDistance(range.getValue(), !legit, pos -> area.blocksSet.contains(pos));
    // nuke all
    if (WMinecraft.getPlayer().capabilities.isCreativeMode && !legit) {
        mc.playerController.resetBlockRemoving();
        // set closest block as current
        for (BlockPos pos : validBlocks) {
            currentBlock = pos;
            break;
        }
        // break all blocks
        validBlocks.forEach((pos) -> BlockUtils.breakBlockPacketSpam(pos));
    } else {
        // find closest valid block
        for (BlockPos pos : validBlocks) {
            boolean successful;
            // break block
            if (legit)
                successful = BlockUtils.prepareToBreakBlockLegit(pos);
            else
                successful = BlockUtils.breakBlockSimple_old(pos);
            // set currentBlock if successful
            if (successful) {
                currentBlock = pos;
                break;
            }
        }
        // reset if no block was found
        if (currentBlock == null)
            mc.playerController.resetBlockRemoving();
    }
    // get remaining blocks
    Predicate<BlockPos> pClickable = pos -> WBlock.canBeClicked(pos);
    area.remainingBlocks = (int) area.blocksList.parallelStream().filter(pClickable).count();
    if (area.remainingBlocks == 0) {
        setEnabled(false);
        return;
    }
    if (pathFinder == null) {
        Comparator<BlockPos> cDistance = Comparator.comparingDouble(pos -> WMinecraft.getPlayer().getDistanceSqToCenter(pos));
        BlockPos closestBlock = area.blocksList.parallelStream().filter(pClickable).min(cDistance).get();
        pathFinder = new ExcavatorPathFinder(closestBlock);
    }
    // find path
    if (!pathFinder.isDone() && !pathFinder.isFailed()) {
        PathProcessor.lockControls();
        pathFinder.think();
        if (!pathFinder.isDone() && !pathFinder.isFailed())
            return;
        pathFinder.formatPath();
        // set processor
        processor = pathFinder.getProcessor();
    }
    // check path
    if (processor != null && !pathFinder.isPathStillValid(processor.getIndex())) {
        pathFinder = new ExcavatorPathFinder(pathFinder);
        return;
    }
    // process path
    processor.process();
    if (processor.isDone()) {
        pathFinder = null;
        processor = null;
        PathProcessor.releaseControls();
    }
}
Also used : Category(net.wurstclient.features.Category) BlockUtils(net.wurstclient.utils.BlockUtils) GUIRenderListener(net.wurstclient.events.GUIRenderListener) ModeSetting(net.wurstclient.settings.ModeSetting) Keyboard(org.lwjgl.input.Keyboard) ArrayList(java.util.ArrayList) ValueDisplay(net.wurstclient.settings.SliderSetting.ValueDisplay) HashSet(java.util.HashSet) PathCmd(net.wurstclient.features.commands.PathCmd) Profile(net.wurstclient.features.special_features.YesCheatSpf.Profile) GL11(org.lwjgl.opengl.GL11) WBlock(net.wurstclient.compatibility.WBlock) RenderListener(net.wurstclient.events.RenderListener) PostUpdateListener(net.wurstclient.events.PostUpdateListener) Fonts(net.wurstclient.font.Fonts) Iterator(java.util.Iterator) PathFinder(net.wurstclient.ai.PathFinder) Predicate(java.util.function.Predicate) ScaledResolution(net.minecraft.client.gui.ScaledResolution) Mod(net.wurstclient.features.Mod) BlockPos(net.minecraft.util.math.BlockPos) SliderSetting(net.wurstclient.settings.SliderSetting) WMinecraft(net.wurstclient.compatibility.WMinecraft) WMath(net.wurstclient.compatibility.WMath) PathProcessor(net.wurstclient.ai.PathProcessor) UpdateListener(net.wurstclient.events.UpdateListener) Feature(net.wurstclient.features.Feature) Comparator(java.util.Comparator) RenderUtils(net.wurstclient.utils.RenderUtils) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with PathFinder

use of net.wurstclient.ai.PathFinder in project Wurst-MC-1.12 by Wurst-Imperium.

the class GoToCmd method onUpdate.

@Override
public void onUpdate() {
    // find path
    if (!pathFinder.isDone()) {
        PathProcessor.lockControls();
        pathFinder.think();
        if (!pathFinder.isDone()) {
            if (pathFinder.isFailed()) {
                ChatUtils.error("Could not find a path.");
                disable();
            }
            return;
        }
        pathFinder.formatPath();
        // set processor
        processor = pathFinder.getProcessor();
        System.out.println("Done");
    }
    // check path
    if (processor != null && !pathFinder.isPathStillValid(processor.getIndex())) {
        System.out.println("Updating path...");
        pathFinder = new PathFinder(pathFinder.getGoal());
        return;
    }
    // process path
    processor.process();
    if (processor.isDone())
        disable();
}
Also used : PathFinder(net.wurstclient.ai.PathFinder)

Example 5 with PathFinder

use of net.wurstclient.ai.PathFinder in project Wurst-MC-1.12 by Wurst-Imperium.

the class GoToCmd method call.

@Override
public void call(String[] args) throws CmdException {
    // disable if enabled
    if (enabled) {
        disable();
        if (args.length == 0)
            return;
    }
    // set PathFinder
    if (args.length == 1 && args[0].equals("-path")) {
        BlockPos goal = wurst.commands.pathCmd.getLastGoal();
        if (goal != null)
            pathFinder = new PathFinder(goal);
        else
            throw new CmdError("No previous position on .path.");
    } else {
        BlockPos goal = argsToPos(args);
        pathFinder = new PathFinder(goal);
    }
    // start
    enabled = true;
    wurst.events.add(UpdateListener.class, this);
    wurst.events.add(RenderListener.class, this);
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) PathFinder(net.wurstclient.ai.PathFinder)

Aggregations

PathFinder (net.wurstclient.ai.PathFinder)10 BlockPos (net.minecraft.util.math.BlockPos)8 ArrayList (java.util.ArrayList)4 Comparator (java.util.Comparator)4 PathProcessor (net.wurstclient.ai.PathProcessor)4 RenderListener (net.wurstclient.events.RenderListener)4 UpdateListener (net.wurstclient.events.UpdateListener)4 SliderSetting (net.wurstclient.settings.SliderSetting)4 ValueDisplay (net.wurstclient.settings.SliderSetting.ValueDisplay)4 Stream (java.util.stream.Stream)3 StreamSupport (java.util.stream.StreamSupport)3 MatrixStack (net.minecraft.client.util.math.MatrixStack)3 Entity (net.minecraft.entity.Entity)3 LivingEntity (net.minecraft.entity.LivingEntity)3 ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)3 AmbientEntity (net.minecraft.entity.mob.AmbientEntity)3 EndermanEntity (net.minecraft.entity.mob.EndermanEntity)3 Monster (net.minecraft.entity.mob.Monster)3 WaterCreatureEntity (net.minecraft.entity.mob.WaterCreatureEntity)3 ZombifiedPiglinEntity (net.minecraft.entity.mob.ZombifiedPiglinEntity)3