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
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, BattleAction> -
Method Summary
Modifier and TypeMethodDescriptionbooleanexecute(BattleController battleController, BattleParticipant participant) Applies this action to the supplied battle if the current server state allows it.default net.minecraft.resources.ResourceLocationid()Gets this action's registered id.default net.minecraft.resources.ResourceKey<BattleActionType<?>> Gets this action's registry key.BattleActionType<? extends BattleAction> type()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
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:
trueif the action was accepted and applied.
-
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().
-