Class BattleRules
java.lang.Object
com.pixelmonmod.pixelmon.battles.api.rules.BattleRules
- All Implemented Interfaces:
IEncodeable
,Cloneable
Customizable rules for restricting battles.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionInitializes 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()
void
decodeInto
(net.minecraft.network.FriendlyByteBuf buf) Imports rules from a byte array.void
encodeInto
(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> T
getOrDefault
(BattleProperty<T> property) boolean
hasClause
(BattleClause clause) Check if the rules have the given clause as a settingboolean
Check if the rules have a clause with a certain ID.importText
(String text) Imports a set of rules from text.boolean
Checks if the rules are the default set of battle rules.void
readFromNBT
(net.minecraft.nbt.CompoundTag nbt) Reads rules from NBT data.<T> BattleRules
set
(BattleProperty<T> property, Object o) void
setNewClauses
(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.void
writeToNBT
(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:
encodeInto
in 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:
decodeInto
in 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.
-