Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Вопрос Вопрос с AutoLes

вот тебе код с нуклеара, портни себе ( ну или попроси чат гпт )


Код:
Expand Collapse Copy
package nuclear.module.impl.player;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import mods.baritone.api.BaritoneAPI;
import mods.baritone.api.pathing.goals.GoalBlock;
import nuclear.control.events.Event;
import nuclear.control.events.impl.player.EventMotion;
import nuclear.control.events.impl.player.EventUpdate;
import nuclear.module.api.Annotation;

@Annotation(
   name = "AutoLes",
   type = TypeList.Player,
   desc = "Автоматически ломает багнутое дерево"
)
public class AutoLes extends Module implements MinecraftAccessor {
   public int attackCount = 0;
   public TimerUtil payTimer = new TimerUtil();
   public static double staticDouble1;
   public TimerUtil stateTimer = new TimerUtil();
   public long payCheckDeadline = 0L;
   public Boolean savedAllowBreak = null;
   public long attackStartTime = 0L;
   public BlockPos savedBlockPos = null;
   public static long staticLong1;
   public static Vec3d attackNpcPos = new Vec3d(-40.5D, 49.0D, 156.5D);
   public boolean isPayingMode = false;
   public Boolean savedRenderPath = null;
   public long balCheckTime = 0L;
   public Vec3d calculatedGoalPos = null;
   public static Vec3d woodNpcPos = new Vec3d(-41.5D, 48.0D, 156.5D);
   public AutoLes.State currentState;
   public BlockPos currentBreakTarget;
   public boolean isReturningToNpc = false;
   public StringSetting nickSetting = (new StringSetting("Ник", "")).setLocalizedName("Nick", "Nick", "Нік").setVisible(() -> {
      return this.autoPaySetting.get();
   });
   public static long staticLong2;
   public long lastAttackTime = 0L;
   public boolean isNavigating = false;
   public BooleanSetting autoPaySetting = (new BooleanSetting("Авто перевод", false)).setLocalizedName("Auto pay", "Auto pay", "Авто pay");
   public static long staticLong3;
   public long lastPayTime = 0L;
   public BooleanSetting forMoneySetting = (new BooleanSetting("Авто зарплата", true)).setLocalizedName("For money", "Za pieniądze", "На гроші");
   public long lastBalance = -1L;
   public static double staticDouble2;

   public Entity findNearestEntity(Vec3d pos, double range) {
      Entity nearest = null;
      double rangeSq = range * range;
      Iterator iterator = mc.world.getEntities().iterator();

      while (true) {
         Entity entity;
         double distSq;
         do {
            do {
               do {
                  if (!iterator.hasNext()) {
                     return nearest;
                  }

                  entity = (Entity) iterator.next();
               } while (entity == mc.player);

               distSq = entity.squaredDistanceTo(pos.x, pos.y, pos.z);
            } while (!(distSq <= rangeSq));
         } while (nearest != null && !(distSq < nearest.squaredDistanceTo(pos.x, pos.y, pos.z)));

         nearest = entity;
      }
   }

   public void processStateMachine() {
      if (mc.player != null && mc.world != null) {
         if (this.currentState == AutoLes.State.IDLE) {
            if (this.stateTimer.hasReached(900000L)) {
               this.startFarmCycle();
            }

         } else {
            switch (this.currentState) {
            case NAVIGATING_TO_NPC:
               if (this.isNearPosition(attackNpcPos, 3.0D)) {
                  this.currentState = AutoLes.State.ATTACKING_NPC;
                  this.attackStartTime = System.currentTimeMillis();
                  this.attackCount = 0;
                  this.lastAttackTime = 0L;
                  this.cancelBaritone();
               }
               break;
            case ATTACKING_NPC:
               long currentTime = System.currentTimeMillis();
               if (this.attackCount < 5 && currentTime - this.lastAttackTime >= 400L) {
                  this.attackNearbyEntity();
                  ++this.attackCount;
                  this.lastAttackTime = currentTime;
               }

               if (currentTime - this.attackStartTime > 3200L || this.attackCount >= 5) {
                  this.currentState = AutoLes.State.NAVIGATING_TO_WOOD;
                  this.isReturningToNpc = true;
                  this.navigateToSavedPos();
               }
               break;
            case NAVIGATING_TO_WOOD:
               if (this.savedBlockPos != null && this.isWithinRange(this.savedBlockPos, 1.6D)) {
                  this.cancelBaritone();
                  this.currentState = AutoLes.State.IDLE;
                  this.isNavigating = false;
                  this.isReturningToNpc = false;
                  this.savedBlockPos = null;
                  this.stateTimer.reset();
               }
            }

         }
      }
   }

