diff --git a/src/api/java/baritone/api/bot/connect/ConnectionStatus.java b/src/api/java/baritone/api/bot/connect/ConnectionStatus.java
index c0f504cc4..7144be3c4 100644
--- a/src/api/java/baritone/api/bot/connect/ConnectionStatus.java
+++ b/src/api/java/baritone/api/bot/connect/ConnectionStatus.java
@@ -33,6 +33,11 @@ public enum ConnectionStatus {
*/
CANT_RESOLVE_HOST,
+ /**
+ * The port for the detected LAN server could not be resolved.
+ */
+ CANT_RESOLVE_LAN,
+
/**
* The connection initialization failed.
*/
diff --git a/src/api/java/baritone/api/pathing/movement/IMovement.java b/src/api/java/baritone/api/pathing/movement/IMovement.java
index dae8668d5..ed81dd607 100644
--- a/src/api/java/baritone/api/pathing/movement/IMovement.java
+++ b/src/api/java/baritone/api/pathing/movement/IMovement.java
@@ -26,8 +26,16 @@ import net.minecraft.util.math.BlockPos;
*/
public interface IMovement {
+ /**
+ * @return The cost of executing this movement.
+ */
double getCost();
+ /**
+ * Updates this movement, allowing it to set the controls for the player to execute.
+ *
+ * @return The new status for this movement
+ */
MovementStatus update();
/**
@@ -45,10 +53,19 @@ public interface IMovement {
*/
boolean safeToCancel();
+ /**
+ * @return Whether or not the position that this movement represents was loaded in the world when calculated.
+ */
boolean calculatedWhileLoaded();
+ /**
+ * @return The starting position of this movement.
+ */
BetterBlockPos getSrc();
+ /**
+ * @return The destination position of this movement.
+ */
BetterBlockPos getDest();
BlockPos getDirection();
diff --git a/src/launch/java/baritone/launch/mixins/MixinIntegratedServer.java b/src/launch/java/baritone/launch/mixins/MixinIntegratedServer.java
new file mode 100644
index 000000000..3f3e718ab
--- /dev/null
+++ b/src/launch/java/baritone/launch/mixins/MixinIntegratedServer.java
@@ -0,0 +1,36 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.launch.mixins;
+
+import baritone.utils.accessor.IIntegratedServer;
+import net.minecraft.client.multiplayer.ThreadLanServerPing;
+import net.minecraft.server.integrated.IntegratedServer;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+/**
+ * @author Brady
+ * @since 3/4/2020
+ */
+@Mixin(IntegratedServer.class)
+public abstract class MixinIntegratedServer implements IIntegratedServer {
+
+ @Accessor
+ @Override
+ public abstract ThreadLanServerPing getLanServerPing();
+}
diff --git a/src/launch/java/baritone/launch/mixins/MixinThreadLanServerPing.java b/src/launch/java/baritone/launch/mixins/MixinThreadLanServerPing.java
new file mode 100644
index 000000000..e12669106
--- /dev/null
+++ b/src/launch/java/baritone/launch/mixins/MixinThreadLanServerPing.java
@@ -0,0 +1,35 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.launch.mixins;
+
+import baritone.utils.accessor.IThreadLanServerPing;
+import net.minecraft.client.multiplayer.ThreadLanServerPing;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+/**
+ * @author Brady
+ * @since 3/4/2020
+ */
+@Mixin(ThreadLanServerPing.class)
+public abstract class MixinThreadLanServerPing implements IThreadLanServerPing {
+
+ @Accessor
+ @Override
+ public abstract String getAddress();
+}
diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json
index eb31a2e76..bef1f0277 100644
--- a/src/launch/resources/mixins.baritone.json
+++ b/src/launch/resources/mixins.baritone.json
@@ -20,6 +20,7 @@
"MixinEntityPlayerSP",
"MixinEntityRenderer",
"MixinGuiScreen",
+ "MixinIntegratedServer",
"MixinItemStack",
"MixinMinecraft",
"MixinNetHandlerPlayClient",
@@ -29,6 +30,7 @@
"MixinRenderList",
"MixinStateImplementation",
"MixinTabCompleter",
+ "MixinThreadLanServerPing",
"MixinVboRenderList",
"MixinWorldClient"
]
diff --git a/src/main/java/baritone/bot/UserManager.java b/src/main/java/baritone/bot/UserManager.java
index 08d55c604..24ccf5237 100644
--- a/src/main/java/baritone/bot/UserManager.java
+++ b/src/main/java/baritone/bot/UserManager.java
@@ -27,17 +27,16 @@ import baritone.api.event.listener.AbstractGameEventListener;
import baritone.api.utils.Helper;
import baritone.bot.connect.ConnectionResult;
import baritone.bot.handler.BotNetHandlerLoginClient;
+import baritone.utils.accessor.IIntegratedServer;
+import baritone.utils.accessor.IThreadLanServerPing;
import net.minecraft.client.multiplayer.ServerAddress;
import net.minecraft.client.multiplayer.ServerData;
-import net.minecraft.client.multiplayer.ThreadLanServerPing;
import net.minecraft.network.EnumConnectionState;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.handshake.client.C00Handshake;
import net.minecraft.network.login.client.CPacketLoginStart;
-import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.util.Session;
-import java.lang.reflect.Field;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collections;
@@ -93,20 +92,14 @@ public final class UserManager implements IUserManager, Helper {
public final IConnectionResult connect(Session session) {
if (mc.getIntegratedServer() != null && mc.getIntegratedServer().getPublic()) {
try {
- // TODO: (bot-system) Fix compatibility in production
- Field fLanServerPing = IntegratedServer.class.getDeclaredField("lanServerPing");
- fLanServerPing.setAccessible(true);
- ThreadLanServerPing lanServerPing = (ThreadLanServerPing) fLanServerPing.get(mc.getIntegratedServer());
+ IIntegratedServer integratedServer = (IIntegratedServer) mc.getIntegratedServer();
+ IThreadLanServerPing lanServerPing = (IThreadLanServerPing) integratedServer.getLanServerPing();
+ int port = Integer.parseInt(lanServerPing.getAddress());
- Field fAddress = lanServerPing.getClass().getDeclaredField("address");
- fAddress.setAccessible(true);
- int port = Integer.parseInt(fAddress.get(lanServerPing).toString());
-
- // Connect to the server from the parsed server data
return connect0(session, new ServerData("", "localhost:" + port, true));
} catch (Exception e) {
e.printStackTrace();
- return ConnectionResult.failed(CANT_RESOLVE_HOST);
+ return ConnectionResult.failed(CANT_RESOLVE_LAN);
}
}
diff --git a/src/main/java/baritone/utils/accessor/IIntegratedServer.java b/src/main/java/baritone/utils/accessor/IIntegratedServer.java
new file mode 100644
index 000000000..7f88c2b72
--- /dev/null
+++ b/src/main/java/baritone/utils/accessor/IIntegratedServer.java
@@ -0,0 +1,29 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.utils.accessor;
+
+import net.minecraft.client.multiplayer.ThreadLanServerPing;
+
+/**
+ * @author Brady
+ * @since 3/4/2020
+ */
+public interface IIntegratedServer {
+
+ ThreadLanServerPing getLanServerPing();
+}
diff --git a/src/main/java/baritone/utils/accessor/IThreadLanServerPing.java b/src/main/java/baritone/utils/accessor/IThreadLanServerPing.java
new file mode 100644
index 000000000..6211ab08a
--- /dev/null
+++ b/src/main/java/baritone/utils/accessor/IThreadLanServerPing.java
@@ -0,0 +1,27 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.utils.accessor;
+
+/**
+ * @author Brady
+ * @since 3/4/2020
+ */
+public interface IThreadLanServerPing {
+
+ String getAddress();
+}