Class BattleRules
java.lang.Object
com.pixelmonmod.pixelmon.battles.api.rules.BattleRules
- All Implemented Interfaces:
 IEncodeable,Cloneable
Customizable rules for restricting battles.
- 
Field Summary
Fields - 
Constructor Summary
ConstructorsConstructorDescriptionInitializes a set of default rules.BattleRules(BattleType battleType) Initializes a set of rules with a specified battle type.BattleRules(String text) Initializes a set of rules from an importable string. - 
Method Summary
Modifier and TypeMethodDescriptionclone()voiddecodeInto(net.minecraft.network.FriendlyByteBuf buf) Imports rules from a byte array.voidencodeInto(net.minecraft.network.FriendlyByteBuf buf) Exports the rules as a byte array.Exports the rules as human-readable text.<T> Optional<T>get(BattleProperty<T> property) Gets a sorted list of clauses by their IDs.Gets a sorted list of clauses.<T> TgetOrDefault(BattleProperty<T> property) booleanhasClause(BattleClause clause) Check if the rules have the given clause as a settingbooleanCheck if the rules have a clause with a certain ID.importText(String text) Imports a set of rules from text.booleanChecks if the rules are the default set of battle rules.voidreadFromNBT(net.minecraft.nbt.CompoundTag nbt) Reads rules from NBT data.<T> BattleRulesset(BattleProperty<T> property, Object o) voidsetNewClauses(List<BattleClause> newClauses) Adds a new set of clauses to the rules.validateSingle(Pokemon pokemon) Checks if the rules allow a Pokémon to be chosen for battle.validateTeam(List<Pokemon> team) Checks if the rules allow a list of Pokémon to be chosen for battle.voidwriteToNBT(net.minecraft.nbt.CompoundTag nbt) Writes rule data to NBT. 
- 
Field Details
- 
MAX_NUM_POKEMON
public static final int MAX_NUM_POKEMON- See Also:
 
 
 - 
 - 
Constructor Details
- 
BattleRules
public BattleRules()Initializes a set of default rules. - 
BattleRules
Initializes a set of rules with a specified battle type.- Parameters:
 battleType- The type of battle to use.
 - 
BattleRules
Initializes a set of rules from an importable string.- Parameters:
 text- The string to import battle rules from.
 
 - 
 - 
Method Details
- 
set
 - 
get
 - 
getOrDefault
 - 
clone
 - 
exportText
Exports the rules as human-readable text.- Returns:
 - A text exportable of the rules.
 
 - 
importText
Imports a set of rules from text.- Parameters:
 text- The text to import rules from.- Returns:
 - Null if the text was parsed correctly. An error code if there was a parsing error.
 
 - 
encodeInto
public void encodeInto(net.minecraft.network.FriendlyByteBuf buf) Exports the rules as a byte array.- Specified by:
 encodeIntoin interfaceIEncodeable- Parameters:
 buf- The byte buffer to write to.
 - 
decodeInto
public void decodeInto(net.minecraft.network.FriendlyByteBuf buf) Imports rules from a byte array.- Specified by:
 decodeIntoin interfaceIEncodeable- Parameters:
 buf- The byte buffer to read from.
 - 
writeToNBT
public void writeToNBT(net.minecraft.nbt.CompoundTag nbt) Writes rule data to NBT.- Parameters:
 nbt- The NBT tag to write to.
 - 
readFromNBT
public void readFromNBT(net.minecraft.nbt.CompoundTag nbt) Reads rules from NBT data.- Parameters:
 nbt- The NBT data to read from.
 - 
getClauseList
Gets a sorted list of clauses.- Returns:
 - A sorted list of clauses.
 
 - 
getClauseIDs
Gets a sorted list of clauses by their IDs.- Returns:
 - A sorted list of clauses by their IDs.
 
 - 
hasClause
Check if the rules have the given clause as a setting- Parameters:
 clause- The clause being checked- Returns:
 - True if it has this clause applied
 
 - 
hasClause
Check if the rules have a clause with a certain ID.- Parameters:
 id- The clause ID to look for.- Returns:
 - Whether the rules have a clause with the specified ID.
 
 - 
setNewClauses
Adds a new set of clauses to the rules. Replaces the current set of clauses.- Parameters:
 newClauses- The new clauses to add.
 - 
isDefault
public boolean isDefault()Checks if the rules are the default set of battle rules.- Returns:
 - Whether the rules are the default set of battle rules.
 
 - 
validateSingle
Checks if the rules allow a Pokémon to be chosen for battle.- Parameters:
 pokemon- The Pokémon to check.- Returns:
 - Whether the rules allow the given Pokémon to be chosen for battle.
 
 - 
validateTeam
Checks if the rules allow a list of Pokémon to be chosen for battle.- Parameters:
 team- The Pokémon to check.- Returns:
 - Whether the rules allow the given Pokémon to be chosen for battle.
 
 
 -