Class BattleParticipant
java.lang.Object
com.pixelmonmod.pixelmon.battles.controller.participants.BattleParticipant
- Direct Known Subclasses:
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.The active Pokémon of the participant.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.boolean
Whether the participant is in a battle.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
boolean
Whether the participant is waiting for other participants to act. -
Constructor Summary
-
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.abstract boolean
Checks if the participant's Pokémon can give experience.boolean
Checks if the participant is allowed to Mega Evolve Pokémon.static boolean[]
Checks if Pokémon can switch or flee.abstract boolean
Checks if the participant's Pokémon are in a valid state.void
Resets turn-specific variables for the participant's Pokémon.int
Calculated number of unfainted Pokémon in the entire team.float
Counts the percentage of health remaining in the participant's party.int
Counts how many Pokémon are in the participant's party.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 the current system time.Returns the name of the entity the participant is representing.abstract net.minecraft.world.entity.LivingEntity
Gets the entity that this participant is representing.Gets the first fainted Pokémon in the participant's party.abstract MoveChoice
getMove
(PixelmonWrapper pixelmonWrapper) Gets the move to be used by the specified Pokémon.abstract net.minecraft.network.chat.Component
getName()
Gets the name of the participant.abstract void
getNextPokemon
(int position) Sends out the next unfainted Pokémon in the participant's party.abstract UUID
Gets the UUID of the next Pokémon in the participant's party that can battle;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.protected PixelmonWrapper
getPokemonFromParty
(PixelmonEntity entity) Gets the Pokémon from the participant's party who matches the given Pokémon ID.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.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.abstract ParticipantType
getType()
Gets the type of participant that this participant is.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 battleabstract boolean
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 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
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
Chooses an action for the participant's Pokémon.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
sendMessage
(PixelmonPacket message) Sends a packet to this participant, wont do anything if its not a player.void
void
setNumControlledPokemon
(int numControlledPokemon) Changes the number of Pokémon that the participant will send out.void
Adds the participant to a battle.void
Switches out all fainted Pokémon for their replacements.abstract PixelmonWrapper
switchPokemon
(PixelmonWrapper pw, UUID newPixelmonUUID) Switches the participant's Pokémon for another one.void
tick()
Updates the participant every tick.void
abstract void
Updates the opponent's Pokémon client-side.abstract void
updatePokemon
(PixelmonWrapper poke) Updates the specified Pokémon client-side.
-
Field Details
-
startedBattle
public boolean startedBattleWhether the participant is in a battle. -
bc
The battle the participant is in. -
team
public int teamThe side of the battle that the participant is on. -
wait
public boolean waitWhether the participant is waiting for other participants to act. -
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
public BattleParticipant(int numControlledPokemon) Initializes a participant.- Parameters:
numControlledPokemon
- The number of Pokémon that the participant will send out.
-
-
Method Details
-
getCurrentTime
Gets the current system time.- Returns:
- The current system time.
-
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.
-
setNumControlledPokemon
public void setNumControlledPokemon(int numControlledPokemon) Changes the number of Pokémon that the participant will send out. Should only be called before a battle begins.- Parameters:
numControlledPokemon
- The number of Pokémon that the participant will send out.
-
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 abstract boolean hasMorePokemonReserve()For use with switching in new Pokémon. Checks if they have Pokémon in reserve. Normally calls countablePokemon.- Returns:
- True if the player has a Pokémon in reserve.
-
canGainXP
public abstract boolean canGainXP()Checks if the participant's Pokémon can give experience.- Returns:
- Whether the participant's Pokémon can give experience.
-
startBattle
public void startBattle()Adds the participant to a battle. -
endBattle
Ends the battle the participant is in. -
getName
public abstract 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.
-
checkPokemon
public abstract 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.
-
updatePokemon
Updates the specified Pokémon client-side.- Parameters:
poke
- The Pokémon to update.
-
getEntity
public abstract net.minecraft.world.entity.LivingEntity getEntity()Gets the entity that this participant is representing.- Returns:
- The entity that this participant is representing.
-
updateOtherPokemon
public abstract void updateOtherPokemon()Updates the opponent's Pokémon client-side. -
getType
Gets the type of participant that this participant is.- Returns:
- The type of participant that this participant is.
-
getNextPokemon
public abstract 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.
-
getNextPokemonUUID
Gets the UUID of the next Pokémon in the participant's party that can battle;- Returns:
- the UUID of the next Pokémon in the participant's party that can battle, or null if there aren't any.
-
countTeam
public int countTeam()Counts how many Pokémon are in the participant's party.- Returns:
- The number of Pokémon in the participant's party.
-
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.
-
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.- Parameters:
target
- The Pokémon who took damage.damage
- The amount of damage dealt.
-
sendHealPacket
Updates the client when a Pokémon heals.- Parameters:
target
- The Pokémon who healed.amount
- The amount of hp healed.
-
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.
-
getPokemonFromParty
Gets the Pokémon from the participant's party who matches the given Pokémon ID.- Parameters:
entity
- The Pokémon to get aPixelmonWrapper
from.- Returns:
- The Pokémon from the participant's party who matches the given Pokémon ID.
-
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
-
sendMessage
Sends a packet to this participant, wont do anything if its not a player.- 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.
-