Interface PropertyValue<T>
- Type Parameters:
T
- The type being stored in the property value
- All Known Implementing Classes:
BattleTypeValue
,BooleanValue
,ClausesValue
,IntegerValue
,OldGenModeValue
,TierValue
public interface PropertyValue<T>
An interface representing a value for a
BattleProperty
of given type T
The encode(FriendlyByteBuf)
and decode(FriendlyByteBuf)
methods do not have to
be implemented unless the value is being sent to the client (only useful for internal uses or when a client-side mod
is present)
The write(String, CompoundTag)
and read(String, CompoundTag)
methods should
only be implemented if you want the data to persist on NPCs/Entities which store the relevant BattleRules
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
decode
(net.minecraft.network.FriendlyByteBuf buffer) Decodes the data from the givenFriendlyByteBuf
When being sent to the client theBattleProperty
's ID will come first so that when being de-serialized it can get a default value and then call thedecode(FriendlyByteBuf)
methoddefault void
encode
(net.minecraft.network.FriendlyByteBuf buffer) Encodes the data to the givenFriendlyByteBuf
When being sent to the client theBattleProperty
's ID will come first so that when being de-serialized it can get a default value and then call thedecode(FriendlyByteBuf)
methodget()
Gets the current data stored in the valuedefault void
Reads a value from theCompoundTag
with the specified key Only implement if you want the battle rule/property to be persistentdefault void
Attempts to set the current value to the object provided If it fails to cast the object to the type of thisPropertyValue
then it will error silently and not set the value Should not be implemented by subclasses unless you wish to change the parsing methodvoid
The method used for directly setting the stored value to an instance of the type, T, specified by the classdefault void
Writes the given value to theCompoundTag
with the specified key Only implement if you want the battle rule/property to be persistent
-
Method Details
-
get
T get()Gets the current data stored in the value- Returns:
- The data
-
set
Attempts to set the current value to the object provided If it fails to cast the object to the type of thisPropertyValue
then it will error silently and not set the value Should not be implemented by subclasses unless you wish to change the parsing method- Parameters:
o
- The new value
-
update
The method used for directly setting the stored value to an instance of the type, T, specified by the class- Parameters:
t
- The new value
-
encode
default void encode(net.minecraft.network.FriendlyByteBuf buffer) Encodes the data to the givenFriendlyByteBuf
When being sent to the client theBattleProperty
's ID will come first so that when being de-serialized it can get a default value and then call thedecode(FriendlyByteBuf)
method- Parameters:
buffer
- The packet buffer being written to
-
decode
default void decode(net.minecraft.network.FriendlyByteBuf buffer) Decodes the data from the givenFriendlyByteBuf
When being sent to the client theBattleProperty
's ID will come first so that when being de-serialized it can get a default value and then call thedecode(FriendlyByteBuf)
method- Parameters:
buffer
- The packet buffer being read from
-
write
Writes the given value to theCompoundTag
with the specified key Only implement if you want the battle rule/property to be persistent- Parameters:
key
- The key being stored undercompound
- The compound being written to
-
read
Reads a value from theCompoundTag
with the specified key Only implement if you want the battle rule/property to be persistent- Parameters:
key
- The key being stored undercompound
- The compound being read from
-