   public boolean isLogBlock(BlockPos pos) {
      BlockState state = mc.world.getBlockState(pos);
      return state.isIn(BlockTags.LOGS);
   }

   public boolean isWithinRange(BlockPos pos, double range) {
      return mc.player.squaredDistanceTo((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) <= range * range;
   }

   public void attackNearbyEntity() {
      Entity entity = this.findNearestEntity(attackNpcPos, 3.5D);
      if (entity != null) {
         mc.interactionManager.attackEntity(mc.player, entity, Hand.MAIN_HAND);
         mc.player.swingHand(Hand.MAIN_HAND);
      }
   }

   public void resetToIdle() {
      this.cancelBaritone();
      this.currentState = AutoLes.State.IDLE;
      this.isNavigating = false;
      this.isReturningToNpc = false;
      this.savedBlockPos = null;
      this.stateTimer.reset();
   }

   public boolean onEvent(Event event) {
      if (event instanceof EventPostUpdate) {
         if (this.forMoneySetting.get()) {
            this.processStateMachine();
         }

         if (!this.isNavigating) {
            this.processBreaking();
         }

         if (this.autoPaySetting.get()) {
            this.processAutoPayment();
         }
      } else if (event instanceof EventMotion) {
         EventMotion motionEvent = (EventMotion) event;
         if (this.forMoneySetting.get() && this.currentState == AutoLes.State.ATTACKING_NPC) {
            this.handleMotionEvent(motionEvent);
         }
      } else if (event instanceof EventPacket) {
         EventPacket packetEvent = (EventPacket) event;
         if (packetEvent.isReceive()) {
            Packet packet = packetEvent.getPacket();
            if (packet instanceof SPacketChat) {
               SPacketChat chatPacket = (SPacketChat) packet;
               this.handleChatMessage(chatPacket);
            }
         }
      }

      return false;
   }

   public void handleChatMessage(SPacketChat chatPacket) {
      if (this.autoPaySetting.get()) {
         ChatType type = chatPacket.getType();
         if (type == ChatType.SYSTEM || type == ChatType.GAME_INFO || type == ChatType.CHAT) {
            Text message = chatPacket.getMessage();
            if (message != null) {
               String text = message.getString();
               String stripped = ChatFormatting.stripFormatting(text);
               if (stripped != null) {
                  if (stripped.contains("Баланс")) {
                     long balance = this.parseBalance(stripped);
                     if (balance > 0L) {
                        this.lastBalance = balance;
                        this.lastPayTime = System.currentTimeMillis();
                     }
                  }
               }
            }
         }
      }
   }

   public void processBreaking() {
      if (mc.player != null && mc.world != null) {
         if (this.currentBreakTarget != null) {
            if (this.isInRange(this.currentBreakTarget)) {
               BlockState state = mc.world.getBlockState(this.currentBreakTarget);
               if (state.isAir()) {
                  this.currentBreakTarget = null;
               } else {
                  mc.interactionManager.attackBlock(this.currentBreakTarget, Direction.UP);
                  mc.interactionManager.breakBlock(this.currentBreakTarget);
                  mc.player.swingHand(Hand.MAIN_HAND);
               }
            } else {
               this.currentBreakTarget = null;
            }
         }

         if (this.currentBreakTarget == null) {
            BlockPos playerPos = mc.player.getBlockPos();
            BlockPos searchMin = playerPos.add(-5, -5, -5);
            BlockPos searchMax = playerPos.add(5, 5, 5);
            ArrayList blockPositions = BlockHelper.INSTANCE.getBlockPositions(searchMin, searchMax);
            this.currentBreakTarget = (BlockPos) blockPositions.stream().filter(this::isLogBlock).filter(this::isInRange).min(Comparator.comparing((pos) -> {
               return mc.player.squaredDistanceTo(Vec3d.ofCenter(pos));
            })).orElse(null);
            if (this.currentBreakTarget != null) {
               mc.interactionManager.attackBlock(this.currentBreakTarget, Direction.UP);
               mc.interactionManager.breakBlock(this.currentBreakTarget);
               mc.player.swingHand(Hand.MAIN_HAND);
            }
         }

      } else {
         this.currentBreakTarget = null;
      }
   }

   public long roundBalance(long balance) {
      if (balance <= 0L) {
         return 0L;
      } else {
         long rounded = balance / 1000L;
         return rounded * 1000L;
      }
   }

   public boolean isInRange(BlockPos pos) {
      return mc.player.squaredDistanceTo(Vec3d.ofCenter(pos)) <= 20.25D;
   }

   public void processAutoPayment() {
      if (mc.player != null && mc.world != null) {
         long currentTime = System.currentTimeMillis();
         if (!this.isPayingMode) {
            if (this.payTimer.hasReached(910000L)) {
               mc.player.sendChatMessage("/bal");
               this.balCheckTime = currentTime;
               this.isPayingMode = true;
               this.payCheckDeadline = currentTime + 5000L;
            }

         } else {
            if (currentTime >= this.payCheckDeadline && this.lastBalance > 0L && this.lastPayTime >= this.balCheckTime) {
               long amount = this.roundBalance(this.lastBalance);
               if (amount > 0L) {
                  String nick = this.nickSetting.getValue();
                  mc.player.sendChatMessage("/pay " + nick + " " + amount);
               }

               this.isPayingMode = false;
               this.payTimer.reset();
            }

         }
      }
   }

   public void onEnable() {
      super.onEnable();
      this.stateTimer.reset();
      this.currentState = AutoLes.State.IDLE;
      this.isNavigating = false;
      this.isReturningToNpc = false;
      this.savedBlockPos = null;
      this.currentBreakTarget = null;
      this.calculatedGoalPos = null;
      this.attackCount = 0;
      this.lastAttackTime = 0L;
      this.payTimer.reset();
      this.isPayingMode = false;
      this.payCheckDeadline = 0L;
      this.balCheckTime = 0L;
      this.lastPayTime = 0L;
      this.lastBalance = -1L;

      try {
         this.savedAllowBreak = (Boolean) BaritoneAPI.getSettings().allowBreak.value;
         BaritoneAPI.getSettings().allowBreak.value = Boolean.valueOf(false);
         this.savedRenderPath = (Boolean) BaritoneAPI.getSettings().renderPath.value;
         BaritoneAPI.getSettings().renderPath.value = Boolean.valueOf(false);
      } catch (Exception ignored) {
      }

      this.cancelBaritone();
   }

   public void handleMotionEvent(EventMotion motionEvent) {
      float[] rotations = this.calculateRotations(attackNpcPos);
      motionEvent.setYaw(rotations[0]);
      motionEvent.setPitch(rotations[1]);
      mc.player.headYaw = rotations[0];
      mc.player.prevPitch = rotations[1];
   }

   public float[] calculateRotations(Vec3d target) {
      Vec3d eyePos = mc.player.getCameraPosVec(1.0F);
      double dx = target.x - eyePos.x;
      double dy = target.y - eyePos.y;
      double dz = target.z - eyePos.z;
      double horizontalDist = Math.hypot(dx, dz);
      float yaw = (float) Math.toDegrees(Math.atan2(dz, dx)) - 90.0F;
      float pitch = (float) (-Math.toDegrees(Math.atan2(dy, horizontalDist)));
      return new float[]{MathHelper.wrapDegrees(yaw), MathHelper.clamp(pitch, -90.0F, 90.0F)};
   }

   public long parseBalance(String text) {
      String digits = text.replaceAll("[^0-9]", "");
      if (digits.isEmpty()) {
         return -1L;
      } else {
         try {
            long value = Long.parseLong(digits);
            if (digits.length() > 2) {
               value /= 100L;
            }

            return value;
         } catch (NumberFormatException e) {
            return -1L;
         }
      }
   }

   public AutoLes() {
      this.currentState = AutoLes.State.IDLE;
      this.setLocalizedDesc("Automatically breaks glitched wood", "Automatycznie niszczy zbugowane drewno", "Автоматично ламає багнуте дерево");
      this.addSettings(new Setting[]{this.forMoneySetting, this.autoPaySetting, this.nickSetting});
   }

   public void startFarmCycle() {
      if (mc.player != null) {
         this.savedBlockPos = mc.player.getBlockPos().toImmutable();
         this.isNavigating = true;
         this.currentState = AutoLes.State.NAVIGATING_TO_NPC;
         this.stateTimer.reset();

         try {
            double dx = woodNpcPos.x - mc.player.getX();
            double dz = woodNpcPos.z - mc.player.getZ();
            double dist = Math.hypot(dx, dz);
            Vec3d targetPos = woodNpcPos;
            if (dist > 0.1D) {
               double normX = dx / dist;
               double normZ = dz / dist;
               targetPos = woodNpcPos.add(normX, 0.0D, normZ);
            }

            this.calculatedGoalPos = targetPos;
            BlockPos goalBlock = new BlockPos(targetPos.x, targetPos.y - 1.0D, targetPos.z);
            BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(goalBlock));
         } catch (Exception e) {
            e.printStackTrace();
            this.resetToIdle();
         }
      }
   }

