SightedClient

class SightedClient[F[_], ServerBoundPackets <: Tuple, ClientBoundPackets <: Tuple, WorldView](val writeTransport: ProtocolBasedWriteTransport[F, ServerBoundPackets], readTransport: ProtocolBasedReadTransport[F, ClientBoundPackets], val identity: ClientIdentity, viewRef: Ref[F, WorldView], abstraction: PacketAbstraction[Union[ClientBoundPackets], WorldView, F[List[WritablePacketIn[ServerBoundPackets]]]])(implicit evidence$1: Concurrent[F])

The class of Minecraft clients that associate incoming packets to updates of state of the connected world. The name "Sighted" is from an analogy between the animals receiving light rays to their eyes and Minecraft clients receiving client-bound packets - they both shape the assumptions (view) about the external environment using those incoming data.

These clients make a distinction between hidden "internal" packets and "visible" packets within ClientBoundPackets. Internal packets are packets that are abstracted away by abstraction, and cannot be observed by users of this class; they contribute to the automatic update of the clients' view of the world. Visible packets are those that are not filtered by the abstraction.

Value Params
abstraction

the object abstracting packets from writeTransport.

identity

the identity of this client

viewRef

reference to a WorldView that this client keeps updating

writeTransport

INTERNAL, the transport that this client uses. Users should use nextPacketOrViewUpdate or writePacket wherever possible.

Companion
object
class Object
trait Matchable
class Any

Type members

Classlikes

Result of an iteration of read-loop, provided by the beginReadLoop resource.

Result of an iteration of read-loop, provided by the beginReadLoop resource.

Value members

Concrete methods

def readLoopAndDiscard: Resource[F, Unit]

A resource that manages the concurrent execution of readLoopUntilDefined that is executed endlessly until the resource gets out of scope.

A resource that manages the concurrent execution of readLoopUntilDefined that is executed endlessly until the resource gets out of scope.

def readLoopUntilDefined[A](f: ReadLoopStepResult => F[Option[A]]): F[A]

An action that repeatedly runs f using a result of reading a packet until we get a defined value of A.

An action that repeatedly runs f using a result of reading a packet until we get a defined value of A.

In testing context, this method can be used in "expecting" a certain sequence of world states, for example,

  • by checking the world time every time a result comes in (Minecraft protocol guarantees that some packet arrives after some time), or
  • by throwing (using MonadThrow[F].raiseError) when certain condition is met
def writePacket[P : IndexKnownIn[ServerBoundPackets]](packet: P): F[Unit]

Write a packet to the underlying transport.

Write a packet to the underlying transport.

Concrete fields

val worldView: F[WorldView]

Read the current view of the world as seen from this client.

Read the current view of the world as seen from this client.

val writeTransport: ProtocolBasedWriteTransport[F, ServerBoundPackets]