#Server-side hook into ALL player attacks

20 messages · Page 1 of 1 (latest)

viscid spear
#

There are Fabric API events for attacking a block or an entity, but I'd also like to hook into attacks on nothing. Specifically I'm trying to allow players to interact with display entities, which have no hitbox and require special hit-testing math due to their transform.

limber garnet
#

@spark heron more specific question here ^

spark heron
#

Client doesn't really sent air attacks aside of the swing. You could technically hook into ServerPlayNetworkHandler#onHandSwing to catch client initiated ones, but it will also trigger in other cases causing false-positives.

runic creek
#

Question level: Patboxtiny_potato

spark heron
#

You could attach Interaction entities to catch the action and then do the math to raycast it more precisely

limber garnet
spark heron
#

Using multiple can improve the shape

#

And making them ride that display (or others with position offset) will smooth out it's movement (entities riding other entities get 1-tick teleport interpolation)

viscid spear
#

What kinds of false positives will onHandSwing yield?

spark heron
#

It's activated on item dropping and item usage

viscid spear
#

hm, ok

#

thanks for the info

spark heron
#

And more tbf

#

More or less any time swing is initiated from the client

#

You could possibly find what caused it by looking at other packets sent at the same time

viscid spear
#

I'll probably just put an interaction entity on the player and call it good

#

was just hoping there'd be an easy way

runic creek
viscid spear
#

gotcha

spark heron
#

Depending on the end goal that might be non issue