Interface Router

All Known Subinterfaces:
Listener, Receiver, Speaker, Transmitter
All Known Implementing Classes:
RadioListener, RadioReceiver, RadioRouter, RadioSpeaker, RadioTransmitter

public interface Router
Routes Messages to other routers.
  • Method Details

    • getReference

      UUID getReference()
      Retrieves the reference that refers to this router. This is not necessarily unique for each router, but will persist across reloads, and is the same across the server-client boundary.

      Routers that belong to the same purpose will share the same reference, but two unrelated routers will have a different reference. That is, a transceiver can have 4 different routers with the same reference differentiated by their class.
      Returns:
      The reference of this router
    • getIdentifier

      short getIdentifier()
      Retrieves the identifier that refers to this router. Identifiers are unique for every router, but are ephemeral, so they do not persist across reloads. You should not rely on this to be the same or stay the same.

      For a short-lived Message, this is used to keep a record of every router it has visited, to ensure that it cannot loop forever and cause a potential stack overflow or memory leak.
      Returns:
      The identifier of this router
    • getFrequency

      @Nullable @Nullable Frequency getFrequency()
    • isClientSide

      Boolean isClientSide()
    • getLocation

      WorldlyPosition getLocation()
      Gets the effective location of this router. If position is provided, will use that, otherwise will infer the position from the entity owning this router.
    • tryAddRouter

      Router tryAddRouter(Router router)
      Tries to link another router to this one if it doesn't already exist.
    • addRouter

      Router addRouter(Router router)
      Links another router to this one.
    • getPosition

      @Nullable @Nullable WorldlyPosition getPosition()
    • getOwner

      @Nullable @Nullable net.minecraft.world.entity.Entity getOwner()
    • getRouter

      Router getRouter(UUID id)
    • getConnectionPosition

      net.minecraft.world.phys.Vec3 getConnectionPosition()
    • getPending

      Map<UUID,Queue<Message>> getPending()
    • getRouters

      List<Router> getRouters()
    • getWires

      List<Wiring> getWires()
    • isActive

      boolean isActive()
    • isValid

      boolean isValid()
    • getConnectionOffset

      net.minecraft.world.phys.Vec3 getConnectionOffset()
    • getLink

      Class<?> getLink()
    • getActivity

      float getActivity()
    • getActivityTime

      int getActivityTime()
    • getRedstoneMappedActivity

      int getRedstoneMappedActivity()
    • getRotation

      org.joml.Quaternionf getRotation()
    • allowDistribution

      void allowDistribution()
      Marks that this router can distribute messages through wires.
    • setOwner

      void setOwner(net.minecraft.world.entity.Entity owner)
    • setActive

      void setActive(boolean active)
    • setLink

      void setLink(Class<?> link)
    • setConnectionOffset

      void setConnectionOffset(net.minecraft.world.phys.Vec3 connectionOffset)
    • setPosition

      void setPosition(WorldlyPosition position)
    • setRotation

      void setRotation(org.joml.Quaternionf position)
    • setRoutingCriteria

      void setRoutingCriteria(BiPredicate<Message,Router> criteria)
    • setAcceptingCriteria

      void setAcceptingCriteria(Predicate<Message> criteria)
    • distanceTo

      double distanceTo(Router other)
    • dispatch

      void dispatch()
      This method is called on the dispatcher thread, when every audio frame is meant to move at once. It is overridden by the speaker to stream audio data to clients.
      (Note that this is called after the router has received its message)
    • route

      void route(Message message)
      Routes the given message to all the routers connected to this one.
      If the router allows distribution through wires, this will also relay it across those.
      Parameters:
      message - The message to be routed
    • accept

      void accept(Message message)
      Accepts the message, notifying any integrations (such as CC:Tweaked) before taking the message.
      Parameters:
      message - The message to be accepted
    • take

      void take(Message message)
      Takes the message, and pushes it if this router is capable of doing so.
      Parameters:
      message - The message to be taken
    • insert

      void insert(Message message)
      Inserts a message into the buffer, where it will be extracted by the courier. This method does not make any checks and will forcefully insert the message.
      Parameters:
      message - The message to be inserted
    • push

      void push(short[] audio)
      Pushes audio data into a separate buffer that dynamically splits it into the needed frame size. This method may leave leftover samples if the total amount is not a multiple of the frame size.
      Parameters:
      audio - The PCM data to be pushed
    • send

      void send(WorldlyPosition at, UUID sender, net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> soundHolder, float volume, float pitch, long seed)
    • send

      void send(WorldlyPosition at, UUID sender, net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> soundHolder, float volume, float pitch, float offset, long seed)
    • send

      Message send(WorldlyPosition at, UUID sender, short[] data, float volume)
      Builds a Message and sends it to this router.
      Parameters:
      at - The location to send it from.
      sender - The sender of the audio.
      data - The data to send, in raw PCM format.
      volume - The overall volume of the audio.
    • send

      Message send(WorldlyPosition at, short[] data, float volume)
    • send

      Message send(UUID sender, short[] data, float volume)
    • send

      Message send(short[] data, float volume)
    • send

      Message send(WorldlyPosition at, UUID sender, byte[] data, float volume)
      Builds a Message and sends it to this router.
      Parameters:
      at - The location to send it from.
      sender - The sender of the audio.
      data - The data to send, in Opus-encoded format.
      volume - The overall volume of the audio.
    • send

      Message send(WorldlyPosition at, byte[] data, float volume)
    • send

      Message send(UUID sender, byte[] data, float volume)
    • send

      Message send(byte[] data, float volume)
    • validate

      boolean validate()
    • invalidate

      void invalidate()