Class BattleParticipant
java.lang.Object
com.pixelmonmod.pixelmon.battles.controller.participants.BattleParticipant
- All Implemented Interfaces:
BattleViewer
- Direct Known Subclasses:
EntityParticipant
,PlayerParticipant
,RaidPixelmonParticipant
,TestParticipant
,TrainerParticipant
,WildPixelmonParticipant
A participant in a battle.
-
Field Summary
Modifier and TypeFieldDescriptionAll Pokémon in the participant's party during battle.The battle the participant is in.final List<PixelmonWrapper>
The active Pokémon of the participant.protected final net.minecraft.world.entity.Entity
Whether the participant can currently Mega Evolve a Pokémon.boolean
Whether the participant has been defeated in battle.The last pokeball type that failed to catpure a pokemon, Used by the Ball Fetch abilityprotected int
The last turn the participant's Pokémon fainted in.protected long
The time when the participant last made a move.int
The number of Pokémon the participant is controlling in battle at once.Keeps track of Pokémon switching.The Pokémon that are switching out after fainting.int
The side of the battle that the participant is on.protected int
How many of the participant's Pokémon have fainted total in the battle.boolean
protected boolean
-
Constructor Summary
ModifierConstructorDescriptionprotected
BattleParticipant
(net.minecraft.world.entity.Entity entity, int numControlledPokemon, Pokemon... pokemon) protected
BattleParticipant
(net.minecraft.world.entity.Entity entity, int numControlledPokemon, PixelmonWrapper... pokemon) protected
BattleParticipant
(net.minecraft.world.entity.Entity entity, int numControlledPokemon, PixelmonEntity... entities) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a Pokémon to the list of Pokémon switching out.boolean
Checks if the participant is allowed to Dynamax Pokémon.boolean
Checks if the participant is allowed to Mega Evolve Pokémon.static boolean[]
Checks if Pokémon can switch or flee.void
checkAndHandleBossTier
(PixelmonWrapper wrapper) Checks if the participant is a boss and then applies the boss tier logic to the provided wrapper.boolean
Checks if the participant's Pokémon are in a valid state.protected void
void
Resets turn-specific variables for the participant's Pokémon.protected static PixelmonWrapper[]
convertEntitiesToWrapper
(PixelmonEntity... entities) protected static PixelmonWrapper[]
convertPokemonToWrapper
(Pokemon... pokemon) int
Calculated number of unfainted Pokémon in the entire team.int
Counts the number of fainted Pokémon in the participant's party.float
Counts the percentage of health remaining in the participant's party.int
countPartyPokemon
(Predicate<PixelmonWrapper> predicate) Counts the number of Pokémon in the participant's party that match the provided predicate.abstract void
endBattle
(BattleEndCause cause) Ends the battle the participant is in.boolean
Returns whether one of the participant's pokemon fainted last turn.Returns all active, unfainted Pokémon that the participant is controlling.Finds the participants on the allied side of the battle.Gets data about the player's allied Pokémon.net.minecraft.network.chat.MutableComponent
Returns the name of the entity the participant is representing.net.minecraft.world.entity.Entity
Gets the entity that this participant is representing.Gets the first fainted Pokémon in the participant's party.int
Gets the highest level of the participant's Pokémon.protected int
Gets the level cap for the participant.getMove
(PixelmonWrapper pixelmonWrapper) Gets the move to be used by the specified Pokémon.net.minecraft.network.chat.Component
getName()
Gets the name of the participant.void
getNextPokemon
(int position) Sends out the next unfainted Pokémon in the participant's party.Returns all Pokemon on the opposite side of the battle that the participant is on.Finds the participants on the opposing side of the battle.getPartyPokemonFromUUID
(UUID uuid) Gets a Pokémon from its UUID.int
getPartyPosition
(PixelmonWrapper pokemon) Gets the base position of the Pokémon in the participant's party.getPokemonFromParty
(UUID uuid) Gets the Pokémon from the participant's party who matches the given Pokémon UUID.getPokemonFromUUID
(UUID uuid) Gets a controlled Pokémon from its UUID.Gets a random Pokémon from the participant's party that isn't already sent out.Returns the Pokémon storage of the participant.Returns all Pokemon on the side of the battle that the participant is on.Finds all Pokémon in the battle allied with the player.int
Returns the number of Pokémon that have fainted for this participant this battle.long
Gets the time since the participant last made a move.Gets the UUID of the participant.boolean
getWait()
Checks if the participant is waiting in battle.net.minecraft.world.level.Level
getWorld()
Gets the world that the participant is in.boolean
Checks if the participant has Pokémon that can battleboolean
For use with switching in new Pokémon.boolean
Checks if the participant has unfainted Pokémon remaining.void
Increments the number of fainted pokemon.protected boolean
boolean
isPlayer()
If the participant is a player.boolean
isRaid()
If the participant is a raid.boolean
If the participant is a trainer.boolean
isWild()
If the participant is a wild Pokémon.protected void
loadParty
(PartyStorage party) Loads all Pokémon in the participant's party.protected void
Loads all Pokémon in the participant's party.protected void
loadSingle
(Pokemon pokemon) Loads just one Pokémon in the participant's party.boolean
onAddStatus
(BattleController bc, PixelmonWrapper user, PixelmonWrapper target, StatusBase status) void
float
onHit
(PixelmonWrapper source, float damage, DamageTypeEnum damageType) void
void
boolean
boolean
onTargeted
(PixelmonWrapper user, Attack attack) boolean
boolean
onUseAttackOther
(BattleController bc, Attack attack, BattleParticipant bp, PixelmonWrapper user) void
void
Adds the participant to a battle.protected void
releasePokemon
(PixelmonWrapper pixelmonWrapper) Attempts to spawn the entity for the provided wrapper.void
Resets the timer for the participant making a move.void
If a player/trainer is riding their Pokémon and gets in a battle while riding it, they shouldn't be knocked off their Pokémon.void
revivePokemon
(float healthPercentage) protected void
revivePokemon
(PixelmonWrapper pokemon, float healthPercentage) void
Chooses an action for the participant's Pokémon.void
sendBattleMessage
(String message, Object... args) Sends a battle message to this participant.void
sendBattleMessage
(net.minecraft.network.chat.Component component) Sends a battle message to this participant.void
sendDamagePacket
(PixelmonWrapper target, int damage) Updates the client when a Pokémon takes damage.void
sendHealPacket
(PixelmonWrapper target, int amount) Updates the client when a Pokémon heals.void
sendPacket
(PixelmonPacket message) Sends a packet to this participant, wont do anything if its not a player.void
void
setWait
(boolean wait) void
void
Switches out all fainted Pokémon for their replacements.switchPokemon
(PixelmonWrapper pw, UUID newPixelmonUUID) Switches the participant's Pokémon for another one.void
tick()
Updates the participant every tick.void
Updates the opponent's Pokémon client-side.void
boolean
waiting()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.pixelmonmod.pixelmon.battles.controller.BattleViewer
getPlayer, sendBattleMessage
-
Field Details
-
entity
protected final net.minecraft.world.entity.Entity entity -
bc
The battle the participant is in. -
team
public int teamThe side of the battle that the participant is on. -
wait
protected boolean wait -
controlledPokemon
The active Pokémon of the participant. -
allPokemon
All Pokémon in the participant's party during battle. -
isDefeated
public boolean isDefeatedWhether the participant has been defeated in battle. -
lastMoveTime
protected long lastMoveTimeThe time when the participant last made a move. -
numControlledPokemon
public int numControlledPokemonThe number of Pokémon the participant is controlling in battle at once. -
lastFaintedTurn
protected int lastFaintedTurnThe last turn the participant's Pokémon fainted in. -
totalFainted
protected int totalFaintedHow many of the participant's Pokémon have fainted total in the battle. -
lastFailedCapture
The last pokeball type that failed to catpure a pokemon, Used by the Ball Fetch ability -
switchingIn
Keeps track of Pokémon switching. -
switchingOut
The Pokémon that are switching out after fainting. -
evolution
Whether the participant can currently Mega Evolve a Pokémon. -
ultraBurst
-
ashNinja
-
dynamax
-
usedZ
public boolean usedZ
-
-
Constructor Details
-
BattleParticipant
protected BattleParticipant(net.minecraft.world.entity.Entity entity, int numControlledPokemon, PixelmonWrapper... pokemon) -
BattleParticipant
protected BattleParticipant(net.minecraft.world.entity.Entity entity, int numControlledPokemon, Pokemon... pokemon) -
BattleParticipant
protected BattleParticipant(net.minecraft.world.entity.Entity entity, int numControlledPokemon, PixelmonEntity... entities)
-
-
Method Details
-
convertPokemonToWrapper
-
convertEntitiesToWrapper
-
resetMoveTimer
public void resetMoveTimer()Resets the timer for the participant making a move. -
getTurnTimeSeconds
public long getTurnTimeSeconds()Gets the time since the participant last made a move.- Returns:
- The time since the participant last made a move.
-
waiting
public boolean waiting() -
setWait
public void setWait(boolean wait) -
clearMovement
-
getUniqueId
Gets the UUID of the participant.- Returns:
- The UUID of the participant.
-
isWild
public boolean isWild()If the participant is a wild Pokémon.- Returns:
- Whether the participant is a wild Pokémon.
-
isPlayer
public boolean isPlayer()If the participant is a player.- Returns:
- Whether the participant is a player.
-
isTrainer
public boolean isTrainer()If the participant is a trainer.- Returns:
- Whether the participant is a trainer.
-
isRaid
public boolean isRaid()If the participant is a raid.- Returns:
- Whether the participant is a raid.
-
hasMorePokemon
public boolean hasMorePokemon()Checks if the participant has Pokémon that can battle- Returns:
- True if the player has a Pokémon that can battle.
-
hasMorePokemonReserve
public boolean hasMorePokemonReserve()For use with switching in new Pokémon. Checks if they have Pokémon in reserve.- Returns:
- True if the player has a Pokémon in reserve.
-
isOnField
-
startBattle
public void startBattle() -
preBattleChecks
public void preBattleChecks()Adds the participant to a battle. -
releasePokemon
Attempts to spawn the entity for the provided wrapper.- Parameters:
pixelmonWrapper
- The wrapper to spawn the entity for.
-
getLevelCap
protected int getLevelCap()Gets the level cap for the participant.
This may be different for boss related entities.- Returns:
- The level cap for the participant.
-
getTeamPokemonUUIDs
Finds all Pokémon in the battle allied with the player.- Returns:
- An array of Pokémon allied with the player.
-
endBattle
Ends the battle the participant is in. -
getName
public net.minecraft.network.chat.Component getName()Gets the name of the participant.- Returns:
- The name of the participant.
-
getMove
Gets the move to be used by the specified Pokémon.- Parameters:
pixelmonWrapper
- The Pokémon to get a move for.- Returns:
- The move to be used by the specified Pokémon.
-
switchPokemon
Switches the participant's Pokémon for another one.- Parameters:
pw
- The Pokémon to switch out.newPixelmonUUID
- The UUID of the Pokémon's to switch in.- Returns:
- The Pokémon who switched in.
-
sendBattleMessage
Sends a battle message to this participant.- Specified by:
sendBattleMessage
in interfaceBattleViewer
- Parameters:
message
- The message to send.args
- The arguments to format the message with.
-
sendBattleMessage
public void sendBattleMessage(net.minecraft.network.chat.Component component) Sends a battle message to this participant.- Specified by:
sendBattleMessage
in interfaceBattleViewer
- Parameters:
component
- The message to send.
-
checkAndHandleBossTier
Checks if the participant is a boss and then applies the boss tier logic to the provided wrapper.- Parameters:
wrapper
- The wrapper to apply the boss tier logic to.
-
getHighestLevel
public int getHighestLevel()Gets the highest level of the participant's Pokémon.- Returns:
- The highest level
-
checkPokemon
public boolean checkPokemon()Checks if the participant's Pokémon are in a valid state.- Returns:
- Whether the participant's Pokémon are in a valid state.
-
getEntity
@Nullable public net.minecraft.world.entity.Entity getEntity()Gets the entity that this participant is representing.- Specified by:
getEntity
in interfaceBattleViewer
- Returns:
- The entity that this participant is representing.
-
updateBattlingPokemon
public void updateBattlingPokemon()Updates the opponent's Pokémon client-side. -
getNextPokemon
public void getNextPokemon(int position) Sends out the next unfainted Pokémon in the participant's party.- Parameters:
position
- The position to send out the Pokémon at.
-
countAblePokemon
public int countAblePokemon()Calculated number of unfainted Pokémon in the entire team.- Returns:
- The number of unfainted Pokémon, sent out or not.
-
countHealthPercent
public float countHealthPercent()Counts the percentage of health remaining in the participant's party.- Returns:
- The percentage of health remaining in the participant's party.
-
getAllyData
Gets data about the player's allied Pokémon.- Returns:
- Data about the player's allied Pokémon.
-
tick
public void tick()Updates the participant every tick. -
clearTurnVariables
public void clearTurnVariables()Resets turn-specific variables for the participant's Pokémon. -
selectAction
public void selectAction()Chooses an action for the participant's Pokémon. -
getWait
public boolean getWait()Checks if the participant is waiting in battle.- Returns:
- Whether the participant is waiting in battle.
-
getFaintedPokemon
Gets the first fainted Pokémon in the participant's party.- Returns:
- The first fainted Pokémon in the participant's party.
-
hasRemainingPokemon
public boolean hasRemainingPokemon()Checks if the participant has unfainted Pokémon remaining.- Returns:
- Whether the participant has unfainted Pokémon remaining.
-
faintedLastTurn
public boolean faintedLastTurn()Returns whether one of the participant's pokemon fainted last turn.- Returns:
- Whether one of the participant's pokemon fainted in the previous turn.
-
updateLastFaintedTurn
public void updateLastFaintedTurn() -
getTotalFainted
public int getTotalFainted()Returns the number of Pokémon that have fainted for this participant this battle.- Returns:
- Number of total fainted, including revived pokemon.
-
incrementFaintCount
public void incrementFaintCount()Increments the number of fainted pokemon. To be called when a Pokémon faints. -
sendDamagePacket
Updates the client when a Pokémon takes damage.- Specified by:
sendDamagePacket
in interfaceBattleViewer
- Parameters:
target
- The Pokémon who took damage.damage
- The amount of damage dealt.
-
sendHealPacket
Updates the client when a Pokémon heals.- Specified by:
sendHealPacket
in interfaceBattleViewer
- Parameters:
target
- The Pokémon who healed.amount
- The amount of hp healed.
-
getDisplayName
public net.minecraft.network.chat.MutableComponent getDisplayName()Returns the name of the entity the participant is representing.- Returns:
- The name of the entity the participant is representing.
-
canSwitch
Checks if Pokémon can switch or flee.- Parameters:
p
- The Pokémon to check.- Returns:
- A boolean array containing whether the Pokémon can switch and whether it can flee.
-
getStorage
Returns the Pokémon storage of the participant.- Returns:
- The Pokémon storage of the participant.
-
getOpponents
Finds the participants on the opposing side of the battle.- Returns:
- The participant's opponents.
-
getAllies
Finds the participants on the allied side of the battle.- Returns:
- The participant's allies.
-
getOpponentPokemon
Returns all Pokemon on the opposite side of the battle that the participant is on.- Returns:
- A list of all Pokemon on the opposite of the battle that the participant is on.
-
getTeamPokemon
Returns all Pokemon on the side of the battle that the participant is on.- Returns:
- A list of all Pokemon on the side of the battle that the participant is on.
-
getActiveUnfaintedPokemon
Returns all active, unfainted Pokémon that the participant is controlling.- Returns:
- A list of all active, unfainted Pokémon that the participant is controlling.
-
getPokemonFromUUID
Gets a controlled Pokémon from its UUID.- Parameters:
uuid
- The UUID of the Pokémon to get.- Returns:
- The Pokémon with the specified UUID, or null if no Pokémon has the UUID.
-
getPartyPokemonFromUUID
Gets a Pokémon from its UUID.- Parameters:
uuid
- The UUID of the Pokémon to get.- Returns:
- The Pokémon with the specified UUID, or null if no Pokémon has the UUID.
-
getPartyPosition
Gets the base position of the Pokémon in the participant's party.- Parameters:
pokemon
- The Pokémon to get the position of.- Returns:
- The base position of the Pokémon in the participant's party.
-
loadParty
Loads all Pokémon in the participant's party.- Parameters:
party
- The storage to load Pokémon from.
-
loadParty
Loads all Pokémon in the participant's party.- Parameters:
party
- The Pokémon to use for the participant's party.
-
loadSingle
Loads just one Pokémon in the participant's party.- Parameters:
pokemon
- The Pokémon to use for the participant's party.
-
getPokemonFromParty
Gets the Pokémon from the participant's party who matches the given Pokémon UUID.- Parameters:
uuid
- The UUID to get a Pokémon with.- Returns:
- The Pokémon from the participant's party who matches the given Pokémon UUID.
-
getWorld
public net.minecraft.world.level.Level getWorld()Gets the world that the participant is in.- Returns:
- The world that the participant is in.
-
addSwitchingOut
Adds a Pokémon to the list of Pokémon switching out.- Parameters:
pw
- The Pokémon to add to the list.- Returns:
- Whether the participant has Pokémon in reserve to switch out with.
-
switchAllFainted
public void switchAllFainted()Switches out all fainted Pokémon for their replacements. -
getRandomPartyPokemon
Gets a random Pokémon from the participant's party that isn't already sent out.- Returns:
- A random Pokémon from the participant's party that isn't already sent out, or null if there aren't any.
-
canMegaEvolve
public boolean canMegaEvolve()Checks if the participant is allowed to Mega Evolve Pokémon.- Returns:
- Whether the participant is allowed to Mega Evolve Pokémon.
-
canDynamax
public boolean canDynamax()Checks if the participant is allowed to Dynamax Pokémon.- Returns:
- Whether the participant is allowed to Dynamax Pokémon.
-
getBattleAI
-
setBattleAI
-
revivePokemon
public void revivePokemon(float healthPercentage) -
revivePokemon
-
countFaintedPokemon
public int countFaintedPokemon()Counts the number of fainted Pokémon in the participant's party.- Returns:
- The number of fainted Pokémon in the participant's party.
-
countPartyPokemon
Counts the number of Pokémon in the participant's party that match the provided predicate.- Parameters:
predicate
- The predicate to match Pokémon against.- Returns:
- The number of Pokémon in the participant's party that match the provided predicate.
-
sendPacket
Sends a packet to this participant, wont do anything if its not a player.- Specified by:
sendPacket
in interfaceBattleViewer
- Parameters:
message
- The packet to send to this player
-
onEndTurn
-
onTakeTurn
-
onUseAttack
-
onUseAttackPost
-
onAddStatus
public boolean onAddStatus(BattleController bc, PixelmonWrapper user, PixelmonWrapper target, StatusBase status) -
onHit
-
onOpponentKO
-
onTargeted
-
onUseAttackOther
public boolean onUseAttackOther(BattleController bc, Attack attack, BattleParticipant bp, PixelmonWrapper user) -
onSwitchIn
-
retrieveEntityDuringBattleUnlessRiding
If a player/trainer is riding their Pokémon and gets in a battle while riding it, they shouldn't be knocked off their Pokémon.- Parameters:
pw
- The Pokémon that is currently in battle that the player may or may not be riding upon.
-