Class ClientBattleManager

java.lang.Object
com.pixelmonmod.pixelmon.client.gui.battles.ClientBattleManager

public class ClientBattleManager extends Object
The client-side manager for battles.
  • Field Details

    • TIMER

      public static final Timer TIMER
    • battleControllerIndex

      public int battleControllerIndex
      The index of the battle controller for the battle the player is in.
    • mode

      protected AtomicReference<BattleMode> mode
    • oldMode

      protected BattleMode oldMode
    • bagSection

      public BagSection bagSection
      The player's battle bag.
    • battleEnded

      public boolean battleEnded
      Whether the player's battle has ended.
    • isSpectating

      public boolean isSpectating
      Whether the player is spectating a battle.
    • teamPokemon

      public UUID[] teamPokemon
      The Pokémon on the player's team that are on the field while in a battle.
    • displayedEnemyPokemon

      public PixelmonClientData[] displayedEnemyPokemon
      The opposing Pokémon displayed in the battle GUI.
    • displayedOurPokemon

      public PixelmonClientData[] displayedOurPokemon
      Pokémon owned by the player that are displayed in the battle GUI.
    • displayedAllyPokemon

      public PixelmonClientData[] displayedAllyPokemon
      Pokémon owned by allies of the player that are displayed in the battle GUI.
    • fullOurPokemon

      public List<PixelmonClientData> fullOurPokemon
      All the Pokémon on the player's team while in a battle.
    • levelUpList

      public ArrayList<LevelUpPacket> levelUpList
      Pokémon owned by the player that have leveled up.
    • newAttackList

      public ArrayList<AttackData> newAttackList
      Attacks to be learned by the player's Pokémon.
    • startIndex

      public int startIndex
      The index of the bag to begin displaying items at.
    • itemToUse

      public ItemData itemToUse
      The item to be used by the player.
    • lastItem

      public org.apache.commons.lang3.tuple.Pair<BagSection,ItemData> lastItem
    • sections

      public Map<BagSection,List<ItemData>> sections
    • sendPacket

      public AbstractPixelmonPacket sendPacket
      Sends packets to the server.
    • yesNoOrigin

      public BattleMode yesNoOrigin
      The mode of the battle where the yes/no GUI was triggered from.
    • evolveList

      public List<EvoInfo> evolveList
      The Pokémon owned by the player that will evolve.
    • isHealing

      public boolean isHealing
      Whether the player's Pokémon is healing.
    • enforcedFleeFailed

      public boolean enforcedFleeFailed
      Whether a flee attempt has failed in this switch.
    • preventFleeOnSwitch

      public boolean preventFleeOnSwitch
      Whether the player can flee (click the "Run" button) when they need to switch Pokémon. This should be true when a Pokémon switches out due to an ability, item, or move.
    • healAmount

      public int healAmount
      The amount to heal the player's Pokémon by.
    • selectedAttack

      public int selectedAttack
      The index of the attack selected by the player.
    • currentPokemon

      public int currentPokemon
      The index of the Pokémon currently selecting a move.
    • targetted

      public boolean[][] targetted
      The Pokémon being targeted by an attack.
    • choosingPokemon

      public boolean choosingPokemon
      Whether the player is currently choosing a Pokémon.
    • battleTurn

      public int battleTurn
      Current turn.
    • weather

      public StatusType weather
      Current weather.
    • terrain

      public StatusType terrain
      Current terrain.
    • catchCombo

      public int catchCombo
      The current catch combo.
    • selectedActions

      public ArrayList<AbstractPixelmonPacket> selectedActions
      The actions that the player has currently selected for the battle turn.
    • battleType

      public BattleType battleType
      The type of battle the player is involved in.
    • afkOn

      public boolean afkOn
      Whether the AFK handler is enabled.
    • afkActive

      public boolean afkActive
      Whether the AFK handler is making moves.
    • afkActivate

      public int afkActivate
      The amount of time before the AFK handler takes over.
    • afkTurn

      public int afkTurn
      The amount of time before the AFK handler makes a move.
    • afkTime

      public int afkTime
      The time that the player has been AFK.
    • waitingText

      public boolean waitingText
      Whether the "waiting" text is visible.
    • battlePerspective

      public BattlePerspectiveMode battlePerspective
      Whether the player is viewing their battle in first person and not with the battle camera.
    • battleScreenDisabled

      public BattleScreenMode battleScreenDisabled
      Whether the battle screen ui elements are disabled/prevented from being rendered while the player is viewing the battle.
    • freeToMoveDuringBattle

      public boolean freeToMoveDuringBattle
      Whether the player can move around while they are in a battle.
    • distanceUntilBattleForfeited

      public float distanceUntilBattleForfeited
      Whether the player will forfeit their battle if they move much further away.
    • minDistanceUntilVignette

      public float minDistanceUntilVignette
    • maxDistanceUntilBattleForfeited

      public float maxDistanceUntilBattleForfeited
    • megaEvolving

      public boolean megaEvolving
      Whether the player has chosen to Mega Evolve or Ultra Burst the current Pokémon.
    • dynamaxing

      public boolean dynamaxing
      Whether the player has chosen to Dynamax the current Pokémon.
    • megaEvolution

      public UUID megaEvolution
      The ID of the currently Mega Evolved/Ultra Burst/Dynamaxed Pokémon.
    • ultraBurst

      public UUID ultraBurst
    • dynamax

      public UUID dynamax
    • hasUltraBurst

      public boolean hasUltraBurst
    • hasDynamaxed

      public boolean hasDynamaxed
    • dynamaxTurnsLeft

      public int dynamaxTurnsLeft
    • dynamaxDisabled

      public boolean dynamaxDisabled
    • gigantamax

      public boolean gigantamax
    • showZMoves

      public boolean showZMoves
    • usedZMove

      public boolean usedZMove
    • oldGen

      public Quadstate oldGen
    • rules

      public BattleRules rules
      The rules currently in effect for the battle.
    • canSwitch

      public boolean canSwitch
      Whether the current Pokémon can switch.
    • canFlee

      public boolean canFlee
      Whether the current Pokémon can flee from battle.
    • pokemonToChoose

      public ArrayList<UUID> pokemonToChoose
      A list of Pokémon to choose actions for.
    • spectatingUUID

      public UUID spectatingUUID
      The UUID of the player being spectated.
  • Constructor Details

    • ClientBattleManager

      public ClientBattleManager()
  • Method Details

    • isBattling

      public boolean isBattling()
      Checks if the player is battling in a battle (not including spectating).
      Returns:
      Whether the player is battling in a battle.
    • addMessage

      public void addMessage(String s)
      Adds a battle message to the player's message list.
      Parameters:
      s - The message to add.
    • addMessage

      public void addMessage(String key, Object... arguments)
      Adds a battle message to the player's message list.
    • getNextBattleTask

      @Nullable public BattleTaskPacket getNextBattleTask()
    • removeBattleTask

      public void removeBattleTask()
    • hasMoreMessages

      public boolean hasMoreMessages()
      Checks if the player has any more messages to be displayed.
      Returns:
      Whether the player has more messages to be displayed.
    • hasMoreTasks

      public boolean hasMoreTasks()
      Checks if the player has any more tasks to be run.
      Returns:
      Whether the player has more messages to be displayed.
    • addBattleMessage

      public void addBattleMessage(BattleTaskPacket message)
      Adds a battle message that will be displayed to the player.
      Parameters:
      message - The message to add.
    • processBattleTasks

      public void processBattleTasks()
    • isProcessingTask

      public boolean isProcessingTask()
      Does not include tasks that are running parallel.
      Returns:
      true if the gui is still processing a message or task.
    • sendParticipantReady

      public void sendParticipantReady()
      Triggers when the player's battle messages are emptied.
    • checkClearedMessages

      public void checkClearedMessages()
      Checks if the player has cleared all messages, and triggers the cleared message event if so.
    • getCurrentPokemon

      public PixelmonClientData getCurrentPokemon()
      Gets the Pokémon currently awaiting action.
      Returns:
      The data for the Pokémon currently awaiting action, or null if there isn't one.
    • getUserPokemon

      public PixelmonEntity getUserPokemon()
    • getUserPokemon

      public PixelmonEntity getUserPokemon(CameraMode mode)
      Gets the Pokémon currently awaiting action.
      Parameters:
      mode -
      Returns:
      Gets the Pokémon entity currently awaiting action, or null if there isn't one.
    • getEntity

      public PixelmonEntity getEntity(UUID uuid)
      Gets the Pokémon entity corresponding to a Pokémon UUID
      Parameters:
      uuid - The UUID of the Pokémon
      Returns:
      The specified Pokémon entity, or null if there isn't one.
    • hasLevelUps

      public boolean hasLevelUps()
      Checks if any of the player's Pokémon have leveled up.
      Returns:
      Whether any of the player's Pokémon have leveled up.
    • hasNewAttacks

      public boolean hasNewAttacks()
      Checks if any of the player's Pokémon are learning new attacks.
      Returns:
      Whether any of the player's Pokémon are learning new attacks.
    • startBattle

      public void startBattle(int battleControllerIndex, boolean canCatch, boolean isForfeit, int afkActivate, int afkTurn, BattleRules rules, List<PixelmonClientData> team, List<PixelmonClientData> allies, List<UUID> battlingPokemon, List<PixelmonClientData> opponentBattlingPokemon, BattleType battleType)
    • startSpectate

      public void startSpectate()
    • endSpectate

      public void endSpectate()
      Causes the player to stop spectating a battle.
    • endUsingBattleCamera

      public void endUsingBattleCamera()
      Switches between a 1st Person and 3rd Person perspective in battle.
    • disableBattleUIButton

      public void disableBattleUIButton()
      Stops/Starts the rendering of the battle UI.
    • onTick

      public void onTick(net.minecraftforge.event.TickEvent.ClientTickEvent event)
      Ticks the battle.
      Parameters:
      event - The triggering tick event.
    • restoreSettingsAndClose

      public void restoreSettingsAndClose()
      Marks the battle as ended.
    • canCatchOpponent

      public boolean canCatchOpponent()
      Checks if the opponent can be caught in a Poké Ball.
      Returns:
      Whether the opponent can be caught in a Poké Ball.
    • canForfeit

      public boolean canForfeit()
    • getViewPlayer

      public net.minecraft.world.entity.player.Player getViewPlayer()
      Gets the player being spectated.
      Returns:
      The player being spectated.
    • startPicking

      public void startPicking(List<Boolean> canSwitch, boolean canFlee, ArrayList<UUID> pokemonToChoose)
      Begins the move picking phase of battle.
      Parameters:
      canSwitch - Whether the Pokémon can switch.
      canFlee - Whether the player can flee from battle.
      pokemonToChoose - A list of Pokémon to choose actions for.
    • selectedMove

      public void selectedMove()
      Handles the selection of an action by the player.
    • selectedMove

      public void selectedMove(boolean isEnforcedSwitch)
      Handles the selection of an action by the player.
      Parameters:
      isEnforcedSwitch - Whether the action was an enforced switch.
    • afkSelectMove

      public void afkSelectMove()
      Chooses a move with the AFK handler.
    • finishSelection

      public void finishSelection()
      Ends the move selection phase and sends the decisions to the server.
    • setTeamPokemon

      public void setTeamPokemon(UUID[] pokemon)
      Sets the Pokémon on the player's side of the battle.
      Parameters:
      pokemon - The Pokémon on the player's side of the battle.
    • setTeamPokemon

      public void setTeamPokemon(PixelmonClientData[] data)
      Sets the Pokémon on the player's side of the battle.
      Parameters:
      data - The Pokémon on the player's side of the battle.
    • setOpponents

      public void setOpponents(PixelmonClientData[] data)
      Sets the Pokémon on the opposing side of the battle.
      Parameters:
      data - The Pokémon on the opposing side of the battle.
    • setTeamData

      public void setTeamData(PixelmonClientData[] data)
      Sets the data for allied Pokémon in battle.
      Parameters:
      data - The allied Pokémon.
    • setFullTeamData

      public void setFullTeamData(PixelmonClientData[] data)
      Sets the data for all our available Pokémon in battle.
      Parameters:
      data - Our available Pokémon.
    • getPokemon

      public PixelmonClientData getPokemon(UUID uuid)
      Gets a Pokémon in the battle the player is in.
      Parameters:
      uuid - The UUID of the Pokémon.
      Returns:
      The Pokémon with the UUID, or null if the UUID is not found.
    • isEnemyPokemon

      public boolean isEnemyPokemon(PixelmonClientData pokemon)
      Checks if the Pokémon is on the opposing side.
      Parameters:
      pokemon - The Pokémon to check.
      Returns:
      Whether the Pokémon is on the opposing side.
    • getBagItems

      public List<ItemData> getBagItems(BagSection section)
    • setCameraToPixelmon

      public void setCameraToPixelmon()
      Keeps the Pokémon camera in third-person mode.
    • setCameraToPlayer

      public void setCameraToPlayer()
      Keeps the player camera in first-person mode.
    • setViewEntity

      public void setViewEntity(net.minecraft.world.entity.Entity entity)
      Sets the camera's focus to an entity.
      Parameters:
      entity - The entity to focus the camera at.
    • getViewEntity

      public net.minecraft.world.entity.Entity getViewEntity()
      Gets the entity the camera is focused on.
      Returns:
      The entity the camera is focused on.
    • resetViewEntity

      public void resetViewEntity()
      Resets the camera to focus on the player.
    • resetAFKTime

      public void resetAFKTime()
      Resets the AFK time limit.
    • setTeamSelectTime

      public void setTeamSelectTime()
      Enables the team select timer if it is active.
    • getLastUsedItemIfStillAvailable

      public Optional<ItemData> getLastUsedItemIfStillAvailable()
    • selectRunAction

      public void selectRunAction(UUID pokemonUUID)
      Attempts to forfeit or flee the battle.
    • canMegaEvolve

      public boolean canMegaEvolve()
      Checks if the player is allowed to Mega Evolve.
      Returns:
      Whether the player is allowed to Mega Evolve.
    • canDynamax

      public boolean canDynamax()
      Checks if the player is allowed to Dynamax.
      Returns:
      Whether the player is allowed to Dynamax.
    • canMegaEvolve

      public boolean canMegaEvolve(PixelmonClientData pig)
      Checks if the player is allowed to Mega Evolve. and the pokemon is capable
      Returns:
      Whether the player is allowed to Mega Evolve.
    • canUltraBurst

      public boolean canUltraBurst()
    • canUltraBurst

      public boolean canUltraBurst(PixelmonClientData pig)
    • canDynamax

      public boolean canDynamax(PixelmonClientData pig)
    • canUseZMove

      public boolean canUseZMove()
    • canUseZMove

      public boolean canUseZMove(PixelmonClientData pig)
    • getPokeballEntity

      public net.minecraft.world.entity.Entity getPokeballEntity()
    • setPokeballEntityId

      public void setPokeballEntityId(int pokeballEntityId)
    • setMode

      public void setMode(BattleMode mode)
    • setMode

      public void setMode(BattleMode mode, BattleMode oldMode)
    • getMode

      public BattleMode getMode()
    • getOldMode

      public BattleMode getOldMode()