Interface ISpellVar<T>
- Type Parameters:
T- the type of value this spell variable holds
- All Known Subinterfaces:
IStoredSpellVar<T>
- All Known Implementing Classes:
ISpellVar.SpellVar,IStoredSpellVar.StoredSpellVar
public interface ISpellVar<T>
Interface for spell variables that can be stored and synchronized between client and server.
Spell variables are used to store data associated with spells or players, with support for persistence across dimension changes and respawns, as well as network synchronization.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classDefault implementation ofISpellVarthat provides basic functionality. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanDetermines whether this spell variable can be purged for the given player.booleanisPersistent(boolean respawn) Determines whether this spell variable should persist.booleanisSynced()Checks whether this spell variable should be synchronized between client and server.read(net.minecraft.network.FriendlyByteBuf buf) Reads the value from a network buffer.Updates the value of this spell variable for the given player.voidWrites the value to a network buffer for synchronization.
-
Method Details
-
update
Updates the value of this spell variable for the given player.This method is typically called each tick to update time-dependent values.
- Parameters:
player- the player whose spell variable is being updatedvalue- the current value- Returns:
- the updated value
-
isPersistent
boolean isPersistent(boolean respawn) Determines whether this spell variable should persist.- Parameters:
respawn- if true, checks persistence across player respawns; if false, checks persistence across dimension changes- Returns:
- true if the variable should persist, false otherwise
-
isSynced
boolean isSynced()Checks whether this spell variable should be synchronized between client and server.- Returns:
- true if the variable should be synced, false otherwise
-
write
Writes the value to a network buffer for synchronization.- Parameters:
buf- the buffer to write tovalue- the value to write
-
read
Reads the value from a network buffer.- Parameters:
buf- the buffer to read from- Returns:
- the value read from the buffer, or null if no value is present
-
canPurge
Determines whether this spell variable can be purged for the given player.By default, spell variables cannot be purged.
- Parameters:
player- the player whose spell variable is being checkedvalue- the current value- Returns:
- true if the variable can be purged, false otherwise
-