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 Summary
Modifier and TypeMethodDescriptionvoidAccepts the message, notifying any integrations (such as CC:Tweaked) before taking the message.Links another router to this one.voidMarks that this router can distribute messages through wires.voiddispatch()This method is called on the dispatcher thread, when every audio frame is meant to move at once.doubledistanceTo(Router other) floatintnet.minecraft.world.phys.Vec3net.minecraft.world.phys.Vec3@Nullable FrequencyshortRetrieves the identifier that refers to this router.Class<?> getLink()Gets the effective location of this router.@Nullable net.minecraft.world.entity.EntitygetOwner()@Nullable WorldlyPositionintRetrieves the reference that refers to this router.org.joml.QuaternionfgetWires()voidInserts a message into the buffer, where it will be extracted by the courier.voidbooleanisActive()booleanisValid()voidpush(short[] audio) Pushes audio data into a separate buffer that dynamically splits it into the needed frame size.voidRoutes the given message to all the routers connected to this one.send(byte[] data, float volume) send(short[] data, float volume) send(WorldlyPosition at, byte[] data, float volume) send(WorldlyPosition at, short[] data, float volume) send(WorldlyPosition at, UUID sender, byte[] data, float volume) Builds aMessageand sends it to this router.send(WorldlyPosition at, UUID sender, short[] data, float volume) Builds aMessageand sends it to this router.voidsend(WorldlyPosition at, UUID sender, net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> soundHolder, float volume, float pitch, float offset, long seed) voidsend(WorldlyPosition at, UUID sender, net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> soundHolder, float volume, float pitch, long seed) voidsetAcceptingCriteria(Predicate<Message> criteria) voidsetActive(boolean active) voidsetConnectionOffset(net.minecraft.world.phys.Vec3 connectionOffset) voidvoidsetOwner(net.minecraft.world.entity.Entity owner) voidsetPosition(WorldlyPosition position) voidsetRotation(org.joml.Quaternionf position) voidsetRoutingCriteria(BiPredicate<Message, Router> criteria) voidTakes the message, and pushes it if this router is capable of doing so.tryAddRouter(Router router) Tries to link another router to this one if it doesn't already exist.booleanvalidate()
-
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-livedMessage, 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
-
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
Tries to link another router to this one if it doesn't already exist. -
addRouter
Links another router to this one. -
getPosition
-
getOwner
@Nullable @Nullable net.minecraft.world.entity.Entity getOwner() -
getRouter
-
getConnectionPosition
net.minecraft.world.phys.Vec3 getConnectionPosition() -
getPending
-
getRouters
-
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
-
setConnectionOffset
void setConnectionOffset(net.minecraft.world.phys.Vec3 connectionOffset) -
setPosition
-
setRotation
void setRotation(org.joml.Quaternionf position) -
setRoutingCriteria
-
setAcceptingCriteria
-
distanceTo
-
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
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
Accepts the message, notifying any integrations (such as CC:Tweaked) before taking the message.- Parameters:
message- The message to be accepted
-
take
Takes the message, and pushes it if this router is capable of doing so.- Parameters:
message- The message to be taken
-
insert
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
Builds aMessageand 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
-
send
-
send
-
send
Builds aMessageand 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
-
send
-
send
-
validate
boolean validate() -
invalidate
void invalidate()
-