Interface ClientPreAttackCallback
public interface ClientPreAttackCallback
This event fires every tick when the attack key (left mouse button by default) is pressed
(including clicking and holding the attack key).
If the callback returns true,
the vanilla handling (block breaking, entity attacking, hand swing) will be cancelled,
and the later callbacks of this event are also cancelled.
This event is client-only, which means handling it may require sending custom packets.
The event fires both when clicking and holding attack key.
To check whether the attack key is just clicked, use clickCount != 0
The vanilla attack cooldown and player game mode does not affect this event.
The mod probably needs to check MinecraftClient.attackCooldown
and the game mode.
ItemCooldownManager
can be used for custom item cooldown handling.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
onClientPlayerPreAttack
(MinecraftClient client, ClientPlayerEntity player, int clickCount)
-
Field Details
-
EVENT
-
-
Method Details
-
onClientPlayerPreAttack
- Parameters:
player
- the client playerclickCount
- the click count of the attack key in this tick.- Returns:
- whether to intercept attack handling
-