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 Minecraft.missTime and the game mode.
ItemCooldowns can be used for custom item cooldown handling.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanonClientPlayerPreAttack(net.minecraft.client.Minecraft client, net.minecraft.client.player.LocalPlayer player, int clickCount)
-
Field Details
-
EVENT
-
-
Method Details
-
onClientPlayerPreAttack
boolean onClientPlayerPreAttack(net.minecraft.client.Minecraft client, net.minecraft.client.player.LocalPlayer player, int clickCount) - Parameters:
player- the client playerclickCount- the click count of the attack key in this tick.- Returns:
- whether to intercept attack handling
-