java.lang.Object
com.pixelmonmod.pixelmon.battles.controller.participants.BattleParticipant
Direct Known Subclasses:
PlayerParticipant, RaidPixelmonParticipant, TestParticipant, TrainerParticipant, WildPixelmonParticipant

public abstract class BattleParticipant extends Object
A participant in a battle.
  • Field Details

    • startedBattle

      public boolean startedBattle
      Whether the participant is in a battle.
    • bc

      public BattleController bc
      The battle the participant is in.
    • team

      public int team
      The side of the battle that the participant is on.
    • wait

      public boolean wait
      Whether the participant is waiting for other participants to act.
    • controlledPokemon

      public List<PixelmonWrapper> controlledPokemon
      The active Pokémon of the participant.
    • allPokemon

      public PixelmonWrapper[] allPokemon
      All Pokémon in the participant's party during battle.
    • isDefeated

      public boolean isDefeated
      Whether the participant has been defeated in battle.
    • lastMoveTime

      protected long lastMoveTime
      The time when the participant last made a move.
    • numControlledPokemon

      public int numControlledPokemon
      The number of Pokémon the participant is controlling in battle at once.
    • lastFaintedTurn

      protected int lastFaintedTurn
      The last turn the participant's Pokémon fainted in.
    • totalFainted

      protected int totalFainted
      How many of the participant's Pokémon have fainted total in the battle.
    • lastFailedCapture

      public PokeBall lastFailedCapture
      The last pokeball type that failed to catpure a pokemon, Used by the Ball Fetch ability
    • switchingIn

      public List<UUID> switchingIn
      Keeps track of Pokémon switching.
    • switchingOut

      public List<PixelmonWrapper> switchingOut
      The Pokémon that are switching out after fainting.
    • evolution

      public UUID evolution
      Whether the participant can currently Mega Evolve a Pokémon.
    • ultraBurst

      public UUID ultraBurst
    • ashNinja

      public UUID ashNinja
    • dynamax

      public UUID 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

      public Long 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

      public abstract void endBattle(BattleEndCause cause)
      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

      public abstract MoveChoice getMove(PixelmonWrapper pixelmonWrapper)
      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

      public abstract PixelmonWrapper switchPokemon(PixelmonWrapper pw, UUID newPixelmonUUID)
      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

      public abstract void updatePokemon(PixelmonWrapper poke)
      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

      public abstract ParticipantType 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

      public abstract UUID 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

      public PixelmonWrapper 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

      public void sendDamagePacket(PixelmonWrapper target, int damage)
      Updates the client when a Pokémon takes damage.
      Parameters:
      target - The Pokémon who took damage.
      damage - The amount of damage dealt.
    • sendHealPacket

      public void sendHealPacket(PixelmonWrapper target, int amount)
      Updates the client when a Pokémon heals.
      Parameters:
      target - The Pokémon who healed.
      amount - The amount of hp healed.
    • getDisplayName

      public String getDisplayName()
      Returns the name of the entity the participant is representing.
      Returns:
      The name of the entity the participant is representing.
    • canSwitch

      public static boolean[] canSwitch(PixelmonWrapper p)
      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

      public PartyStorage getStorage()
      Returns the Pokémon storage of the participant.
      Returns:
      The Pokémon storage of the participant.
    • getOpponents

      public List<BattleParticipant> getOpponents()
      Finds the participants on the opposing side of the battle.
      Returns:
      The participant's opponents.
    • getAllies

      public List<BattleParticipant> getAllies()
      Finds the participants on the allied side of the battle.
      Returns:
      The participant's allies.
    • getOpponentPokemon

      public List<PixelmonWrapper> 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

      public List<PixelmonWrapper> 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

      public List<PixelmonWrapper> 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

      public PixelmonWrapper getPokemonFromUUID(UUID uuid)
      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

      public PixelmonWrapper getPartyPokemonFromUUID(UUID uuid)
      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

      public int getPartyPosition(PixelmonWrapper pokemon)
      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

      protected void loadParty(PartyStorage party)
      Loads all Pokémon in the participant's party.
      Parameters:
      party - The storage to load Pokémon from.
    • loadParty

      protected void loadParty(List<Pokemon> party)
      Loads all Pokémon in the participant's party.
      Parameters:
      party - The Pokémon to use for the participant's party.
    • loadSingle

      protected void loadSingle(Pokemon pokemon)
      Loads just one Pokémon in the participant's party.
      Parameters:
      pokemon - The Pokémon to use for the participant's party.
    • getPokemonFromParty

      public PixelmonWrapper getPokemonFromParty(UUID uuid)
      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

      protected PixelmonWrapper getPokemonFromParty(PixelmonEntity entity)
      Gets the Pokémon from the participant's party who matches the given Pokémon ID.
      Parameters:
      entity - The Pokémon to get a PixelmonWrapper 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

      public boolean addSwitchingOut(PixelmonWrapper pw)
      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

      public PixelmonWrapper 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

      public BattleAIBase getBattleAI()
    • setBattleAI

      public void setBattleAI(BattleAIBase ai)
    • sendMessage

      public void sendMessage(PixelmonPacket message)
      Sends a packet to this participant, wont do anything if its not a player.
      Parameters:
      message - The packet to send to this player
    • onEndTurn

      public void onEndTurn(BattleController bc)
    • onTakeTurn

      public boolean onTakeTurn(BattleController bc, PixelmonWrapper pw)
    • onUseAttack

      public boolean onUseAttack(BattleController bc, PixelmonWrapper pw)
    • onUseAttackPost

      public void onUseAttackPost(BattleController bc, PixelmonWrapper pw)
    • onAddStatus

      public boolean onAddStatus(BattleController bc, PixelmonWrapper user, PixelmonWrapper target, StatusBase status)
    • onHit

      public float onHit(PixelmonWrapper source, float damage, DamageTypeEnum damageType)
    • onOpponentKO

      public void onOpponentKO(BattleController bc, PixelmonWrapper pw)
    • onTargeted

      public boolean onTargeted(PixelmonWrapper user, Attack attack)
    • onUseAttackOther

      public boolean onUseAttackOther(BattleController bc, Attack attack, BattleParticipant bp, PixelmonWrapper user)
    • onSwitchIn

      public void onSwitchIn(BattleController bc, PixelmonWrapper pw)
    • retrieveEntityDuringBattleUnlessRiding

      public void retrieveEntityDuringBattleUnlessRiding(PixelmonWrapper pw)
      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.