Interface BattleAction

All Known Implementing Classes:
AttackBattleAction, DynamaxCheerBattleAction, StruggleBattleAction, SwitchBattleAction, TeraCheerBattleAction, UseBagItemBattleAction

public interface BattleAction
A client-requested battle action that can validate and apply itself on the server.

Actions are transport-safe descriptions of a requested choice, such as an attack, switch, bag item, or raid cheer. They must never treat client input as authoritative. Each concrete action is responsible for resolving the current server-side battle state, checking that the requested choice is still legal, and only then mutating the battle.

The action type is registry-backed so new battle action implementations can be added without changing the packet format used by BattleActionPacket.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,BattleAction>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    execute(BattleController battleController, BattleParticipant participant)
    Applies this action to the supplied battle if the current server state allows it.
    default net.minecraft.resources.ResourceLocation
    id()
    Gets this action's registered id.
    default net.minecraft.resources.ResourceKey<BattleActionType<?>>
    Gets this action's registry key.
    Gets the registered type used to encode and decode this action.
  • Field Details

    • CODEC

      static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,BattleAction> CODEC
  • Method Details

    • type

      BattleActionType<? extends BattleAction> type()
      Gets the registered type used to encode and decode this action.
      Returns:
      The battle action type.
    • execute

      boolean execute(BattleController battleController, BattleParticipant participant)
      Applies this action to the supplied battle if the current server state allows it.

      Callers must only invoke this with a resolved battle and participant.

      Parameters:
      battleController - The battle receiving the action.
      participant - The player's participant in the battle.
      Returns:
      true if the action was accepted and applied.
    • registryKey

      default net.minecraft.resources.ResourceKey<BattleActionType<?>> registryKey()
      Gets this action's registry key.
      Returns:
      The registry key for type().
    • id

      default net.minecraft.resources.ResourceLocation id()
      Gets this action's registered id.
      Returns:
      The registry id for type().