Class StandardBattleController
- All Implemented Interfaces:
RegistryBacked,BattleController,BattleEvents,BattleMessaging,BattleRandomContext,BattleSimulationContext,BattleSpectating,BattleStateView,ContextHolder,LegacyBattleAISupport
-
Field Summary
FieldsModifier and TypeFieldDescriptionintTurn counter for individual Pokémon moving within a battle turn.protected AttackDamageCalculatorintThe battle's index in the battle registry.The battle log for the battle.protected intControls when the battle state is checked.intThe number of turns the battle has lasted.The Pokemon that need to be evolvedprotected final StoredContextprotected List<ActiveBattleAnimation> The currently acting pokemon.protected DynamaxControllerController tracking dynamax potential during multi-battles.protected final List<FutureBattleTask<?, ?>> Global conditions (e.g., weather) currently active in the battle.booleanWhether a Pokémon has switched due to a move.The most recent attack used during the battle.The most recent attack used while simulating the battle.The most recent temp attack while simulating the battle.The most recent temp attack used during the battle.protected List<BattleParticipant> protected BattleRandomnessprotected net.minecraft.core.RegistryAccessThe battle rules that are in effect for the battle.Spectators of the battleprotected List<List<BattleParticipant>> protected int -
Constructor Summary
ConstructorsConstructorDescriptionStandardBattleController(BattleParticipant[] team1, BattleParticipant[] team2, net.minecraft.core.RegistryAccess registryAccess) StandardBattleController(BattleParticipant[] team1, BattleParticipant[] team2, net.minecraft.core.RegistryAccess registryAccess, Consumer<StandardBattleController> setupLogic) -
Method Summary
Modifier and TypeMethodDescriptionvoidacknowledgeBattleAnimation(net.minecraft.server.level.ServerPlayer player, UUID acknowledgementId) Acknowledges completion of a client-side battle animation wait.intReturns the current action index within the active turn.voidaddBattleAnimation(ActiveBattleAnimation animation) Stores a battle animation that is currently running for this battle.<E extends BattleEvent,A>
CompletableFuture<A> addFunctionAtEvent(Class<E> eventClass, BiFunction<E, BattleController, A> task) Adds a one-shot function to run the next time the specified event type is published.<E extends BattleEvent>
voidaddPersistentTaskAtEvent(Class<E> eventClass, BiConsumer<E, BattleController> task) Adds a persistent task to run every time the specified event type is published.<E extends BattleEvent>
CompletableFuture<Void> addTaskAtEvent(Class<E> eventClass, BiConsumer<E, BattleController> task) Adds a one-shot task to run the next time the specified event type is published.voidbattleAnimationChannelId(String battleAnimationChannelId) intReturns this battle's index.voidbattleIndex(int battleIndex) Sets this battle's index.Returns the battle log for this battle.intReturns the number of times the current battle has been ticked.intReturns the current battle turn number.voidbroadcastPacket(PixelmonPacket packet) Broadcasts a battle packet to all relevant battle clients.voidChecks if a participant has been defeated, updates theBattleParticipant.isDefeatedvalue, and notifies other participants of the battle that the participant is out of usable Pokémon.This method returns a set of Pokémon that need to be evolved at the end of the turn.voidChecks the conditions of the active Pokémon.booleancheckReviveSendOut(BattleParticipant participant) Checks if a Pokémon can be sent out after being revived.voidcheckTeamDefeated(BattleParticipant battleParticipant) Checks if the team of the given BattleParticipant has been defeated, and if so, will post theLostToWildPixelmonEventif a player lost to a Wild Pixelmon, revent a player that lost from receiving money from a battle, and will then end the battle.voidcleanUpBattleAnimationChannel(String channel) copy()Creates a copy of this battle controller.voidcurrentlyActingPokemon(PixelmonWrapper currentlyActingPokemon) voidvoidbooleanChecks whether the battle controller is performing hard swaps causing aligned switch-in effectsendBattle(BattleEndCause cause, Map<BattleParticipant, BattleResults> results) Ends the battle with the given cause and any precalculated results.voidendPause()Unpauses the battle.voidendTurn()Handles end-of-turn effects.Returns the attack damage calculator used by this battle.getOpponentPokemon(BattleParticipant participant) Returns all Pokemon on the opposite side of the battle that the specified participant is on.getStage()Returns the current stage of the battle.List<net.minecraft.server.level.ServerPlayer> Gets a list of all players that are viewing the battle
This includes all players that are in the battle as well as spectatorsReturns the controller for global battle statuses.protected voidThe primary use of this function is to callAbility.applyStartOfBattleHeadOfPartyEffect(Pokemon, PixelmonWrapper), which is primarily used for Synchronize's out-of-battle effect.booleanbooleanThis method returns if a Pokémon has switched due to a move during this move.voidhasSwitchedDuringThisMove(boolean hasSwitchedDuringThisMove) This method sets whether a Pokémon has switched due to a move during this move.protected voidInitiates the battle.booleanisBattleAnimationChannelBusy(String channel) booleanisOneAlive(List<PixelmonWrapper> teamPokemon) Checks whether there is a non-fainted Pokémon among the given Pokémon list.booleanisSpectating(net.minecraft.world.entity.player.Player player) Returns whether the specified player is currently spectating this battle.voidlastAttack(Attack attack) voidlastSimulatedAttack(Attack attack) voidlastSimulatedTempAttack(Attack attack) voidlastTempAttack(Attack attack) voidmodifyStatsCancellable(PixelmonWrapper attacker) Modifies Pokémon stats during a turn after deciding which Pokémon gets to make a move.oldGen()Returns the old-generation rules state for this battle.voidSets the old-generation rules state for this battle.outcome()Returns whether this battle has ended.booleanChecks if a participant is capable of dynamaxing and that it is their turn.voidAlerted from a packet received from a participant that they have viewed all the battle messages and the next sub-turn can begin.Returns the participants in this battle.voidPauses the battle.<T extends BattleEvent>
TpublishEvent(T event) Publishes a battle event.Returns the battle randomness provider used by this battle.voidrecordFaintOrder(PixelmonWrapper target, PixelmonWrapper source, DamageTypeEnum damageType) Records a faint after all cancellable faint hooks have completed successfully.net.minecraft.core.RegistryAccessReturns the backing registry access used to resolve registries and entries.booleanremoveSpectator(net.minecraft.server.level.ServerPlayer player) Removes a player from this battle's spectators.voidreserveFaintOrder(PixelmonWrapper target, PixelmonWrapper source, DamageTypeEnum damageType) Reserves this position in the faint order for effects whose user faints before their target, such as Self-Destruct and Final Gambit.voidreserveFaintOrderBefore(PixelmonWrapper target, PixelmonWrapper beforeTarget, PixelmonWrapper source, DamageTypeEnum damageType) Reserves a faint immediately before an existing faint.voidFinds any statuses affecting the whole team and determines where a Pokémon being sent into battle should be positioned.voidsetAttackDamageCalculator(AttackDamageCalculator attackDamageCalculator) Sets the attack damage calculator used by this battle.voidSets a Pokémon to flee in the turn.booleanThis function first checks if there is no weather (i.e.voidsetRandomness(BattleRandomness randomness) Sets the battle randomness provider used by this battle.booleanDetermines whether participant initialization should emit battle start packets directly.voidshouldSendBattleStartPackets(boolean shouldSendBattleStartPackets) Sets whether participant initialization should emit battle start packets directly.booleanReturns whether this battle is currently running in the legacy AI simulation mode.voidsimulateMode(boolean simulateMode) Sets whether this battle is currently running in the legacy AI simulation mode.booleanReturns whether the legacy AI should use simulated stat handling for this battle.voidsimulateStats(boolean simulateStats) Sets whether the legacy AI should use simulated stat handling for this battle.voidspectate(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.entity.Entity target) Adds a player as a spectator of this battle.Returns the spectators currently watching this battle.voidstoreSwitchInActivation(PixelmonWrapper pw, PixelmonWrapper former) voidswitchPokemon(UUID switchingPokemonUUID, UUID newPokemonUUID, boolean switchInstantly) Switches a Pokémon out for a different one.teams()Returns the battle participants grouped by team.voidMoves pokemon to end of list of pokemon gaining their abilitiesbooleanChecks whether the specified Pokémon will try to flee.booleantryFlee(PixelmonWrapper p, boolean turnEnd) Checks if the given Pokemon will try to flee.turnList()This method returns the order of Pokémon moving during a battle turn.voidturnList(List<PixelmonWrapper> turnList) This method sets the order of Pokémon moving during a battle turn.voidupdate()Updates the battle every tick.voidUpdates the battle every tick.intReturns the number of battle ticks this battle must wait before normal turn progression can continue.voidwaitTicks(int waitTicks) Sets the number of battle ticks this battle must wait before normal turn progression can continue.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.pixelmonmod.pixelmon.battles.controller.BattleController
advanceToMoves, checkValid, clearHurtTimer, consumeAllItems, enableReturnHeldItems, endBattle, endBattle, endBattleWithoutXP, forfeitBattleForPlayerAndTheirTeam, getAbilityIfPresent, getDefaultTurnOrder, getFirstMover, getFirstMover, getLastMover, getLastMover, getPokemonAtPosition, getPokemonWithAbility, getPositionOfPokemon, getPositionOfPokemon, getTurn, getTurnForPokemon, isLastMover, modifyStats, publishPokemonHealthUpdate, publishRevivedPokemonEvent, publishSwitchPokemonEvent, removeFromTurnList, removePlayer, sendBattleScenePacket, sendBattleScenePackets, setAllReady, setUseItem, setUseItem, spawnEntityForBattle, sync, takeFullTurn, takeFullTurn, updateRemovedPokemonMethods inherited from interface com.pixelmonmod.pixelmon.battles.controller.BattleMessaging
sendToAll, sendToAll, sendToOthers, sendToOthers, sendToPlayer, updateFormChangeMethods inherited from interface com.pixelmonmod.pixelmon.battles.controller.BattleRandomContext
forceChance, forceChance, setRandom, shouldForceChanceMethods inherited from interface com.pixelmonmod.pixelmon.battles.controller.BattleSimulationContext
disableCommunication, freeze, isFrozen, isLevelingDisabled, isSimulatedBattle, shouldSpawnEntities, unfreezeMethods inherited from interface com.pixelmonmod.pixelmon.battles.controller.BattleStateView
battleEnded, battleTicksPerSecond, containsParticipantType, getActiveFaintedPokemon, getActivePokemon, getActiveUnfaintedPokemon, getBattleType, getParticipantForEntity, getParticipantFromPokemon, getParticipants, getPartyPokemonFromUUID, getPlayer, getPlayer, getPlayerEntities, getPlayers, getPokemonFromUUID, isInverseBattle, isPvE, isPvP, isRaid, isTeamDefeated, isTeamHomogeneous, isWaiting, onBattlefield, otherParticipant, playerCount, team, timeElapsedMethods inherited from interface com.pixelmonmod.pixelmon.battles.controller.context.ContextHolder
get, getOrDefault, has, remove, set, updateMethods inherited from interface com.pixelmonmod.pixelmon.api.registry.RegistryBacked
holder, registry, registryValue
-
Field Details
-
participants
-
teams
-
globalStatusController
Global conditions (e.g., weather) currently active in the battle. -
spectators
Spectators of the battle -
battleTicks
protected int battleTicksControls when the battle state is checked. -
battleTurn
public int battleTurnThe number of turns the battle has lasted. -
ticks
protected int ticks -
battleIndex
public int battleIndexThe battle's index in the battle registry. -
battleLog
The battle log for the battle. -
lastAttack
The most recent attack used during the battle. -
lastSimulatedAttack
The most recent attack used while simulating the battle. -
lastTempAttack
The most recent temp attack used during the battle. -
lastSimulatedTempAttack
The most recent temp attack while simulating the battle. -
rules
The battle rules that are in effect for the battle. -
dynamaxController
Controller tracking dynamax potential during multi-battles. -
hasSwitchedDuringThisMove
public boolean hasSwitchedDuringThisMoveWhether a Pokémon has switched due to a move. Only one Pokémon may switch per move. -
currentAnimations
-
checkedPokemon
The Pokemon that need to be evolved -
futureTasks
-
randomness
-
attackDamageCalculator
-
registryAccess
protected net.minecraft.core.RegistryAccess registryAccess -
context
-
actionIndex
public int actionIndexTurn counter for individual Pokémon moving within a battle turn. -
currentlyActingPokemon
The currently acting pokemon. -
turnList
-
-
Constructor Details
-
StandardBattleController
public StandardBattleController(BattleParticipant[] team1, BattleParticipant[] team2, net.minecraft.core.RegistryAccess registryAccess) -
StandardBattleController
public StandardBattleController(BattleParticipant[] team1, BattleParticipant[] team2, net.minecraft.core.RegistryAccess registryAccess, Consumer<StandardBattleController> setupLogic)
-
-
Method Details
-
battleTicks
public int battleTicks()Description copied from interface:BattleStateViewReturns the number of times the current battle has been ticked.
This may be incremented multiple times per-server tick depending on the controller's battle tick rate. So this is not necessarily equal to 20 times a second.
To get the number of battle ticks per second, useBattleStateView.battleTicksPerSecond().- Specified by:
battleTicksin interfaceBattleStateView- Returns:
- the current battle tick
-
initBattle
Initiates the battle.- Throws:
IllegalStateException- If any participants have invalid pokemon this will get thro0wn
-
handleSetupForStartOfBattleHeadOfPartyEffect
The primary use of this function is to callAbility.applyStartOfBattleHeadOfPartyEffect(Pokemon, PixelmonWrapper), which is primarily used for Synchronize's out-of-battle effect.- Parameters:
p- A participant of the battle
-
doLater
-
update
public void update()Description copied from interface:BattleControllerUpdates the battle every tick.- Specified by:
updatein interfaceBattleController
-
doTurnLogic
public void doTurnLogic()- Specified by:
doTurnLogicin interfaceBattleController
-
updateTurnZero
public void updateTurnZero()Updates the battle every tick. Called before any Pokémon makes an attack for that turn. -
modifyStatsCancellable
Description copied from interface:BattleControllerModifies Pokémon stats during a turn after deciding which Pokémon gets to make a move.- Specified by:
modifyStatsCancellablein interfaceBattleController- Parameters:
attacker- The Pokémon using a move.
-
participantReady
Alerted from a packet received from a participant that they have viewed all the battle messages and the next sub-turn can begin.- Parameters:
p- The player.
-
endTurn
public void endTurn()Description copied from interface:BattleControllerHandles end-of-turn effects.- Specified by:
endTurnin interfaceBattleController
-
checkReviveSendOut
Checks if a Pokémon can be sent out after being revived.- Parameters:
participant- The participant to check for sending out a revived Pokémon.- Returns:
- True if a revived Pokémon can be sent out onto the battlefield.
-
reviveAfterDefeat
Description copied from interface:BattleControllerFinds any statuses affecting the whole team and determines where a Pokémon being sent into battle should be positioned. Then sends out the newly revived Pokémon as an entity if it can, and sets the revived Pokémon's battle position, sets it as on the battlefield and applies the statuses. Finally, triggers some affects that occur when a Pokémon switches in.- Specified by:
reviveAfterDefeatin interfaceBattleController- Parameters:
p- the trainer that needs to send out a now revived Pokémon.
-
endBattle
public Map<BattleParticipant,BattleResults> endBattle(BattleEndCause cause, Map<BattleParticipant, BattleResults> results) Description copied from interface:BattleControllerEnds the battle with the given cause and any precalculated results. This method is called by ALL other end of battle methods.- Specified by:
endBattlein interfaceBattleController
-
participantCanDynamax
Description copied from interface:BattleControllerChecks if a participant is capable of dynamaxing and that it is their turn.- Specified by:
participantCanDynamaxin interfaceBattleController
-
timedAbilityStarted
Description copied from interface:BattleControllerMoves pokemon to end of list of pokemon gaining their abilities- Specified by:
timedAbilityStartedin interfaceBattleController
-
getPokemonOrderedByAbilityGain
- Specified by:
getPokemonOrderedByAbilityGainin interfaceBattleController
-
tryFlee
Checks whether the specified Pokémon will try to flee.- Parameters:
p- The Pokémon to check.- Returns:
- Whether the Pokémon will try to flee.
-
tryFlee
Checks if the given Pokemon will try to flee.- Parameters:
p- The pokemon being checkedturnEnd- If it's turn end (i.e. don't look back to see if they've already had their turn)- Returns:
- true if the pokemon will try fleeing
-
reserveFaintOrder
public void reserveFaintOrder(PixelmonWrapper target, PixelmonWrapper source, DamageTypeEnum damageType) Description copied from interface:BattleControllerReserves this position in the faint order for effects whose user faints before their target, such as Self-Destruct and Final Gambit.- Specified by:
reserveFaintOrderin interfaceBattleController
-
reserveFaintOrderBefore
public void reserveFaintOrderBefore(PixelmonWrapper target, PixelmonWrapper beforeTarget, PixelmonWrapper source, DamageTypeEnum damageType) Description copied from interface:BattleControllerReserves a faint immediately before an existing faint. This is used by effects such as Innards Out whose owner wins if its retaliation knocks out both final Pokémon.- Specified by:
reserveFaintOrderBeforein interfaceBattleController
-
recordFaintOrder
public void recordFaintOrder(PixelmonWrapper target, PixelmonWrapper source, DamageTypeEnum damageType) Description copied from interface:BattleControllerRecords a faint after all cancellable faint hooks have completed successfully.- Specified by:
recordFaintOrderin interfaceBattleController
-
checkPokemon
public void checkPokemon()Description copied from interface:BattleControllerChecks the conditions of the active Pokémon.- Specified by:
checkPokemonin interfaceBattleController
-
isOneAlive
Checks whether there is a non-fainted Pokémon among the given Pokémon list.- Parameters:
teamPokemon- The list of Pokémon to check.- Returns:
- Whether there is a non-fainted Pokémon.
-
checkDefeated
Checks if a participant has been defeated, updates theBattleParticipant.isDefeatedvalue, and notifies other participants of the battle that the participant is out of usable Pokémon.- Parameters:
p- The participant to check.
-
checkTeamDefeated
Checks if the team of the given BattleParticipant has been defeated, and if so, will post theLostToWildPixelmonEventif a player lost to a Wild Pixelmon, revent a player that lost from receiving money from a battle, and will then end the battle.- Parameters:
battleParticipant- The object that represents the owner of a team of Pokémon.
-
switchPokemon
Description copied from interface:BattleControllerSwitches a Pokémon out for a different one.- Specified by:
switchPokemonin interfaceBattleController- Parameters:
switchingPokemonUUID- The Pokémon switching out.newPokemonUUID- The Pokémon to switch into.switchInstantly- True if the switch will happen immediately, false if the switch will happen during the turn.
-
storeSwitchInActivation
- Specified by:
storeSwitchInActivationin interfaceBattleController
-
setFlee
Description copied from interface:BattleControllerSets a Pokémon to flee in the turn.- Specified by:
setFleein interfaceBattleController- Parameters:
fleeingUUID- The fleeing Pokémon.
-
getOpponentPokemon
Returns all Pokemon on the opposite side of the battle that the specified participant is on.- Parameters:
participant- The participant to find opponent Pokemon for.- Returns:
- A list of all Pokemon on the opposite of the battle that the participant is on.
-
spectators
Description copied from interface:BattleSpectatingReturns the spectators currently watching this battle.The returned list may be backed by the live battle state. Callers should avoid mutating it directly unless they are part of battle-controller internals.
- Specified by:
spectatorsin interfaceBattleSpectating- Returns:
- the current battle spectators
-
getViewingPlayers
Gets a list of all players that are viewing the battle
This includes all players that are in the battle as well as spectators- Returns:
- A list of all players that are viewing the battle
-
broadcastPacket
Description copied from interface:BattleMessagingBroadcasts a battle packet to all relevant battle clients.Implementations should avoid sending packets when battle communication is disabled.
- Specified by:
broadcastPacketin interfaceBattleMessaging- Parameters:
packet- the packet to broadcast
-
getStage
Description copied from interface:BattleStateViewReturns the current stage of the battle.- Specified by:
getStagein interfaceBattleStateView- Returns:
- the current battle stage
-
spectate
public void spectate(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.entity.Entity target) Description copied from interface:BattleSpectatingAdds a player as a spectator of this battle.The target entity is used as the entity the player is spectating from or tracking when they begin watching the battle.
- Specified by:
spectatein interfaceBattleSpectating- Parameters:
player- the player to add as a spectatortarget- the battle-related entity being spectated or tracked
-
isSpectating
public boolean isSpectating(net.minecraft.world.entity.player.Player player) Description copied from interface:BattleSpectatingReturns whether the specified player is currently spectating this battle.- Specified by:
isSpectatingin interfaceBattleSpectating- Parameters:
player- the player to check- Returns:
trueif the player is spectating this battle;falseotherwise
-
removeSpectator
public boolean removeSpectator(net.minecraft.server.level.ServerPlayer player) Description copied from interface:BattleSpectatingRemoves a player from this battle's spectators.- Specified by:
removeSpectatorin interfaceBattleSpectating- Parameters:
player- the spectator to remove- Returns:
trueif the player was spectating this battle and was removed;falseotherwise
-
duringSwitchAction
public boolean duringSwitchAction()Description copied from interface:BattleControllerChecks whether the battle controller is performing hard swaps causing aligned switch-in effects- Specified by:
duringSwitchActionin interfaceBattleController- Returns:
- whether the controller is occupied with hard switches
-
getLastAttack
- Specified by:
getLastAttackin interfaceBattleController
-
getLastTempAttack
- Specified by:
getLastTempAttackin interfaceBattleController
-
setOverworldWeatherAsBattleWeatherDuringBattle
public boolean setOverworldWeatherAsBattleWeatherDuringBattle()This function first checks if there is no weather (i.e. the weather is Clear) or if the current battle weather represented the Minecraft Overworld. If either of those conditions are true, it rechecks what the current Minecraft weather is and changes the battle weather to that if necessary.- Returns:
- Whether the weather was changed mid-battle.
-
addFunctionAtEvent
public <E extends BattleEvent,A> CompletableFuture<A> addFunctionAtEvent(Class<E> eventClass, BiFunction<E, BattleController, A> task) Description copied from interface:BattleEventsAdds a one-shot function to run the next time the specified event type is published.The returned future is completed with the function result after the task has executed. Once executed, the task is removed and will not run for later events of the same type.
- Specified by:
addFunctionAtEventin interfaceBattleEvents- Type Parameters:
E- the battle event typeA- the function result type- Parameters:
eventClass- the event type to wait fortask- the function to execute when the event is published- Returns:
- a future completed with the function result when the task runs
-
addTaskAtEvent
public <E extends BattleEvent> CompletableFuture<Void> addTaskAtEvent(Class<E> eventClass, BiConsumer<E, BattleController> task) Description copied from interface:BattleEventsAdds a one-shot task to run the next time the specified event type is published.The returned future is completed after the task has executed. Once executed, the task is removed and will not run for later events of the same type.
- Specified by:
addTaskAtEventin interfaceBattleEvents- Type Parameters:
E- the battle event type- Parameters:
eventClass- the event type to wait fortask- the task to execute when the event is published- Returns:
- a future completed when the task has run
-
addPersistentTaskAtEvent
public <E extends BattleEvent> void addPersistentTaskAtEvent(Class<E> eventClass, BiConsumer<E, BattleController> task) Description copied from interface:BattleEventsAdds a persistent task to run every time the specified event type is published.Persistent tasks are not removed after execution and do not expose a future, because they may run multiple times over the lifetime of the battle.
- Specified by:
addPersistentTaskAtEventin interfaceBattleEvents- Type Parameters:
E- the battle event type- Parameters:
eventClass- the event type to listen fortask- the task to execute each time the event is published
-
registryAccess
public net.minecraft.core.RegistryAccess registryAccess()Description copied from interface:RegistryBackedReturns the backing registry access used to resolve registries and entries.- Specified by:
registryAccessin interfaceRegistryBacked- Returns:
- the registry access for this object
-
getContext
- Specified by:
getContextin interfaceContextHolder
-
publishEvent
Description copied from interface:BattleEventsPublishes a battle event.Publishing an event should run any one-shot or persistent tasks waiting for that event type, and should also pass the event through the normal Pixelmon event pipeline where applicable. The returned event may have been modified by listeners.
- Specified by:
publishEventin interfaceBattleEvents- Type Parameters:
T- the battle event type- Parameters:
event- the event to publish- Returns:
- the published event, potentially modified by listeners
-
copy
Description copied from interface:BattleSimulationContextCreates a copy of this battle controller.The returned battle is intended for systems that need to evaluate or simulate battle outcomes without directly mutating the original battle. The exact copied state depends on the backing
BattleControllerimplementation.- Specified by:
copyin interfaceBattleSimulationContext- Returns:
- a copied battle controller
-
getAttackDamageCalculator
Description copied from interface:BattleRandomContextReturns the attack damage calculator used by this battle.The damage calculator controls how the attack damage random multiplier is resolved. Different implementations may use normal random damage rolls, average damage, minimum damage, maximum damage, or another deterministic strategy for simulations and tests.
- Specified by:
getAttackDamageCalculatorin interfaceBattleRandomContext- Returns:
- the attack damage calculator
-
setAttackDamageCalculator
Description copied from interface:BattleRandomContextSets the attack damage calculator used by this battle.- Specified by:
setAttackDamageCalculatorin interfaceBattleRandomContext- Parameters:
attackDamageCalculator- the attack damage calculator to use
-
randomness
Description copied from interface:BattleRandomContextReturns the battle randomness provider used by this battle.The randomness provider should be used by battle logic for random battle behaviour so live battles, tests, and simulations can control randomness consistently.
- Specified by:
randomnessin interfaceBattleRandomContext- Returns:
- the battle randomness provider
-
setRandomness
Description copied from interface:BattleRandomContextSets the battle randomness provider used by this battle.- Specified by:
setRandomnessin interfaceBattleRandomContext- Parameters:
randomness- the battle randomness provider to use
-
hasInitialized
public boolean hasInitialized() -
waitTicks
public int waitTicks()Description copied from interface:BattleSimulationContextReturns the number of battle ticks this battle must wait before normal turn progression can continue.- Specified by:
waitTicksin interfaceBattleSimulationContext- Returns:
- remaining wait ticks
-
waitTicks
public void waitTicks(int waitTicks) Description copied from interface:BattleSimulationContextSets the number of battle ticks this battle must wait before normal turn progression can continue.- Specified by:
waitTicksin interfaceBattleSimulationContext- Parameters:
waitTicks- remaining wait ticks
-
shouldSendBattleStartPackets
public boolean shouldSendBattleStartPackets()Description copied from interface:BattleControllerDetermines whether participant initialization should emit battle start packets directly. Multi-lane battles disable this on their lane controllers so the parent controller can send a single packet with the full cross-lane battle view.- Specified by:
shouldSendBattleStartPacketsin interfaceBattleController- Returns:
- Whether this controller should send battle start packets from its participants.
-
shouldSendBattleStartPackets
public void shouldSendBattleStartPackets(boolean shouldSendBattleStartPackets) Description copied from interface:BattleControllerSets whether participant initialization should emit battle start packets directly.- Specified by:
shouldSendBattleStartPacketsin interfaceBattleController- Parameters:
shouldSendBattleStartPackets- Whether this controller should send battle start packets.
-
globalStatusController
Description copied from interface:BattleStateViewReturns the controller for global battle statuses.- Specified by:
globalStatusControllerin interfaceBattleStateView- Returns:
- the global status controller
-
battleLog
Description copied from interface:BattleStateViewReturns the battle log for this battle.- Specified by:
battleLogin interfaceBattleStateView- Returns:
- the battle log
-
outcome
Description copied from interface:BattleStateViewReturns whether this battle has ended.- Specified by:
outcomein interfaceBattleStateView- Returns:
trueif the battle has ended;falseotherwise
-
battleTurn
public int battleTurn()Description copied from interface:BattleStateViewReturns the current battle turn number.- Specified by:
battleTurnin interfaceBattleStateView- Returns:
- the current battle turn
-
participants
Description copied from interface:BattleStateViewReturns the participants in this battle.The returned list may be backed by the live battle state. Callers should avoid mutating it unless they are part of battle-controller internals.
- Specified by:
participantsin interfaceBattleStateView- Returns:
- the battle participants
-
teams
Description copied from interface:BattleStateViewReturns the battle participants grouped by team.The returned lists may be backed by the live battle state. Callers should avoid mutating them unless they are part of battle-controller internals.
- Specified by:
teamsin interfaceBattleStateView- Returns:
- the battle teams
-
simulateMode
public boolean simulateMode()Description copied from interface:LegacyBattleAISupportReturns whether this battle is currently running in the legacy AI simulation mode.This flag is only used by the legacy
BattleAI.ADVANCED,BattleAI.TACTICAL, andBattleAI.AGGRESSIVEimplementations. New simulation-aware code should use the battle context instead.- Specified by:
simulateModein interfaceLegacyBattleAISupport- Returns:
trueif the battle is being simulated by legacy AI logic;falseotherwise
-
simulateMode
public void simulateMode(boolean simulateMode) Description copied from interface:LegacyBattleAISupportSets whether this battle is currently running in the legacy AI simulation mode.- Specified by:
simulateModein interfaceLegacyBattleAISupport- Parameters:
simulateMode- whether the battle should be treated as simulated by legacy AI logic
-
simulateStats
public boolean simulateStats()Description copied from interface:LegacyBattleAISupportReturns whether the legacy AI should use simulated stat handling for this battle.This is an artifact of the older battle AI system. It is separate from the modern battle context simulation flag and does not represent a general-purpose battle state setting.
- Specified by:
simulateStatsin interfaceLegacyBattleAISupport- Returns:
trueif legacy AI stat simulation handling is enabled;falseotherwise
-
simulateStats
public void simulateStats(boolean simulateStats) Description copied from interface:LegacyBattleAISupportSets whether the legacy AI should use simulated stat handling for this battle.- Specified by:
simulateStatsin interfaceLegacyBattleAISupport- Parameters:
simulateStats- whether legacy AI stat simulation handling should be enabled
-
addBattleAnimation
Description copied from interface:BattleControllerStores a battle animation that is currently running for this battle.- Specified by:
addBattleAnimationin interfaceBattleController- Parameters:
animation- The animation to store
-
isBattleAnimationChannelBusy
- Specified by:
isBattleAnimationChannelBusyin interfaceBattleController
-
cleanUpBattleAnimationChannel
- Specified by:
cleanUpBattleAnimationChannelin interfaceBattleController
-
acknowledgeBattleAnimation
public void acknowledgeBattleAnimation(net.minecraft.server.level.ServerPlayer player, UUID acknowledgementId) Description copied from interface:BattleControllerAcknowledges completion of a client-side battle animation wait.- Specified by:
acknowledgeBattleAnimationin interfaceBattleController- Parameters:
player- the client that acknowledged the animationacknowledgementId- the acknowledgement token sent to the client
-
actionIndex
public int actionIndex()Description copied from interface:BattleStateViewReturns the current action index within the active turn.This is used while resolving turn actions to identify which action or Pokémon is currently being processed.
- Specified by:
actionIndexin interfaceBattleStateView- Returns:
- the current action index
-
battleIndex
public int battleIndex()Description copied from interface:BattleStateViewReturns this battle's index.- Specified by:
battleIndexin interfaceBattleStateView- Returns:
- the battle index
-
battleIndex
public void battleIndex(int battleIndex) Description copied from interface:BattleStateViewSets this battle's index.- Specified by:
battleIndexin interfaceBattleStateView- Parameters:
battleIndex- the battle index
-
battleAnimationChannelId
- Specified by:
battleAnimationChannelIdin interfaceBattleController
-
battleAnimationChannelId
- Specified by:
battleAnimationChannelIdin interfaceBattleController
-
turnList
Description copied from interface:BattleControllerThis method returns the order of Pokémon moving during a battle turn.- Specified by:
turnListin interfaceBattleController- Returns:
- The order of Pokémon moving during a battle turn.
-
turnList
Description copied from interface:BattleControllerThis method sets the order of Pokémon moving during a battle turn.- Specified by:
turnListin interfaceBattleController- Parameters:
turnList- The order of Pokémon moving during a battle turn.
-
hasSwitchedDuringThisMove
public void hasSwitchedDuringThisMove(boolean hasSwitchedDuringThisMove) Description copied from interface:BattleControllerThis method sets whether a Pokémon has switched due to a move during this move. This is used to prevent multiple Pokémon from switching out during one move, such as with moves like U-Turn or Volt Switch. Only one Pokémon may switch per move.- Specified by:
hasSwitchedDuringThisMovein interfaceBattleController- Parameters:
hasSwitchedDuringThisMove- If a Pokémon has switched due to a move during this move.
-
hasSwitchedDuringThisMove
public boolean hasSwitchedDuringThisMove()Description copied from interface:BattleControllerThis method returns if a Pokémon has switched due to a move during this move. This is used to prevent multiple Pokémon from switching out during one move, such as with moves like U-Turn or Volt Switch. Only one Pokémon may switch per move.- Specified by:
hasSwitchedDuringThisMovein interfaceBattleController- Returns:
- If a Pokémon has switched due to a move during this move.
-
endPause
public void endPause()Description copied from interface:BattleControllerUnpauses the battle.- Specified by:
endPausein interfaceBattleController
-
pauseBattle
public void pauseBattle()Description copied from interface:BattleControllerPauses the battle.- Specified by:
pauseBattlein interfaceBattleController
-
oldGen
Description copied from interface:BattleStateViewReturns the old-generation rules state for this battle.- Specified by:
oldGenin interfaceBattleStateView- Returns:
- the old-generation rules state
-
oldGen
Description copied from interface:BattleStateViewSets the old-generation rules state for this battle.- Specified by:
oldGenin interfaceBattleStateView- Parameters:
oldGen- the old-generation rules state
-
lastAttack
- Specified by:
lastAttackin interfaceBattleController
-
lastAttack
- Specified by:
lastAttackin interfaceBattleController
-
lastTempAttack
- Specified by:
lastTempAttackin interfaceBattleController
-
lastTempAttack
- Specified by:
lastTempAttackin interfaceBattleController
-
lastSimulatedAttack
- Specified by:
lastSimulatedAttackin interfaceBattleController
-
lastSimulatedAttack
- Specified by:
lastSimulatedAttackin interfaceBattleController
-
lastSimulatedTempAttack
- Specified by:
lastSimulatedTempAttackin interfaceBattleController
-
lastSimulatedTempAttack
- Specified by:
lastSimulatedTempAttackin interfaceBattleController
-
checkedPokemon
Description copied from interface:BattleControllerThis method returns a set of Pokémon that need to be evolved at the end of the turn. This is used to keep track of Pokémon that need to be evolved at the end of the turn after all actions have been resolved, so that they can be evolved before the next turn starts.- Specified by:
checkedPokemonin interfaceBattleController- Returns:
- A set of Pokémon that need to be evolved at the end of the turn.
-
currentlyActingPokemon
- Specified by:
currentlyActingPokemonin interfaceBattleController
-
currentlyActingPokemon
- Specified by:
currentlyActingPokemonin interfaceBattleController
-