use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class Quiver method onActivate.
@Override
public void onActivate() {
FindItemResult bow = InvUtils.findInHotbar(Items.BOW);
if (!bow.isHotbar()) {
error("No bow found, disabling...");
toggle();
}
mc.options.useKey.setPressed(false);
mc.interactionManager.stopUsingItem(mc.player);
InvUtils.swap(bow.slot(), true);
arrowSlots.clear();
List<StatusEffect> usedEffects = new ArrayList<>();
for (int i = mc.player.getInventory().size(); i > 0; i--) {
if (i == mc.player.getInventory().selectedSlot)
continue;
ItemStack item = mc.player.getInventory().getStack(i);
if (item.getItem() != Items.TIPPED_ARROW)
continue;
List<StatusEffectInstance> effects = PotionUtil.getPotionEffects(item);
if (effects.isEmpty())
continue;
StatusEffect effect = effects.get(0).getEffectType();
if (this.effects.get().contains(effect) && !usedEffects.contains(effect) && (!hasEffect(effect) || !checkEffects.get())) {
usedEffects.add(effect);
arrowSlots.add(i);
}
}
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class AutoEXP method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
if (playerNearStop.get() && TargetUtils.isPlayerNear(playerNearStopRange.get()))
return;
if (repairingI == -1) {
if (mode.get() != Mode.Hands) {
for (int i = 0; i < mc.player.getInventory().armor.size(); i++) {
if (needsRepair(mc.player.getInventory().armor.get(i), minThreshold.get())) {
repairingI = SlotUtils.ARMOR_START + i;
break;
}
}
}
if (mode.get() != Mode.Armor && repairingI == -1) {
for (Hand hand : Hand.values()) {
if (needsRepair(mc.player.getStackInHand(hand), minThreshold.get())) {
repairingI = hand == Hand.MAIN_HAND ? mc.player.getInventory().selectedSlot : SlotUtils.OFFHAND;
break;
}
}
}
}
if (repairingI != -1) {
if (!needsRepair(mc.player.getInventory().getStack(repairingI), maxThreshold.get())) {
repairingI = -1;
return;
}
FindItemResult exp = InvUtils.find(Items.EXPERIENCE_BOTTLE);
if (exp.found()) {
if (!exp.isHotbar() && !exp.isOffhand()) {
if (!replenish.get())
return;
InvUtils.move().from(exp.slot()).toHotbar(slot.get() - 1);
}
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, Hand.MAIN_HAND);
InvUtils.swapBack();
}
});
}
}
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class Notebot method onTickSetup.
private void onTickSetup() {
if (ticks < delay.get())
return;
ticks = 0;
if (currentNote >= uniqueNotes.size()) {
stage = Stage.Playing;
info("Loading done.");
Play();
return;
}
int index = currentNote + offset;
BlockPos pos;
if (index < scannedNoteblocks.size()) {
pos = scannedNoteblocks.get(index);
if (mc.world.getBlockState(pos).getBlock() != Blocks.NOTE_BLOCK)
offset++;
else {
blockPositions.put(uniqueNotes.get(currentNote), pos);
stage = Stage.Tune;
}
return;
}
FindItemResult noteBlock = InvUtils.findInHotbar(Items.NOTE_BLOCK);
if (!noteBlock.found()) {
error("Not enough noteblocks");
disable();
return;
}
index -= scannedNoteblocks.size();
try {
pos = mc.player.getBlockPos().add(possibleBlockPos.get(index));
} catch (IndexOutOfBoundsException e) {
error("Not enough valid positions.");
disable();
return;
}
if (!isValidEmptySpot(pos) || !NotebotUtils.isValidInstrument(pos, instrument.get())) {
offset++;
return;
}
if (!BlockUtils.place(pos, noteBlock, true, 100, true))
offset++;
else {
blockPositions.put(uniqueNotes.get(currentNote), pos);
stage = Stage.Tune;
}
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class LocateCommand method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(literal("buried_treasure").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.FILLED_MAP) {
error("You need to hold a treasure map first");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 == null) {
error("Couldn't locate the cross. Are you holding a (highlight)treasure map(default)?");
return SINGLE_SUCCESS;
}
NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT == null) {
error("Couldn't locate the cross. Are you holding a (highlight)treasure map(default)?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
BaseText text = new LiteralText("Buried Treasure located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("lodestone").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.COMPASS) {
error("You need to hold a lodestone compass");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
if (tag == null) {
error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
return SINGLE_SUCCESS;
}
NbtCompound nbt1 = tag.getCompound("LodestonePos");
if (nbt1 == null) {
error("Couldn't get the NBT data. Are you holding a (highlight)lodestone(default) compass?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(nbt1.getDouble("X"), nbt1.getDouble("Y"), nbt1.getDouble("Z"));
BaseText text = new LiteralText("Lodestone located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("mansion").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() != Items.FILLED_MAP) {
error("You need to hold a woodland explorer map first");
return SINGLE_SUCCESS;
}
NbtCompound tag = stack.getNbt();
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 == null) {
error("Couldn't locate the mansion. Are you holding a (highlight)woodland explorer map(default)?");
return SINGLE_SUCCESS;
}
NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT == null) {
error("Couldn't locate the mansion. Are you holding a (highlight)woodland explorer map(default)?");
return SINGLE_SUCCESS;
}
Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
BaseText text = new LiteralText("Mansion located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("stronghold").executes(s -> {
FindItemResult eye = InvUtils.findInHotbar(Items.ENDER_EYE);
if (eye.found()) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("follow entity minecraft:eye_of_ender");
firstStart = null;
firstEnd = null;
secondStart = null;
secondEnd = null;
MatHax.EVENT_BUS.subscribe(this);
info("Please throw the first Eye of Ender");
} else {
Vec3d coords = findByBlockList(strongholdBlocks);
if (coords == null) {
error("No stronghold found nearby. You can use (highlight)Ender Eyes(default) for more success.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Stronghold located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
}
return SINGLE_SUCCESS;
}));
builder.then(literal("nether_fortress").executes(s -> {
Vec3d coords = findByBlockList(netherFortressBlocks);
if (coords == null) {
error("No nether fortress found.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Fortress located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("monument").executes(s -> {
ItemStack stack = mc.player.getInventory().getMainHandStack();
if (stack.getItem() == Items.FILLED_MAP) {
NbtCompound tag = stack.getNbt();
if (tag != null) {
NbtList nbt1 = (NbtList) tag.get("Decorations");
if (nbt1 != null) {
NbtCompound iconNBT = nbt1.getCompound(0);
if (iconNBT != null) {
Vec3d coords = new Vec3d(iconNBT.getDouble("x"), iconNBT.getDouble("y"), iconNBT.getDouble("z"));
BaseText text = new LiteralText("Monument located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}
}
}
}
Vec3d coords = findByBlockList(monumentBlocks);
if (coords == null) {
error("No monument found. You can try using a (highlight)Ocean explorer map(default) for more success.");
return SINGLE_SUCCESS;
}
BaseText text = new LiteralText("Monument located at ");
text.append(ChatUtils.formatCoords(coords));
text.append(".");
info(text);
return SINGLE_SUCCESS;
}));
builder.then(literal("cancel").executes(s -> {
cancel();
return SINGLE_SUCCESS;
}));
}
use of mathax.client.utils.player.FindItemResult in project Client by MatHax.
the class AutoNametag method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
// Nametag in hobar
FindItemResult findNametag = InvUtils.findInHotbar(Items.NAME_TAG);
if (!findNametag.found()) {
error("No Nametag in Hotbar");
toggle();
return;
}
// Target
target = TargetUtils.get(entity -> {
if (PlayerUtils.distanceTo(entity) > range.get())
return false;
if (!entities.get().getBoolean(entity.getType()))
return false;
if (entity.hasCustomName())
return renametag.get() && entity.getCustomName() != mc.player.getInventory().getStack(findNametag.slot()).getName();
return false;
}, priority.get());
if (target == null)
return;
// Swapping slots
InvUtils.swap(findNametag.slot(), true);
offHand = findNametag.isOffhand();
// Interaction
if (rotate.get())
Rotations.rotate(Rotations.getYaw(target), Rotations.getPitch(target), -100, this::interact);
else
interact();
}
Aggregations