use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class AutoBedCraft method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
if (PlayerUtils.getTotalHealth() <= minHealth.get())
return;
if (automatic.get() && isOutOfMaterial() && !alertedNoMats) {
error("Cannot activate auto mode, no material left.");
alertedNoMats = true;
}
if (automatic.get() && needsRefill() && canRefill(true) && !isOutOfMaterial() && !(mc.player.currentScreenHandler instanceof CraftingScreenHandler)) {
FindItemResult craftTable = InvUtils.findCraftTable();
if (!craftTable.found()) {
toggle();
error("No crafting tables in hotbar!");
return;
}
BlockPos tablePos;
tablePos = findCraftingTable();
if (tablePos == null) {
placeCraftingTable(craftTable);
return;
}
openCraftingTable(tablePos);
if (chatInfo.get() && !startedRefill) {
info("Refilling...");
startedRefill = true;
}
didRefill = true;
return;
}
if (didRefill && !needsRefill()) {
if (chatInfo.get())
info("Refill complete.");
didRefill = false;
startedRefill = false;
}
if (mc.player.currentScreenHandler instanceof CraftingScreenHandler) {
if (!canRefill(false)) {
mc.player.closeHandledScreen();
if (antiDesync.get())
mc.player.getInventory().updateItems();
return;
}
CraftingScreenHandler currentScreenHandler = (CraftingScreenHandler) mc.player.currentScreenHandler;
if (isOutOfMaterial()) {
if (chatInfo.get())
error("You are out of material!");
if (disableNoMats.get())
toggle();
mc.player.closeHandledScreen();
if (antiDesync.get())
mc.player.getInventory().updateItems();
return;
}
if (InvUtils.isInventoryFull()) {
if (disableAfter.get())
toggle();
if (closeAfter.get()) {
mc.player.closeHandledScreen();
if (antiDesync.get())
mc.player.getInventory().updateItems();
}
if (chatInfo.get() && !automatic.get())
info("Your inventory is full.");
return;
}
List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getResultsForGroup(RecipeBookGroup.CRAFTING_MISC);
for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) {
for (Recipe<?> recipe : recipeResultCollection.getRecipes(true)) {
if (recipe.getOutput().getItem() instanceof BedItem) {
assert mc.interactionManager != null;
mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, false);
windowClick(currentScreenHandler, 0, SlotActionType.QUICK_MOVE, 1);
}
}
}
}
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class ElytraFlightMode method onTick.
public void onTick() {
if (elytraFly.autoReplenish.get()) {
FindItemResult fireworks = InvUtils.find(Items.FIREWORK_ROCKET);
FindItemResult hotbarFireworks = InvUtils.findInHotbar(Items.FIREWORK_ROCKET);
if (!hotbarFireworks.found() && fireworks.found()) {
InvUtils.move().from(fireworks.slot()).toHotbar(elytraFly.replenishSlot.get() - 1);
}
}
if (elytraFly.replace.get()) {
ItemStack chestStack = MatHax.mc.player.getInventory().getArmorStack(2);
if (chestStack.getItem() == Items.ELYTRA) {
if (chestStack.getMaxDamage() - chestStack.getDamage() <= elytraFly.replaceDurability.get()) {
FindItemResult elytra = InvUtils.find(stack -> stack.getMaxDamage() - stack.getDamage() > elytraFly.replaceDurability.get() && stack.getItem() == Items.ELYTRA);
InvUtils.move().from(elytra.slot()).toArmor(2);
}
}
}
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class HoleFiller method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
for (Hole hole : holes) holePool.free(hole);
holes.clear();
FindItemResult block = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BlockItem && blocks.get().contains(Block.getBlockFromItem(itemStack.getItem())));
if (!block.found())
return;
BlockIterator.register(horizontalRadius.get(), verticalRadius.get(), (blockPos, blockState) -> {
if (!validHole(blockPos))
return;
int bedrock = 0, obsidian = 0;
Direction air = null;
for (Direction direction : Direction.values()) {
if (direction == Direction.UP)
continue;
BlockState state = mc.world.getBlockState(blockPos.offset(direction));
if (state.getBlock() == Blocks.BEDROCK)
bedrock++;
else if (state.getBlock() == Blocks.OBSIDIAN)
obsidian++;
else if (direction == Direction.DOWN)
return;
else if (validHole(blockPos.offset(direction)) && air == null) {
for (Direction dir : Direction.values()) {
if (dir == direction.getOpposite() || dir == Direction.UP)
continue;
BlockState blockState1 = mc.world.getBlockState(blockPos.offset(direction).offset(dir));
if (blockState1.getBlock() == Blocks.BEDROCK)
bedrock++;
else if (blockState1.getBlock() == Blocks.OBSIDIAN)
obsidian++;
else
return;
}
air = direction;
}
}
if (obsidian + bedrock == 5 && air == null)
holes.add(holePool.get().set(blockPos, NULL));
else if (obsidian + bedrock == 8 && doubles.get() && air != null) {
holes.add(holePool.get().set(blockPos, Dir.get(air)));
}
});
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class HoleFiller method onTickPost.
@EventHandler
private void onTickPost(TickEvent.Post event) {
if (timer <= 0 && !holes.isEmpty()) {
FindItemResult block = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BlockItem && blocks.get().contains(Block.getBlockFromItem(itemStack.getItem())));
BlockUtils.place(holes.get(0).blockPos, block, rotate.get(), 10, true);
timer = placeDelay.get();
}
timer--;
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class Offhand method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
if (autoTotem.mode.get() == AutoTotem.Mode.Strict && autoTotem.isActive()) {
info("(highlight)%s(default) does not work with (highlight)%s(default) set to (highlight)%s(default) mode, disabling...", title, autoTotem.title, "Strict");
toggle();
return;
}
if (autoTotem.mode.get() != AutoTotem.Mode.Strict && autoTotem.isActive() && PlayerUtils.getTotalHealth() - PlayerUtils.possibleHealthReductions(autoTotem.explosion.get(), autoTotem.fall.get()) <= autoTotem.health.get())
return;
if ((mc.player.getMainHandStack().getItem() instanceof SwordItem || mc.player.getMainHandStack().getItem() instanceof AxeItem) && swordGap.get())
currentItem = Item.EGap;
else if ((Modules.get().isActive(CrystalAura.class) && crystalCrystalAura.get()) || mc.interactionManager.isBreakingBlock() && crystalMine.get())
currentItem = Item.Crystal;
else
currentItem = item.get();
if (mc.player.getOffHandStack().getItem() != currentItem.item) {
FindItemResult item = InvUtils.find(itemStack -> itemStack.getItem() == currentItem.item, hotbar.get() ? 0 : 9, 35);
if (!item.found()) {
if (!sentMessage) {
warning("Chosen item not found" + (toggleNotFound.get() ? ", disabling..." : "."));
if (toggleNotFound.get()) {
toggle();
return;
}
sentMessage = true;
}
} else if ((isClicking || !rightClick.get()) && !autoTotem.isLocked() && !item.isOffhand()) {
InvUtils.move().from(item.slot()).toOffhand();
sentMessage = false;
}
} else if (!isClicking && rightClick.get()) {
if (autoTotem.isActive()) {
FindItemResult totem = InvUtils.find(itemStack -> itemStack.getItem() == Items.TOTEM_OF_UNDYING, hotbar.get() ? 0 : 9, 35);
if (totem.found() && !totem.isOffhand())
InvUtils.move().from(totem.slot()).toOffhand();
} else {
FindItemResult empty = InvUtils.find(ItemStack::isEmpty, hotbar.get() ? 0 : 9, 35);
if (empty.found())
InvUtils.move().fromOffhand().to(empty.slot());
}
}
}
Aggregations