   public boolean isNearPosition(Vec3d pos, double range) {
      return mc.player.squaredDistanceTo(pos) <= range * range;
   }

   public void navigateToSavedPos() {
      if (this.savedBlockPos == null) {
         this.resetToIdle();
      } else {
         try {
            BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(this.savedBlockPos));
         } catch (Exception e) {
            e.printStackTrace();
            this.resetToIdle();
         }
      }
   }

   public void onDisable() {
      super.onDisable();
      this.isPayingMode = false;

      try {
         if (this.savedAllowBreak != null) {
            BaritoneAPI.getSettings().allowBreak.value = this.savedAllowBreak;
            this.savedAllowBreak = null;
         }

         if (this.savedRenderPath != null) {
            BaritoneAPI.getSettings().renderPath.value = this.savedRenderPath;
            this.savedRenderPath = null;
         }
      } catch (Exception ignored) {
      }

      this.cancelBaritone();
   }

   public void cancelBaritone() {
      try {
         BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything();
      } catch (Throwable ignored) {
      }
   }

   private enum State {
      ATTACKING_NPC,
      NAVIGATING_TO_NPC,
      NAVIGATING_TO_WOOD,
      IDLE;
   }
}
 
вот тебе код с нуклеара, портни себе ( ну или попроси чат гпт )


