use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class AutoShearer method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
entity = null;
for (Entity entity : mc.world.getEntities()) {
if (!(entity instanceof SheepEntity) || ((SheepEntity) entity).isSheared() || ((SheepEntity) entity).isBaby() || mc.player.distanceTo(entity) > distance.get())
continue;
boolean findNewShears = false;
if (mc.player.getInventory().getMainHandStack().getItem() instanceof ShearsItem) {
if (antiBreak.get() && mc.player.getInventory().getMainHandStack().getDamage() >= mc.player.getInventory().getMainHandStack().getMaxDamage() - 1)
findNewShears = true;
} else if (mc.player.getInventory().offHand.get(0).getItem() instanceof ShearsItem) {
if (antiBreak.get() && mc.player.getInventory().offHand.get(0).getDamage() >= mc.player.getInventory().offHand.get(0).getMaxDamage() - 1)
findNewShears = true;
else
offHand = true;
} else {
findNewShears = true;
}
boolean foundShears = !findNewShears;
if (findNewShears) {
FindItemResult shears = InvUtils.findInHotbar(itemStack -> (!antiBreak.get() || (antiBreak.get() && itemStack.getDamage() < itemStack.getMaxDamage() - 1)) && itemStack.getItem() == Items.SHEARS);
if (InvUtils.swap(shears.slot(), true))
foundShears = true;
}
if (foundShears) {
this.entity = entity;
if (rotate.get())
Rotations.rotate(Rotations.getYaw(entity), Rotations.getPitch(entity), -100, this::interact);
else
interact();
return;
}
}
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class EChestFarmer method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
// Finding target pos
if (target == null) {
if (mc.crosshairTarget == null || mc.crosshairTarget.getType() != HitResult.Type.BLOCK)
return;
BlockPos pos = ((BlockHitResult) mc.crosshairTarget).getBlockPos().up();
BlockState state = mc.world.getBlockState(pos);
if (state.getMaterial().isReplaceable() || state.getBlock() == Blocks.ENDER_CHEST) {
target = ((BlockHitResult) mc.crosshairTarget).getBlockPos().up();
} else
return;
}
// Disable if the block is too far away
if (PlayerUtils.distanceTo(target) > mc.interactionManager.getReachDistance()) {
error("Target block pos out of reach.");
target = null;
return;
}
// Toggle if obby amount reached
if (selfToggle.get() && InvUtils.find(Items.OBSIDIAN).count() - (ignoreExisting.get() ? startCount : 0) >= amount.get()) {
InvUtils.swapBack();
error("Obsidian amount reached, disabling...");
toggle();
return;
}
// Break existing echest at target pos
if (mc.world.getBlockState(target).getBlock() == Blocks.ENDER_CHEST) {
double bestScore = -1;
int bestSlot = -1;
for (int i = 0; i < 9; i++) {
ItemStack itemStack = mc.player.getInventory().getStack(i);
if (EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, itemStack) > 0)
continue;
double score = itemStack.getMiningSpeedMultiplier(Blocks.ENDER_CHEST.getDefaultState());
if (score > bestScore) {
bestScore = score;
bestSlot = i;
}
}
if (bestSlot == -1)
return;
InvUtils.swap(bestSlot, true);
BlockUtils.breakBlock(target, swingHand.get());
}
// Place echest if the target pos is empty
if (mc.world.getBlockState(target).getMaterial().isReplaceable()) {
FindItemResult echest = InvUtils.findInHotbar(Items.ENDER_CHEST);
if (!echest.found()) {
error("No EChests in your hotbar, disabling...");
toggle();
return;
}
BlockUtils.place(target, echest, true, 0, true);
}
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class SpawnProofer method onTickPre.
@EventHandler
private void onTickPre(TickEvent.Pre event) {
if (delay.get() != 0 && ticksWaited < delay.get() - 1)
return;
FindItemResult block = InvUtils.findInHotbar(itemStack -> blocks.get().contains(Block.getBlockFromItem(itemStack.getItem())));
if (!block.found()) {
error("Found none of the chosen blocks in your hotbar, disabling...");
toggle();
return;
}
for (BlockPos.Mutable blockPos : spawns) spawnPool.free(blockPos);
spawns.clear();
BlockIterator.register(range.get(), range.get(), (blockPos, blockState) -> {
BlockUtils.MobSpawn spawn = BlockUtils.isValidMobSpawn(blockPos, newMobSpawnLightLevel.get());
if ((spawn == BlockUtils.MobSpawn.Always && (mode.get() == Mode.Always || mode.get() == Mode.Both)) || spawn == BlockUtils.MobSpawn.Potential && (mode.get() == Mode.Potential || mode.get() == Mode.Both))
spawns.add(spawnPool.get().set(blockPos));
});
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class InfinityMiner method findPickaxe.
private boolean findPickaxe() {
Predicate<ItemStack> pickaxePredicate = (stack -> stack.getItem() instanceof PickaxeItem && Utils.hasEnchantments(stack, Enchantments.MENDING) && !Utils.hasEnchantments(stack, Enchantments.SILK_TOUCH));
FindItemResult bestPick = InvUtils.findInHotbar(pickaxePredicate);
if (bestPick.isOffhand())
InvUtils.quickMove().fromOffhand().toHotbar(mc.player.getInventory().selectedSlot);
else if (bestPick.isHotbar())
InvUtils.swap(bestPick.slot(), false);
return InvUtils.findInHotbar(pickaxePredicate).isMainHand();
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class LiquidFiller method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
// Update timer according to delay
if (timer < delay.get()) {
timer++;
return;
} else
timer = 0;
// Find slot with a block
FindItemResult item = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BlockItem && whitelist.get().contains(Block.getBlockFromItem(itemStack.getItem())));
if (!item.found())
return;
// Loop blocks around the player
BlockIterator.register(horizontalRadius.get(), verticalRadius.get(), (blockPos, blockState) -> {
// Check if the block a source liquid block
if (isSource(blockState)) {
Block liquid = blockState.getBlock();
PlaceIn placeIn = placeInLiquids.get();
if (placeIn == PlaceIn.Both || (placeIn == PlaceIn.Lava && liquid == Blocks.LAVA) || (placeIn == PlaceIn.Water && liquid == Blocks.WATER)) {
if (BlockUtils.place(blockPos, item, rotate.get(), 0, true))
BlockIterator.disableCurrent();
}
}
});
}
Aggregations