Interface SyncPolicy

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SyncPolicy
Which players receive a Attachment's value. Only players who can see the holder are ever asked: those tracking an entity (plus the entity itself when it's a player), or those with a block entity's chunk loaded.
.sync(SyncPolicy.SELF)                                  // a player's own HUD value
.sync(SyncPolicy.ALL)                                   // everyone who sees the holder, e.g. for rendering
.sync(SyncPolicy.ALL.and((owner, player) -> player.permissions().hasPermission(...)))
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final SyncPolicy
    Everyone who sees the holder, the player it belongs to included.
    static final SyncPolicy
    Never sent; the value lives on the server only.
    static final SyncPolicy
    Only the player the value belongs to.
    static final SyncPolicy
    Players who see the holder, but not the player it belongs to.
  • Method Summary

    Modifier and Type
    Method
    Description
    default SyncPolicy
    and(SyncPolicy other)
     
    default SyncPolicy
    or(SyncPolicy other)
     
    boolean
    shouldSync(Object owner, net.minecraft.server.level.ServerPlayer player)
     
  • Field Details

    • NONE

      static final SyncPolicy NONE
      Never sent; the value lives on the server only.
    • SELF

      static final SyncPolicy SELF
      Only the player the value belongs to. Nobody, for anything but a player.
    • TRACKING

      static final SyncPolicy TRACKING
      Players who see the holder, but not the player it belongs to.
    • ALL

      static final SyncPolicy ALL
      Everyone who sees the holder, the player it belongs to included.
  • Method Details

    • shouldSync

      boolean shouldSync(Object owner, net.minecraft.server.level.ServerPlayer player)
      Parameters:
      owner - the entity or block entity holding the value
      player - a player who can see it
    • and

      default SyncPolicy and(SyncPolicy other)
    • or

      default SyncPolicy or(SyncPolicy other)