Код:
Expand Collapse Copy
package nuclear.module.impl.player;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import mods.baritone.api.BaritoneAPI;
import mods.baritone.api.pathing.goals.GoalBlock;
import nuclear.control.events.Event;
import nuclear.control.events.impl.player.EventMotion;
import nuclear.control.events.impl.player.EventUpdate;
import nuclear.module.api.Annotation;

@Annotation(
   name = "AutoLes",
   type = TypeList.Player,
   desc = "Автоматически ломает багнутое дерево"
)
public class AutoLes extends Module implements MinecraftAccessor {
   public int attackCount = 0;
   public TimerUtil payTimer = new TimerUtil();
   public static double staticDouble1;
   public TimerUtil stateTimer = new TimerUtil();
   public long payCheckDeadline = 0L;
   public Boolean savedAllowBreak = null;
   public long attackStartTime = 0L;
   public BlockPos savedBlockPos = null;
   public static long staticLong1;
   public static Vec3d attackNpcPos = new Vec3d(-40.5D, 49.0D, 156.5D);
   public boolean isPayingMode = false;
   public Boolean savedRenderPath = null;
   public long balCheckTime = 0L;
   public Vec3d calculatedGoalPos = null;
   public static Vec3d woodNpcPos = new Vec3d(-41.5D, 48.0D, 156.5D);
   public AutoLes.State currentState;
   public BlockPos currentBreakTarget;
   public boolean isReturningToNpc = false;
   public StringSetting nickSetting = (new StringSetting("Ник", "")).setLocalizedName("Nick", "Nick", "Нік").setVisible(() -> {
      return this.autoPaySetting.get();
   });
   public static long staticLong2;
   public long lastAttackTime = 0L;
   public boolean isNavigating = false;
   public BooleanSetting autoPaySetting = (new BooleanSetting("Авто перевод", false)).setLocalizedName("Auto pay", "Auto pay", "Авто pay");
   public static long staticLong3;
   public long lastPayTime = 0L;
   public BooleanSetting forMoneySetting = (new BooleanSetting("Авто зарплата", true)).setLocalizedName("For money", "Za pieniądze", "На гроші");
   public long lastBalance = -1L;
   public static double staticDouble2;

