Record Class BattleRule

java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.battles.api.rules.BattleRule
Record Components:
modifiers - The modifiers that apply to the battle.
requirements - The requirements that the participants' Pokémon must meet to be valid for the battle.

public record BattleRule(List<BattleModifier> modifiers, List<ReasonedBattleRequirement> requirements) extends Record
A battle rule is a single rule that can be applied to a battle.
They are used to modify the battle, and check that the participants' Pokémon meet some set of requirements.
To see a list of all available modifiers, and requirements, check out the PixelmonRegistry, or BattleModifierTypes, and BattleRequirementTypes respectively.
All BattleRules are immutable, and are intended to be created through the datapackable registry PixelmonRegistry.BATTLE_RULE_REGISTRY.
  • Field Details

    • DIRECT_CODEC

      public static final com.mojang.serialization.Codec<BattleRule> DIRECT_CODEC
    • CODEC

      public static final com.mojang.serialization.Codec<net.minecraft.core.Holder<BattleRule>> CODEC
    • EMPTY

      public static final BattleRule EMPTY
  • Constructor Details

  • Method Details

    • validate

      public boolean validate(BattleParticipant participant)
    • validate

      public boolean validate(PartyStorage storage)
    • validate

      public boolean validate(Collection<Pokemon> pokemon)
    • validate

      public boolean validate(Pokemon... pokemon)
    • getFailureReasons

      public List<net.minecraft.network.chat.Component> getFailureReasons(BattleParticipant participant)
    • getFailureReasons

      public List<net.minecraft.network.chat.Component> getFailureReasons(PartyStorage storage)
    • getFailureReasons

      public List<net.minecraft.network.chat.Component> getFailureReasons(Collection<Pokemon> pokemon)
    • getFailureReasons

      public List<net.minecraft.network.chat.Component> getFailureReasons(Pokemon... pokemon)
    • apply

      public void apply(BattleController controller)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • modifiers

      public List<BattleModifier> modifiers()
      Returns the value of the modifiers record component.
      Returns:
      the value of the modifiers record component
    • requirements

      public List<ReasonedBattleRequirement> requirements()
      Returns the value of the requirements record component.
      Returns:
      the value of the requirements record component