T
- The type being stored in the property valuepublic interface PropertyValue<T>
BattleProperty
of given type T
The encode(PacketBuffer)
and decode(PacketBuffer)
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, CompoundNBT)
and read(String, CompoundNBT)
methods should
only be implemented if you want the data to persist on NPCs/Entities which store the relevant BattleRules
Modifier and Type | Method and Description |
---|---|
default void |
decode(net.minecraft.network.PacketBuffer buffer)
Decodes the data from the given
PacketBuffer
When being sent to the client the BattleProperty 's ID will come first so that when being de-serialized it
can get a default value and then call the decode(PacketBuffer) method |
default void |
encode(net.minecraft.network.PacketBuffer buffer)
Encodes the data to the given
PacketBuffer
When being sent to the client the BattleProperty 's ID will come first so that when being de-serialized it
can get a default value and then call the decode(PacketBuffer) method |
T |
get()
Gets the current data stored in the value
|
default void |
read(java.lang.String key,
net.minecraft.nbt.CompoundNBT compound)
Reads a value from the
CompoundNBT with the specified key
Only implement if you want the battle rule/property to be persistent |
default void |
set(java.lang.Object o)
Attempts to set the current value to the object provided
If it fails to cast the object to the type of this
PropertyValue then it will error silently and not set
the value
Should not be implemented by subclasses unless you wish to change the parsing method |
void |
update(T t)
The method used for directly setting the stored value to an instance of the type, T, specified by the class
|
default void |
write(java.lang.String key,
net.minecraft.nbt.CompoundNBT compound)
Writes the given value to the
CompoundNBT with the specified key
Only implement if you want the battle rule/property to be persistent |
T get()
default void set(java.lang.Object o)
PropertyValue
then it will error silently and not set
the value
Should not be implemented by subclasses unless you wish to change the parsing methodo
- The new valuevoid update(T t)
t
- The new valuedefault void encode(net.minecraft.network.PacketBuffer buffer)
PacketBuffer
When being sent to the client the BattleProperty
's ID will come first so that when being de-serialized it
can get a default value and then call the decode(PacketBuffer)
methodbuffer
- The packet buffer being written todefault void decode(net.minecraft.network.PacketBuffer buffer)
PacketBuffer
When being sent to the client the BattleProperty
's ID will come first so that when being de-serialized it
can get a default value and then call the decode(PacketBuffer)
methodbuffer
- The packet buffer being read fromdefault void write(java.lang.String key, net.minecraft.nbt.CompoundNBT compound)
CompoundNBT
with the specified key
Only implement if you want the battle rule/property to be persistentkey
- The key being stored undercompound
- The compound being written todefault void read(java.lang.String key, net.minecraft.nbt.CompoundNBT compound)
CompoundNBT
with the specified key
Only implement if you want the battle rule/property to be persistentkey
- The key being stored undercompound
- The compound being read from