   public Entity findNearestEntity(Vec3d pos, double range) {
      Entity nearest = null;
      double rangeSq = range * range;
      Iterator iterator = mc.world.getEntities().iterator();

      while (true) {
         Entity entity;
         double distSq;
         do {
            do {
               do {
                  if (!iterator.hasNext()) {
                     return nearest;
                  }

                  entity = (Entity) iterator.next();
               } while (entity == mc.player);

               distSq = entity.squaredDistanceTo(pos.x, pos.y, pos.z);
            } while (!(distSq <= rangeSq));
         } while (nearest != null && !(distSq < nearest.squaredDistanceTo(pos.x, pos.y, pos.z)));

         nearest = entity;
      }
   }

   public void processStateMachine() {
      if (mc.player != null && mc.world != null) {
         if (this.currentState == AutoLes.State.IDLE) {
            if (this.stateTimer.hasReached(900000L)) {
               this.startFarmCycle();
            }

         } else {
            switch (this.currentState) {
            case NAVIGATING_TO_NPC:
               if (this.isNearPosition(attackNpcPos, 3.0D)) {
                  this.currentState = AutoLes.State.ATTACKING_NPC;
                  this.attackStartTime = System.currentTimeMillis();
                  this.attackCount = 0;
                  this.lastAttackTime = 0L;
                  this.cancelBaritone();
               }
               break;
            case ATTACKING_NPC:
               long currentTime = System.currentTimeMillis();
               if (this.attackCount < 5 && currentTime - this.lastAttackTime >= 400L) {
                  this.attackNearbyEntity();
                  ++this.attackCount;
                  this.lastAttackTime = currentTime;
               }

               if (currentTime - this.attackStartTime > 3200L || this.attackCount >= 5) {
                  this.currentState = AutoLes.State.NAVIGATING_TO_WOOD;
                  this.isReturningToNpc = true;
                  this.navigateToSavedPos();
               }
               break;
            case NAVIGATING_TO_WOOD:
               if (this.savedBlockPos != null && this.isWithinRange(this.savedBlockPos, 1.6D)) {
                  this.cancelBaritone();
                  this.currentState = AutoLes.State.IDLE;
                  this.isNavigating = false;
                  this.isReturningToNpc = false;
                  this.savedBlockPos = null;
                  this.stateTimer.reset();
               }
            }

         }
      }
   }

   public boolean isLogBlock(BlockPos pos) {
      BlockState state = mc.world.getBlockState(pos);
      return state.isIn(BlockTags.LOGS);
   }

