use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class BookDupeCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
FindItemResult book = InvUtils.findInHotbar(Items.WRITABLE_BOOK);
if (book.getHand() == null)
error("No book found, you must be holding a writable book!");
else {
int i = book.isMainHand() ? mc.player.getInventory().selectedSlot : 40;
mc.player.networkHandler.sendPacket(new BookUpdateC2SPacket(i, DUPE_PAGES, Optional.of("Dupe Book")));
}
return SINGLE_SUCCESS;
});
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class AutoBedCraft method isOutOfMaterial.
private boolean isOutOfMaterial() {
FindItemResult wool = InvUtils.find(itemStack -> InvUtils.wools.contains(itemStack.getItem()));
FindItemResult plank = InvUtils.find(itemStack -> InvUtils.planks.contains(itemStack.getItem()));
FindItemResult craftTable = InvUtils.findCraftTable();
if (!craftTable.found())
return true;
if (!wool.found() || !plank.found())
return true;
return wool.count() < 3 || plank.count() < 3;
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class Scaffold method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
renderBlocks.forEach(RenderBlock::tick);
renderBlocks.removeIf(renderBlock -> renderBlock.ticks <= 0);
if (airPlace.get()) {
Vec3d vec = mc.player.getPos().add(mc.player.getVelocity()).add(0, -0.5f, 0);
bp.set(vec.getX(), vec.getY(), vec.getZ());
} else {
if (BlockUtils.getPlaceSide(mc.player.getBlockPos().down()) != null)
bp.set(mc.player.getBlockPos().down());
else {
Vec3d pos = mc.player.getPos();
pos = pos.add(0, -0.98f, 0);
pos.add(mc.player.getVelocity());
if (PlayerUtils.distanceTo(prevBp) > placeRange.get()) {
List<BlockPos> blockPosArray = new ArrayList<>();
for (int x = (int) (mc.player.getX() - placeRange.get()); x < mc.player.getX() + placeRange.get(); x++) {
for (int z = (int) (mc.player.getZ() - placeRange.get()); z < mc.player.getZ() + placeRange.get(); z++) {
for (int y = (int) Math.max(mc.world.getBottomY(), mc.player.getY() - placeRange.get()); y < Math.min(mc.world.getTopY(), mc.player.getY() + placeRange.get()); y++) {
bp.set(x, y, z);
if (!mc.world.getBlockState(bp).isAir())
blockPosArray.add(new BlockPos(bp));
}
}
}
if (blockPosArray.size() == 0)
return;
blockPosArray.sort(Comparator.comparingDouble(PlayerUtils::distanceTo));
prevBp.set(blockPosArray.get(0));
}
Vec3d vecPrevBP = new Vec3d((double) prevBp.getX() + 0.5f, (double) prevBp.getY() + 0.5f, (double) prevBp.getZ() + 0.5f);
Vec3d sub = pos.subtract(vecPrevBP);
Direction facing;
if (sub.getY() < -0.5f)
facing = Direction.DOWN;
else if (sub.getY() > 0.5f)
facing = Direction.UP;
else
facing = Direction.getFacing(sub.getX(), 0, sub.getZ());
bp.set(prevBp.offset(facing));
}
}
FindItemResult item = InvUtils.findInHotbar(itemStack -> validItem(itemStack, bp));
if (!item.found())
return;
if (item.getHand() == null && !autoSwitch.get())
return;
if (mc.options.sneakKey.isPressed() && !mc.options.jumpKey.isPressed()) {
if (lastSneakingY - mc.player.getY() < 0.1) {
lastWasSneaking = false;
return;
}
} else
lastWasSneaking = false;
if (!lastWasSneaking)
lastSneakingY = mc.player.getY();
if (mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed() && fastTower.get())
mc.player.setVelocity(0, 0.42f, 0);
if (BlockUtils.place(bp, item, rotate.get(), 50, swing.get(), true)) {
if (!mc.world.isOutOfHeightLimit(bp.getY()))
renderBlocks.add(renderBlockPool.get().set(bp));
if (mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed() && !mc.player.isOnGround() && !mc.world.getBlockState(bp).isAir() && fastTower.get())
mc.player.setVelocity(0, -0.28f, 0);
}
if (!mc.world.getBlockState(bp).isAir())
prevBp.set(bp);
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class ElytraFlightMode method handleAutopilot.
public void handleAutopilot() {
if (!MatHax.mc.player.isFallFlying())
return;
if (elytraFly.autoPilot.get() && MatHax.mc.player.getY() > elytraFly.autoPilotMinimumHeight.get()) {
MatHax.mc.options.forwardKey.setPressed(true);
lastForwardPressed = true;
}
if (elytraFly.useFireworks.get()) {
if (ticksLeft <= 0) {
ticksLeft = elytraFly.autoPilotFireworkDelay.get() * 20;
FindItemResult itemResult = InvUtils.findInHotbar(Items.FIREWORK_ROCKET);
if (!itemResult.found())
return;
if (itemResult.isOffhand()) {
MatHax.mc.interactionManager.interactItem(MatHax.mc.player, MatHax.mc.world, Hand.OFF_HAND);
MatHax.mc.player.swingHand(Hand.OFF_HAND);
} else {
InvUtils.swap(itemResult.slot(), true);
MatHax.mc.interactionManager.interactItem(MatHax.mc.player, MatHax.mc.world, Hand.MAIN_HAND);
MatHax.mc.player.swingHand(Hand.MAIN_HAND);
InvUtils.swapBack();
}
}
ticksLeft--;
}
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class EXPThrower method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
FindItemResult exp = InvUtils.findInHotbar(Items.EXPERIENCE_BOTTLE);
if (!exp.found())
return;
Rotations.rotate(mc.player.getYaw(), 90, () -> {
if (exp.getHand() != null)
mc.interactionManager.interactItem(mc.player, mc.world, exp.getHand());
else {
InvUtils.swap(exp.slot(), true);
mc.interactionManager.interactItem(mc.player, mc.world, exp.getHand());
InvUtils.swapBack();
}
});
}
Aggregations