Package com.petrolpark.core.team
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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceITeamobjects have one instance for each team, and cannot be serialized.static final record -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.network.chat.ComponentgetName()The name of this Team, without necessarily referring to anymembers.TheITeam.Providerthat provides this exact Team instance.default net.minecraft.network.chat.ComponentgetRenderedMemberList(int maxTextWidth) Get thenamesof somemembersof this Team, formatted nicely.booleanisAdmin(net.minecraft.world.entity.player.Player player) What this means will be different for every system that uses Teams.booleanisMember(net.minecraft.world.entity.player.Player player) Whether the given Player is in this Team, meaning they have access client-side to the Team'sData Components, and have any non-adminabilities.default booleanisNone()Whether this Team can never haveany membersorData Components.intThe number ofmembersof this Team.voidrenderIcon(net.minecraft.client.gui.GuiGraphics graphics) Render an icon for thisITeam.default voidsendToAllMembers(net.createmod.catnip.net.base.ClientboundPacketPayload packet) Broadcast a packet to everymemberof this Team.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> Everymemberof this Team, with no guarantee of order.The uniqueusernameof everymemberof this Team, in no particular order.default Stream<net.minecraft.server.level.ServerPlayer> Everymemberof this Team as aServerPlayerobject, with no guarantee of order.Methods inherited from interface net.minecraft.core.component.DataComponentHolder
get, getComponents, getOrDefault, hasMethods inherited from interface net.neoforged.neoforge.common.extensions.IDataComponentHolderExtension
addToTooltip, addToTooltip, get, getOrDefault, hasMethods inherited from interface net.neoforged.neoforge.common.MutableDataComponentHolder
applyComponents, applyComponents, copyFrom, copyFrom, remove, remove, set, set, update, update, update, update
-
Method Details
-
streamAll
Get every Team of which the given Player is a member. Add customITeamimplementations withGatherTeamProvidersEvent.- Parameters:
player-
-
getProvider
ITeam.Provider getProvider()TheITeam.Providerthat provides this exact Team instance. -
isNone
default boolean isNone()Whether this Team can never haveany membersorData 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'sData Components, and have any non-adminabilities.- Parameters:
player-
-
memberCount
int memberCount()The number ofmembersof this Team.- Returns:
- Positive integer
almost alwaysgreater than0.
-
streamMemberUsernames
The uniqueusernameof everymemberof this Team, in no particular order. ForScoreboardTeams in particular, this method is faster thanstreamMembers()and should be used in preference to calling that method and then getting the usernames. -
streamMembers
Stream<net.minecraft.world.entity.player.Player> streamMembers()Everymemberof this Team, with no guarantee of order. It is faster to usestreamMemberUsernames()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
Everymemberof this Team as aServerPlayerobject, with no guarantee of order. It is faster to usestreamMemberUsernames()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 aShop, for example. It has nothing to do with operator permissions. If called, it is assumed thatisMember(Player)has already passed.- Parameters:
player-
-
getName
net.minecraft.network.chat.Component getName()The name of this Team, without necessarily referring to anymembers.- See Also:
-
renderIcon
void renderIcon(net.minecraft.client.gui.GuiGraphics graphics) Render an icon for thisITeam. 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 thenamesof somemembersof 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 everymemberof this Team.- Parameters:
packet-
-