Contents
Class PlayerVoiceFrame
java.lang.Object
com.hypixel.hytale.server.core.modules.voice.PlayerVoiceFrame
Mutable view of one inbound player voice frame, passed to a
PlayerVoiceInterceptor. Valid only for
the duration of PlayerVoiceInterceptor.intercept(PlayerVoiceFrame). Do not retain it past that call.
By default a living speaker's frame is delivered to nearby same-world listeners and a dead speaker's
frame is delivered to no one. An interceptor changes that with one of the audience methods. When several
interceptors act on the same frame the last audience call wins, so a frame drop() left for no one
can still be re-routed by a later interceptor with deliverByProximity() or deliverTo(Collection).
-
Method Summary
Modifier and TypeMethodDescriptionvoidDelivers this frame to all nearby same-world listeners, clearing any proximity filters a prior interceptor set.voiddeliverTo(Collection<UUID> listeners) Delivers this frame to exactlylisteners(any world, no distance falloff), playing at each listener rather than spatialized.voiddrop()Delivers this frame to no one.intThe speaker's entity network id, which drives the client's overhead speaking indicator.voidexcludeListener(UUID listener) Excludes a listener from proximity delivery, accumulating across calls.byte[]opus()The Opus frame bytes.org.joml.Vector3dcposition()The speaker's current ear position, ornullwhen not yet cached (seeworldId).voidrestrictProximityTo(Set<UUID> allowed) Restricts proximity delivery to the intersection of nearby listeners andallowed, switching delivery to proximity and keeping any priorexcludeListener(UUID).shortThe client-stamped sequence number for this frame.voidsetOpus(byte[] frame) Replaces the Opus frame bytes (for example a censor beep or a baked clip).voidsetPosition(org.joml.Vector3dc position) Overrides the position used for proximity distance and the relayed (quantized) position.voidsetUnderwater(boolean underwater) Overrides whether the speaker is treated as underwater for proximity delivery.speaker()The speaking player.booleanWhether the speaker is dead.intThe client-stamped capture timestamp (48kHz sample units) for this frame.booleanWhether the speaker's ears are submerged, applied as the underwater muffle for proximity delivery.worldId()The speaker's world, ornullwhen the position cache is not yet populated (just connected, or mid world transfer).
-
Method Details
-
speaker
The speaking player. Use it for identity and thread-safe lookups only. Do not read ECS, component, or block state from here (this runs off the world thread). -
worldId
The speaker's world, ornullwhen the position cache is not yet populated (just connected, or mid world transfer). -
entityNetworkId
public int entityNetworkId()The speaker's entity network id, which drives the client's overhead speaking indicator. -
sequenceNumber
public short sequenceNumber()The client-stamped sequence number for this frame. -
timestamp
public int timestamp()The client-stamped capture timestamp (48kHz sample units) for this frame. -
speakerDead
public boolean speakerDead()Whether the speaker is dead. A dead speaker's frame defaults to no delivery. Opt it back in withdeliverByProximity()ordeliverTo(Collection). -
position
@Nullable public org.joml.Vector3dc position()The speaker's current ear position, ornullwhen not yet cached (seeworldId). Used for proximity distance and quantized into the relayed position. The returned vector is a read-only view of internal state, so do not cast and mutate it. Override the position withsetPosition(Vector3dc). -
underwater
public boolean underwater()Whether the speaker's ears are submerged, applied as the underwater muffle for proximity delivery. -
opus
@Nonnull public byte[] opus()The Opus frame bytes. Read-only access for taps. Replace them withsetOpus(byte[])and do not mutate the array. -
setPosition
public void setPosition(@Nonnull org.joml.Vector3dc position) Overrides the position used for proximity distance and the relayed (quantized) position.- Parameters:
position- the replacement position, whose coordinates must be finite- Throws:
IllegalArgumentException- if any coordinate is not finite
-
setUnderwater
public void setUnderwater(boolean underwater) Overrides whether the speaker is treated as underwater for proximity delivery. -
setOpus
public void setOpus(@Nonnull byte[] frame) Replaces the Opus frame bytes (for example a censor beep or a baked clip). The server does not encode audio, so the bytes must already be a valid Opus frame: 48kHz mono, 1 to 512 bytes.The array is fanned out to every recipient without copying, so hand off a fresh array and never mutate it afterward, or a recipient's encode could read a half-overwritten frame.
- Parameters:
frame- the replacement Opus frame, 1 to 512 bytes- Throws:
IllegalArgumentException- if the frame is empty or larger than the limit
-
drop
public void drop()Delivers this frame to no one. A later interceptor in the chain can still re-route it withdeliverByProximity()ordeliverTo(Collection). This is the same state a dead speaker's frame starts in. -
deliverByProximity
public void deliverByProximity()Delivers this frame to all nearby same-world listeners, clearing any proximity filters a prior interceptor set. Use it to route a dead speaker's voice that would otherwise be dropped. Narrow it afterward withrestrictProximityTo(Set)orexcludeListener(UUID). -
restrictProximityTo
Restricts proximity delivery to the intersection of nearby listeners andallowed, switching delivery to proximity and keeping any priorexcludeListener(UUID). Membership is tested per nearby listener, so aSetis taken for O(1) lookups. The set is referenced, not copied, so do not mutate it after this call. The server reads it during routing, once the interceptor chain has run. An empty set delivers to no one. Distance falloff and the per-speaker listener cap still apply, after this filter. -
excludeListener
Excludes a listener from proximity delivery, accumulating across calls. This only refines proximity delivery and does not enable it, so on a dropped or dead-speaker frame calldeliverByProximity()first or the exclusion has nothing to act on. -
deliverTo
Delivers this frame to exactlylisteners(any world, no distance falloff), playing at each listener rather than spatialized. The collection is referenced, not copied, so do not mutate it after this call. The server reads it during routing, once the interceptor chain has run. Null elements are skipped. An empty collection delivers to no one.
-