Начинающий
Че за баллы мне дали какието 18 апр истекают, имьа типа наверное чиназе
Хуйня которая не воркРаботает быстрее чем в нищей дельте в 2-4 раза.
Пожалуйста, авторизуйтесь для просмотра ссылки.
Java:public class AutoFarm extends Module { private final StopWatch stopWatchMain = new StopWatch(); private final StopWatch stopWatch = new StopWatch(); private boolean autoRepair, expValid; @Override public void toggle() { super.toggle(); autoRepair = false; expValid = false; } @EventHandler public void onStopUseItemEvent(StopUseItemEvent e) { e.setCancelled(mc.player.getFoodStats().needFood()); } @EventHandler public void onUpdate(UpdateEvent e) { List<Item> hoeItems = List.of(Items.NETHERITE_HOE, Items.DIAMOND_HOE); List<Item> plantsItems = List.of(Items.CARROT, Items.POTATO); Slot expSlot = InvUtil.getInventorySlot(Items.EXPERIENCE_BOTTLE); Slot plantSlot = InvUtil.getInventorySlot(plantsItems); Slot hoeSlot = InvUtil.getInventorySlot(hoeItems); int expCount = InvUtil.getInventoryCount(Items.EXPERIENCE_BOTTLE); Item mainHandItem = mc.player.getHeldItemMainhand().getItem(); Item offHandItem = mc.player.getHeldItemOffhand().getItem(); if (hoeSlot == null || MoveUtil.isMoving() || !stopWatchMain.finished(500)) return; RotationComponent.update(new Rotation(Rotation.cameraYaw(), 90), 360, 360, 0, 5); float itemStrength = 1 - MathHelper.clamp((float) hoeSlot.getStack().getDamage() / (float) hoeSlot.getStack().getMaxDamage(), 0, 1); if (itemStrength < 0.05) { autoRepair = true; } else if (itemStrength == 1 && autoRepair) { stopWatchMain.reset(); autoRepair = false; expValid = false; return; } expValid = expCount >= 320 || expCount != 0 && expValid; if (mc.player.getFoodStats().needFood()) { Slot slot = InvUtil.getSlotFoodMaxSaturation(); if (!offHandItem.equals(slot.getStack().getItem())) { if (mc.currentScreen instanceof ContainerScreen<?>) { mc.player.closeScreen(); return; } InvUtil.clickSlot(slot, 40, ClickType.SWAP, false); } mc.playerController.processRightClick(mc.player, mc.world, Hand.OFF_HAND); } else if (mc.player.inventory.getFirstEmptyStack() == -1) { if (!plantsItems.contains(offHandItem)) { InvUtil.clickSlot(plantSlot, 40, ClickType.SWAP, false); return; } if (mc.currentScreen instanceof ContainerScreen<?> screen) { if (screen.getTitle().getString().equals("● Выберите секцию")) { InvUtil.clickSlotId(21, 0, ClickType.PICKUP, true); return; } if (screen.getTitle().getString().equals("Скупщик еды")) { InvUtil.clickSlotId(offHandItem.equals(Items.CARROT) ? 10 : 11, 0, ClickType.PICKUP, true); return; } } if (stopWatch.finished(1000)) { mc.player.sendChatMessage("/buyer"); stopWatch.reset(); } } else if (autoRepair) { if (expValid) { if (mc.currentScreen instanceof ContainerScreen<?>) { mc.player.closeScreen(); stopWatchMain.reset(); return; } if (!offHandItem.equals(Items.EXPERIENCE_BOTTLE)) { InvUtil.clickSlot(expSlot, 40, ClickType.SWAP, false); } if (!hoeItems.contains(mainHandItem)) { InvUtil.clickSlot(hoeSlot, mc.player.inventory.currentItem, ClickType.SWAP, false); } mc.player.connection.sendPacket(new CPlayerTryUseItemPacket(Hand.OFF_HAND)); } else if (stopWatch.finished(800)) { if (mc.currentScreen instanceof ContainerScreen<?> screen) { if (screen.getTitle().getString().contains("Пузырек опыта")) { mc.player.openContainer.inventorySlots.stream().filter(s -> s.getStack().getTag() != null && s.slotNumber < 45) .min(Comparator.comparingInt(s -> AutoBuyUtil.getPrice(s.getStack()) / s.getStack().getCount())) .ifPresent(s -> InvUtil.clickSlot(s, 0, ClickType.QUICK_MOVE, true)); stopWatch.reset(); return; } else if (screen.getTitle().getString().contains("Подозрительная цена")) { InvUtil.clickSlotId(0, 0, ClickType.QUICK_MOVE, true); stopWatch.reset(); return; } } mc.player.sendChatMessage("/ah search Пузырёк Опыта"); stopWatch.reset(); } } else { BlockPos pos = mc.player.getPosition(); if (mc.world.getBlockState(pos).getBlock().equals(Blocks.FARMLAND)) { if (hoeItems.contains(mainHandItem) && plantsItems.contains(offHandItem)) { mc.player.connection.sendPacket(new CPlayerTryUseItemOnBlockPacket(Hand.OFF_HAND, new BlockRayTraceResult(mc.player.getPositionVec(), Direction.UP, pos, false))); IntStream.range(0, 3).forEach(i -> mc.player.connection.sendPacket(new CPlayerTryUseItemOnBlockPacket(Hand.MAIN_HAND, new BlockRayTraceResult(mc.player.getPositionVec(), Direction.UP, pos.up(), false)))); mc.player.connection.sendPacket(new CPlayerDiggingPacket(CPlayerDiggingPacket.Action.START_DESTROY_BLOCK, pos.up(), Direction.UP)); } else { if (mc.currentScreen instanceof ContainerScreen<?>) { mc.player.closeScreen(); stopWatchMain.reset(); return; } if (!plantsItems.contains(offHandItem)) { InvUtil.clickSlot(plantSlot, 40, ClickType.SWAP, false); } if (!hoeItems.contains(mainHandItem)) { InvUtil.clickSlot(hoeSlot, mc.player.inventory.currentItem, ClickType.SWAP, false); } } } } } }
Методы которые многие просили:public Slot getInventorySlot(Item item) { return mc.player.openContainer.inventorySlots.stream().filter(s -> s.getStack().getItem().equals(item) && s.slotNumber >= mc.player.openContainer.inventorySlots.size() - 36).findFirst().orElse(null); } public Slot getInventorySlot(List<Item> item) { return mc.player.openContainer.inventorySlots.stream().filter(s -> item.contains(s.getStack().getItem()) && s.slotNumber >= mc.player.openContainer.inventorySlots.size() - 36).findFirst().orElse(null); } public Slot getFoodMaxSaturationSlot() { return mc.player.openContainer.inventorySlots.stream().filter(s -> s.getStack().getItem().getFood() != null && !s.getStack().getItem().getFood().canEatWhenFull()).max(Comparator.comparingDouble(s -> s.getStack().getItem().getFood().getSaturation())).orElse(null); } public int getInventoryCount(Item item) { return IntStream.range(0, 45).filter(i -> mc.player.inventory.getStackInSlot(i).getItem().equals(item)).map(i -> mc.player.inventory.getStackInSlot(i).getCount()).sum(); } public void clickSlot(Slot slot, int button, ClickType clickType, boolean packet) { if (slot != null) clickSlotId(slot.slotNumber, button, clickType, packet); } public void clickSlotId(int slot, int button, ClickType clickType, boolean packet) { if (packet) { mc.player.connection.sendPacket(new CClickWindowPacket(mc.player.openContainer.windowId, slot, button, clickType, ItemStack.EMPTY, mc.player.openContainer.getNextTransactionID(mc.player.inventory))); } else { mc.playerController.windowClick(mc.player.openContainer.windowId, slot, button, clickType, mc.player); } } public int getPrice(ItemStack itemStack) { CompoundNBT tag = itemStack.getTag(); if (tag == null) return -1; String price = StringUtils.substringBetween(tag.toString(), "\"text\":\" $", "\"}]"); if (price == null || price.isEmpty()) return -1; price = price.replaceAll(" ", "").replaceAll(",", ""); return Integer.parseInt(price); }