Interface ITeam

All Superinterfaces:
net.minecraft.core.component.DataComponentHolder, net.neoforged.neoforge.common.extensions.IDataComponentHolderExtension, net.neoforged.neoforge.common.MutableDataComponentHolder
All Known Implementing Classes:
AbstractTeam, NoTeam, ScoreboardTeam, SinglePlayerTeam

@ParametersAreNonnullByDefault public interface ITeam extends net.neoforged.neoforge.common.MutableDataComponentHolder
A collection of Players acting as one entity. Teams are MutableDataComponentHolders, but only members of a Team are guaranteed to have access to those Components on the client side.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    ITeam objects have one instance for each team, and cannot be serialized.
    static final record 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.network.chat.Component
    The name of this Team, without necessarily referring to any members.
    The ITeam.Provider that provides this exact Team instance.
    default net.minecraft.network.chat.Component
    getRenderedMemberList(int maxTextWidth)
    Get the names of some members of this Team, formatted nicely.
    boolean
    isAdmin(net.minecraft.world.entity.player.Player player)
    What this means will be different for every system that uses Teams.
    boolean
    isMember(net.minecraft.world.entity.player.Player player)
    Whether the given Player is in this Team, meaning they have access client-side to the Team's Data Components, and have any non-admin abilities.
    default boolean
    Whether this Team can never have any members or Data Components.
    int
    The number of members of this Team.
    void
    renderIcon(net.minecraft.client.gui.GuiGraphics graphics)
    Render an icon for this ITeam.
    default void
    sendToAllMembers(net.createmod.catnip.net.base.ClientboundPacketPayload packet)
    Broadcast a packet to every member of this Team.
    static Stream<ITeam>
    streamAll(net.minecraft.world.entity.player.Player player)
    Get every Team of which the given Player is a member.
    Stream<net.minecraft.world.entity.player.Player>
    Every member of this Team, with no guarantee of order.
    The unique username of every member of this Team, in no particular order.
    default Stream<net.minecraft.server.level.ServerPlayer>
    Every member of this Team as a ServerPlayer object, with no guarantee of order.

    Methods inherited from interface net.minecraft.core.component.DataComponentHolder

    get, getComponents, getOrDefault, has

    Methods inherited from interface net.neoforged.neoforge.common.extensions.IDataComponentHolderExtension

    addToTooltip, addToTooltip, get, getOrDefault, has

    Methods inherited from interface net.neoforged.neoforge.common.MutableDataComponentHolder

    applyComponents, applyComponents, copyFrom, copyFrom, remove, remove, set, set, update, update, update, update
  • Method Details

    • streamAll

      static Stream<ITeam> streamAll(net.minecraft.world.entity.player.Player player)
      Get every Team of which the given Player is a member. Add custom ITeam implementations with GatherTeamProvidersEvent.
      Parameters:
      player -
    • getProvider

      ITeam.Provider getProvider()
      The ITeam.Provider that provides this exact Team instance.
    • isNone

      default boolean isNone()
      Whether this Team can never have any members or Data Components.
      See Also:
    • isMember

      boolean isMember(net.minecraft.world.entity.player.Player player)
      Whether the given Player is in this Team, meaning they have access client-side to the Team's Data Components, and have any non-admin abilities.
      Parameters:
      player -
    • memberCount

      int memberCount()
      The number of members of this Team.
      Returns:
      Positive integer almost always greater than 0.
    • streamMemberUsernames

      Stream<String> streamMemberUsernames()
      The unique username of every member of this Team, in no particular order. For ScoreboardTeams in particular, this method is faster than streamMembers() and should be used in preference to calling that method and then getting the usernames.
    • streamMembers

      Stream<net.minecraft.world.entity.player.Player> streamMembers()
      Every member of this Team, with no guarantee of order. It is faster to use streamMemberUsernames() unless having the Player itself is vital. On the client side, that is the only way to know the members of the Team.
      See Also:
    • streamServerMembers

      default Stream<net.minecraft.server.level.ServerPlayer> streamServerMembers()
      Every member of this Team as a ServerPlayer object, with no guarantee of order. It is faster to use streamMemberUsernames() unless having the Player itself is vital.
      See Also:
    • isAdmin

      boolean isAdmin(net.minecraft.world.entity.player.Player player)
      What this means will be different for every system that uses Teams. It could mean the ability to change the name of a Shop, for example. It has nothing to do with operator permissions. If called, it is assumed that isMember(Player) has already passed.
      Parameters:
      player -
    • getName

      net.minecraft.network.chat.Component getName()
      The name of this Team, without necessarily referring to any members.
      See Also:
    • renderIcon

      void renderIcon(net.minecraft.client.gui.GuiGraphics graphics)
      Render an icon for this ITeam. The icon should occupy (0, 0) -> (16, 16) of the given PoseStack.
      Parameters:
      graphics -
    • getRenderedMemberList

      default net.minecraft.network.chat.Component getRenderedMemberList(int maxTextWidth)
      Get the names of some members of this Team, formatted nicely. This does not need to list every member exhaustively. This list in no particular order, but should be the same every time to prevent weird rendering.
      Parameters:
      maxTextWidth -
      See Also:
    • sendToAllMembers

      default void sendToAllMembers(net.createmod.catnip.net.base.ClientboundPacketPayload packet)
      Broadcast a packet to every member of this Team.
      Parameters:
      packet -