Package me.hackware.api
Class InteractionManager
java.lang.Object
me.hackware.api.InteractionManager
Centralized interaction manager — item use, entity attacks, use-action lifecycle.
Block placement and block interaction are handled by BlockPlacementManager.
This manager covers:
- Item use (pearls, potions, food, fireworks, XP bottles, etc.)
- Entity attacks (crystals, players, mobs)
- Use-action control (stop/release using item)
-
Method Summary
Modifier and TypeMethodDescriptionvoidAttacks an entity viagameMode.attack.static InteractionManagerget()voidinit()Register event handlers.voidreleaseUsingItem(String caller) Releases the item being used (e.g.voidsendAttackPacket(String caller, net.minecraft.world.entity.Entity target) Sends a raw attack packet without going through gameMode.attack.voidsendUseItemPacket(String caller, net.minecraft.world.InteractionHand hand, float yaw, float pitch) Sends a rawServerboundUseItemPacketvia startPrediction.voidstopUsingItem(String caller) Stops the player's current item use action (e.g.net.minecraft.world.InteractionResultUses the item currently in the given hand viagameMode.useItem.
-
Method Details
-
get
-
init
public void init()Register event handlers. Call once during mod init. -
useItem
public net.minecraft.world.InteractionResult useItem(String caller, net.minecraft.world.InteractionHand hand) Uses the item currently in the given hand viagameMode.useItem. Handles prediction internally.- Parameters:
caller- descriptive source (module name)hand- which hand to use- Returns:
- the interaction result
-
sendUseItemPacket
public void sendUseItemPacket(String caller, net.minecraft.world.InteractionHand hand, float yaw, float pitch) Sends a rawServerboundUseItemPacketvia startPrediction. Use this when you need packet-level control (e.g. pearl throws with custom rotation).- Parameters:
caller- descriptive sourcehand- which handyaw- look yaw for the packetpitch- look pitch for the packet
-
attack
Attacks an entity viagameMode.attack. This is the standard vanilla attack path (includes swing, sounds, knockback).- Parameters:
caller- descriptive sourcetarget- the entity to attack
-
sendAttackPacket
Sends a raw attack packet without going through gameMode.attack. Useful for silent attacks that bypass vanilla's attack cooldown/swing.- Parameters:
caller- descriptive sourcetarget- the entity to attack
-
stopUsingItem
Stops the player's current item use action (e.g. interrupts eating, bow draw). -
releaseUsingItem
Releases the item being used (e.g. fires bow, throws trident). Different fromstopUsingItem(java.lang.String)— this triggers the release action.
-