   public boolean isWithinRange(BlockPos pos, double range) {
      return mc.player.squaredDistanceTo((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) <= range * range;
   }

   public void attackNearbyEntity() {
      Entity entity = this.findNearestEntity(attackNpcPos, 3.5D);
      if (entity != null) {
         mc.interactionManager.attackEntity(mc.player, entity, Hand.MAIN_HAND);
         mc.player.swingHand(Hand.MAIN_HAND);
      }
   }

   public void resetToIdle() {
      this.cancelBaritone();
      this.currentState = AutoLes.State.IDLE;
      this.isNavigating = false;
      this.isReturningToNpc = false;
      this.savedBlockPos = null;
      this.stateTimer.reset();
   }

   public boolean onEvent(Event event) {
      if (event instanceof EventPostUpdate) {
         if (this.forMoneySetting.get()) {
            this.processStateMachine();
         }

         if (!this.isNavigating) {
            this.processBreaking();
         }

         if (this.autoPaySetting.get()) {
            this.processAutoPayment();
         }
      } else if (event instanceof EventMotion) {
         EventMotion motionEvent = (EventMotion) event;
         if (this.forMoneySetting.get() && this.currentState == AutoLes.State.ATTACKING_NPC) {
            this.handleMotionEvent(motionEvent);
         }
      } else if (event instanceof EventPacket) {
         EventPacket packetEvent = (EventPacket) event;
         if (packetEvent.isReceive()) {
            Packet packet = packetEvent.getPacket();
            if (packet instanceof SPacketChat) {
               SPacketChat chatPacket = (SPacketChat) packet;
               this.handleChatMessage(chatPacket);
            }
         }
      }

      return false;
   }

   public void handleChatMessage(SPacketChat chatPacket) {
      if (this.autoPaySetting.get()) {
         ChatType type = chatPacket.getType();
         if (type == ChatType.SYSTEM || type == ChatType.GAME_INFO || type == ChatType.CHAT) {
            Text message = chatPacket.getMessage();
            if (message != null) {
               String text = message.getString();
               String stripped = ChatFormatting.stripFormatting(text);
               if (stripped != null) {
                  if (stripped.contains("Баланс")) {
                     long balance = this.parseBalance(stripped);
                     if (balance > 0L) {
                        this.lastBalance = balance;
                        this.lastPayTime = System.currentTimeMillis();
                     }
                  }
               }
            }
         }
      }
   }

   public void processBreaking() {
      if (mc.player != null && mc.world != null) {
         if (this.currentBreakTarget != null) {
            if (this.isInRange(this.currentBreakTarget)) {
               BlockState state = mc.world.getBlockState(this.currentBreakTarget);
               if (state.isAir()) {
                  this.currentBreakTarget = null;
               } else {
                  mc.interactionManager.attackBlock(this.currentBreakTarget, Direction.UP);
                  mc.interactionManager.breakBlock(this.currentBreakTarget);
                  mc.player.swingHand(Hand.MAIN_HAND);
               }
            } else {
               this.currentBreakTarget = null;
            }
         }

         if (this.currentBreakTarget == null) {
            BlockPos playerPos = mc.player.getBlockPos();
            BlockPos searchMin = playerPos.add(-5, -5, -5);
            BlockPos searchMax = playerPos.add(5, 5, 5);
            ArrayList blockPositions = BlockHelper.INSTANCE.getBlockPositions(searchMin, searchMax);
            this.currentBreakTarget = (BlockPos) blockPositions.stream().filter(this::isLogBlock).filter(this::isInRange).min(Comparator.comparing((pos) -> {
               return mc.player.squaredDistanceTo(Vec3d.ofCenter(pos));
            })).orElse(null);
            if (this.currentBreakTarget != null) {
               mc.interactionManager.attackBlock(this.currentBreakTarget, Direction.UP);
               mc.interactionManager.breakBlock(this.currentBreakTarget);
               mc.player.swingHand(Hand.MAIN_HAND);
            }
         }

      } else {
         this.currentBreakTarget = null;
      }
   }

   public long roundBalance(long balance) {
      if (balance <= 0L) {
         return 0L;
      } else {
         long rounded = balance / 1000L;
         return rounded * 1000L;
      }
   }

   public boolean isInRange(BlockPos pos) {
      return mc.player.squaredDistanceTo(Vec3d.ofCenter(pos)) <= 20.25D;
   }

   public void processAutoPayment() {
      if (mc.player != null && mc.world != null) {
         long currentTime = System.currentTimeMillis();
         if (!this.isPayingMode) {
            if (this.payTimer.hasReached(910000L)) {
               mc.player.sendChatMessage("/bal");
               this.balCheckTime = currentTime;
               this.isPayingMode = true;
               this.payCheckDeadline = currentTime + 5000L;
            }

         } else {
            if (currentTime >= this.payCheckDeadline && this.lastBalance > 0L && this.lastPayTime >= this.balCheckTime) {
               long amount = this.roundBalance(this.lastBalance);
               if (amount > 0L) {
                  String nick = this.nickSetting.getValue();
                  mc.player.sendChatMessage("/pay " + nick + " " + amount);
               }

               this.isPayingMode = false;
               this.payTimer.reset();
            }

         }
      }
   }

   public void onEnable() {
      super.onEnable();
      this.stateTimer.reset();
      this.currentState = AutoLes.State.IDLE;
      this.isNavigating = false;
      this.isReturningToNpc = false;
      this.savedBlockPos = null;
      this.currentBreakTarget = null;
      this.calculatedGoalPos = null;
      this.attackCount = 0;
      this.lastAttackTime = 0L;
      this.payTimer.reset();
      this.isPayingMode = false;
      this.payCheckDeadline = 0L;
      this.balCheckTime = 0L;
      this.lastPayTime = 0L;
      this.lastBalance = -1L;

      try {
         this.savedAllowBreak = (Boolean) BaritoneAPI.getSettings().allowBreak.value;
         BaritoneAPI.getSettings().allowBreak.value = Boolean.valueOf(false);
         this.savedRenderPath = (Boolean) BaritoneAPI.getSettings().renderPath.value;
         BaritoneAPI.getSettings().renderPath.value = Boolean.valueOf(false);
      } catch (Exception ignored) {
      }

      this.cancelBaritone();
   }

   public void handleMotionEvent(EventMotion motionEvent) {
      float[] rotations = this.calculateRotations(attackNpcPos);
      motionEvent.setYaw(rotations[0]);
      motionEvent.setPitch(rotations[1]);
      mc.player.headYaw = rotations[0];
      mc.player.prevPitch = rotations[1];
   }

   public float[] calculateRotations(Vec3d target) {
      Vec3d eyePos = mc.player.getCameraPosVec(1.0F);
      double dx = target.x - eyePos.x;
      double dy = target.y - eyePos.y;
      double dz = target.z - eyePos.z;
      double horizontalDist = Math.hypot(dx, dz);
      float yaw = (float) Math.toDegrees(Math.atan2(dz, dx)) - 90.0F;
      float pitch = (float) (-Math.toDegrees(Math.atan2(dy, horizontalDist)));
      return new float[]{MathHelper.wrapDegrees(yaw), MathHelper.clamp(pitch, -90.0F, 90.0F)};
   }

   public long parseBalance(String text) {
      String digits = text.replaceAll("[^0-9]", "");
      if (digits.isEmpty()) {
         return -1L;
      } else {
         try {
            long value = Long.parseLong(digits);
            if (digits.length() > 2) {
               value /= 100L;
            }

            return value;
         } catch (NumberFormatException e) {
            return -1L;
         }
      }
   }

   public AutoLes() {
      this.currentState = AutoLes.State.IDLE;
      this.setLocalizedDesc("Automatically breaks glitched wood", "Automatycznie niszczy zbugowane drewno", "Автоматично ламає багнуте дерево");
      this.addSettings(new Setting[]{this.forMoneySetting, this.autoPaySetting, this.nickSetting});
   }

   public void startFarmCycle() {
      if (mc.player != null) {
         this.savedBlockPos = mc.player.getBlockPos().toImmutable();
         this.isNavigating = true;
         this.currentState = AutoLes.State.NAVIGATING_TO_NPC;
         this.stateTimer.reset();

         try {
            double dx = woodNpcPos.x - mc.player.getX();
            double dz = woodNpcPos.z - mc.player.getZ();
            double dist = Math.hypot(dx, dz);
            Vec3d targetPos = woodNpcPos;
            if (dist > 0.1D) {
               double normX = dx / dist;
               double normZ = dz / dist;
               targetPos = woodNpcPos.add(normX, 0.0D, normZ);
            }

            this.calculatedGoalPos = targetPos;
            BlockPos goalBlock = new BlockPos(targetPos.x, targetPos.y - 1.0D, targetPos.z);
            BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(goalBlock));
         } catch (Exception e) {
            e.printStackTrace();
            this.resetToIdle();
         }
      }
   }

   public boolean isNearPosition(Vec3d pos, double range) {
      return mc.player.squaredDistanceTo(pos) <= range * range;
   }

   public void navigateToSavedPos() {
      if (this.savedBlockPos == null) {
         this.resetToIdle();
      } else {
         try {
            BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(this.savedBlockPos));
         } catch (Exception e) {
            e.printStackTrace();
            this.resetToIdle();
         }
      }
   }

   public void onDisable() {
      super.onDisable();
      this.isPayingMode = false;

      try {
         if (this.savedAllowBreak != null) {
            BaritoneAPI.getSettings().allowBreak.value = this.savedAllowBreak;
            this.savedAllowBreak = null;
         }

         if (this.savedRenderPath != null) {
            BaritoneAPI.getSettings().renderPath.value = this.savedRenderPath;
            this.savedRenderPath = null;
         }
      } catch (Exception ignored) {
      }

      this.cancelBaritone();
   }

   public void cancelBaritone() {
      try {
         BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything();
      } catch (Throwable ignored) {
      }
   }

   private enum State {
      ATTACKING_NPC,
      NAVIGATING_TO_NPC,
      NAVIGATING_TO_WOOD,
      IDLE;
   }
}
Спасибо попробую
 
Назад
Сверху Снизу