Class ISpellVar.SpellVar<T>
java.lang.Object
com.binaris.wizardry.api.content.data.ISpellVar.SpellVar<T>
- Type Parameters:
T- the type of value this spell variable holds
- All Implemented Interfaces:
ISpellVar<T>
Default implementation of
ISpellVar that provides basic functionality.
This implementation stores non-persistent, non-synced values with optional tick updates.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.binaris.wizardry.api.content.data.ISpellVar
ISpellVar.SpellVar<T> -
Constructor Summary
ConstructorsConstructorDescriptionSpellVar(Persistence persistence) Creates a new spell variable with the specified persistence settings. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisPersistent(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.withTicker(BiFunction<net.minecraft.world.entity.player.Player, T, T> ticker) Sets a custom ticker function for this spell variable.voidWrites the value to a network buffer for synchronization.
-
Constructor Details
-
SpellVar
Creates a new spell variable with the specified persistence settings.- Parameters:
persistence- the persistence settings for this variable
-
-
Method Details
-
withTicker
public ISpellVar.SpellVar<T> withTicker(BiFunction<net.minecraft.world.entity.player.Player, T, T> ticker) Sets a custom ticker function for this spell variable.The ticker function is called during
update(Player, Object)to compute the new value.- Parameters:
ticker- a function that takes a player and current value, and returns the updated value- Returns:
- this spell variable for method chaining
-
update
Description copied from interface:ISpellVarUpdates the value of this spell variable for the given player.This method is typically called each tick to update time-dependent values.
-
isPersistent
public boolean isPersistent(boolean respawn) Description copied from interface:ISpellVarDetermines whether this spell variable should persist.- Specified by:
isPersistentin interfaceISpellVar<T>- 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
public boolean isSynced()Description copied from interface:ISpellVarChecks whether this spell variable should be synchronized between client and server. -
write
Description copied from interface:ISpellVarWrites the value to a network buffer for synchronization. -
read
Description copied from interface:ISpellVarReads the value from a network buffer.
-