forked from RepoMirrors/baritone
Merge branch 'comms' into tenor
This commit is contained in:
commit
82c64d4d06
|
@ -84,6 +84,10 @@ public class BufferedConnection implements IConnection {
|
||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleAllPendingMessages(IMessageListener listener) throws IOException {
|
||||||
|
receiveMessagesNonBlocking().forEach(msg -> msg.handle(listener));
|
||||||
|
}
|
||||||
|
|
||||||
public static BufferedConnection makeBuffered(IConnection conn) {
|
public static BufferedConnection makeBuffered(IConnection conn) {
|
||||||
if (conn instanceof BufferedConnection) {
|
if (conn instanceof BufferedConnection) {
|
||||||
return (BufferedConnection) conn;
|
return (BufferedConnection) conn;
|
||||||
|
|
|
@ -38,7 +38,6 @@ import cabaletta.comms.upward.MessageStatus;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ControllerBehavior extends Behavior implements IMessageListener {
|
public class ControllerBehavior extends Behavior implements IMessageListener {
|
||||||
|
@ -91,8 +90,7 @@ public class ControllerBehavior extends Behavior implements IMessageListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
List<iMessage> msgs = conn.receiveMessagesNonBlocking();
|
conn.handleAllPendingMessages(this);
|
||||||
msgs.forEach(msg -> msg.handle(this));
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
disconnect();
|
disconnect();
|
||||||
|
|
Loading…
Reference in New Issue