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 Type
    Method
    Description
    default void
    decode(net.minecraft.network.FriendlyByteBuf buffer)
    Decodes the data from the given FriendlyByteBuf 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(FriendlyByteBuf) method
    default void
    encode(net.minecraft.network.FriendlyByteBuf buffer)
    Encodes the data to the given FriendlyByteBuf 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(FriendlyByteBuf) method
    get()
    Gets the current data stored in the value
    default void
    read(String key, net.minecraft.nbt.CompoundTag compound)
    Reads a value from the CompoundTag with the specified key Only implement if you want the battle rule/property to be persistent
    default void
    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(String key, net.minecraft.nbt.CompoundTag compound)
    Writes the given value to the CompoundTag 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

      default void set(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
      Parameters:
      o - The new value
    • update

      void update(T t)
      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 given FriendlyByteBuf 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(FriendlyByteBuf) method
      Parameters:
      buffer - The packet buffer being written to
    • decode

      default void decode(net.minecraft.network.FriendlyByteBuf buffer)
      Decodes the data from the given FriendlyByteBuf 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(FriendlyByteBuf) method
      Parameters:
      buffer - The packet buffer being read from
    • write

      default void write(String key, net.minecraft.nbt.CompoundTag compound)
      Writes the given value to the CompoundTag with the specified key Only implement if you want the battle rule/property to be persistent
      Parameters:
      key - The key being stored under
      compound - The compound being written to
    • read

      default void read(String key, net.minecraft.nbt.CompoundTag compound)
      Reads a value from the CompoundTag with the specified key Only implement if you want the battle rule/property to be persistent
      Parameters:
      key - The key being stored under
      compound - The compound being read from