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
All BattleRules are immutable, and are intended to be created through the datapackable registry
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec
<net.minecraft.core.Holder<BattleRule>> static final com.mojang.serialization.Codec
<BattleRule> static final BattleRule
-
Constructor Summary
ConstructorsConstructorDescriptionBattleRule
(List<BattleModifier> modifiers, List<ReasonedBattleRequirement> requirements) Creates an instance of aBattleRule
record class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(BattleController controller) final boolean
Indicates whether some other object is "equal to" this one.List
<net.minecraft.network.chat.Component> getFailureReasons
(Pokemon... pokemon) List
<net.minecraft.network.chat.Component> getFailureReasons
(PartyStorage storage) List
<net.minecraft.network.chat.Component> getFailureReasons
(BattleParticipant participant) List
<net.minecraft.network.chat.Component> getFailureReasons
(Collection<Pokemon> pokemon) final int
hashCode()
Returns a hash code value for this object.Returns the value of themodifiers
record component.Returns the value of therequirements
record component.final String
toString()
Returns a string representation of this record class.boolean
boolean
validate
(PartyStorage storage) boolean
validate
(BattleParticipant participant) boolean
validate
(Collection<Pokemon> pokemon)
-
Field Details
-
DIRECT_CODEC
-
CODEC
-
EMPTY
-
-
Constructor Details
-
BattleRule
Creates an instance of aBattleRule
record class.- Parameters:
modifiers
- the value for themodifiers
record componentrequirements
- the value for therequirements
record component
-
-
Method Details
-
validate
-
validate
-
validate
-
validate
-
getFailureReasons
-
getFailureReasons
-
getFailureReasons
-
getFailureReasons
-
apply
-
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. -
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. -
equals
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 withObjects::equals(Object,Object)
. -
modifiers
Returns the value of themodifiers
record component.- Returns:
- the value of the
modifiers
record component
-
requirements
Returns the value of therequirements
record component.- Returns:
- the value of the
requirements
record component
-