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());
}
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);
}
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();
}
}
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();
}
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);
}
Aggregations