Interaction Types
The InteractionType enum defines all possible ways a player can trigger an interaction. Each type maps to specific player input or game events.
Package Location
Section titled “Package Location”com.hypixel.hytale.protocol.InteractionType
Complete InteractionType Reference
Section titled “Complete InteractionType Reference”| Value | Name | Trigger | Description |
|---|---|---|---|
| 0 | Primary | Left click | Main attack or action |
| 1 | Secondary | Right click | Alternate attack or block |
| 2 | Ability1 | Ability key 1 | First ability slot |
| 3 | Ability2 | Ability key 2 | Second ability slot |
| 4 | Ability3 | Ability key 3 | Third ability slot |
| 5 | Use | Use key | Interact with blocks/entities |
| 6 | Pick | Pick key | Pick block (like creative mode) |
| 7 | Pickup | Automatic | Pick up item from ground |
| 8 | CollisionEnter | Physics | Entity enters collision with another |
| 9 | CollisionLeave | Physics | Entity leaves collision |
| 10 | Collision | Physics | Ongoing collision tick |
| 11 | EntityStatEffect | Effect system | Status effect applied to entity |
| 12 | SwapTo | Inventory | Item swapped into active slot |
| 13 | SwapFrom | Inventory | Item swapped out of active slot |
| 14 | Death | Death event | Entity dies |
| 15 | Wielding | Holding item | Active while holding item (blocking) |
| 16 | ProjectileSpawn | Projectile | Projectile is created |
| 17 | ProjectileHit | Projectile | Projectile hits target |
| 18 | ProjectileMiss | Projectile | Projectile misses/expires |
| 19 | ProjectileBounce | Projectile | Projectile bounces off surface |
| 20 | Held | Passive | Passive effect while item in main hand |
| 21 | HeldOffhand | Passive | Passive effect while item in offhand |
| 22 | Equipped | Passive | Passive effect while armor equipped |
| 23 | Dodge | Dodge key | Dodge/roll action |
| 24 | GameModeSwap | Game mode change | Player switches game mode |
Type Categories
Section titled “Type Categories”Player Input Types
Section titled “Player Input Types”These types are triggered by direct player input:
InteractionType.Primary // Left click - attackInteractionType.Secondary // Right click - alt attack/blockInteractionType.Ability1 // First abilityInteractionType.Ability2 // Second abilityInteractionType.Ability3 // Third abilityInteractionType.Dodge // Dodge/rollInteractionType.Use // Interact (doors, chests, NPCs)InteractionType.Pick // Pick blockInteractionType.Pickup // Pick up itemPassive Types
Section titled “Passive Types”These types run continuously while conditions are met:
InteractionType.Held // Main hand passive (e.g., torch glow)InteractionType.HeldOffhand // Offhand passive (e.g., shield ready)InteractionType.Equipped // Armor passive (e.g., set bonuses)InteractionType.Wielding // Active holding (e.g., blocking stance)Event Types
Section titled “Event Types”These types are triggered by game events, not player input:
// Collision eventsInteractionType.CollisionEnter // First frame of collisionInteractionType.CollisionLeave // Frame collision endsInteractionType.Collision // Each frame during collision
// Projectile eventsInteractionType.ProjectileSpawn // When projectile is createdInteractionType.ProjectileHit // When projectile hits targetInteractionType.ProjectileMiss // When projectile expiresInteractionType.ProjectileBounce // When projectile bounces
// State change eventsInteractionType.SwapTo // Item becomes activeInteractionType.SwapFrom // Item becomes inactiveInteractionType.Death // Entity deathInteractionType.EntityStatEffect // Effect appliedInteractionType.GameModeSwap // Game mode changedHow Types Map to Items
Section titled “How Types Map to Items”Items define which interaction types they support in their Interactions field:
{ "Interactions": { "Primary": "Root_Weapon_Sword_Primary", "Secondary": "Root_Weapon_Sword_Guard", "Ability1": "Root_Weapon_Sword_Signature" }}When the player presses the corresponding input, the system looks up the RootInteraction for that type.
UnarmedInteractions Fallback
Section titled “UnarmedInteractions Fallback”When a player has no item equipped (or the item doesn’t define an interaction for a type), the system falls back to UnarmedInteractions:
// From InteractionContext.getRootInteractionId()Item heldItem = context.getOriginalItemType();if (heldItem == null) { UnarmedInteractions unarmed = UnarmedInteractions.getAssetMap().getAsset("Empty"); return unarmed.getInteractions().get(type);}return heldItem.getInteractions().get(type);UnarmedInteractions Asset
Section titled “UnarmedInteractions Asset”{ "Id": "Empty", "Interactions": { "Primary": "Root_Unarmed_Primary", "Secondary": "Root_Unarmed_Secondary", "Use": "Root_Use_Block" }}Usage in Java
Section titled “Usage in Java”Getting Interaction Type
Section titled “Getting Interaction Type”import com.hypixel.hytale.protocol.InteractionType;
// From enum valueInteractionType type = InteractionType.Primary;
// From integer valueInteractionType type = InteractionType.fromValue(0); // Primary
// All valuesInteractionType[] all = InteractionType.VALUES;Creating Context for Type
Section titled “Creating Context for Type”import com.hypixel.hytale.server.core.entity.InteractionContext;
// Standard creation - determines slot based on typeInteractionContext context = InteractionContext.forInteraction( manager, entityRef, InteractionType.Primary, componentAccessor);
// For equipped interactions - must specify slotInteractionContext armorContext = InteractionContext.forInteraction( manager, entityRef, InteractionType.Equipped, slotIndex, // 0-3 for armor slots componentAccessor);Slot Resolution by Type
Section titled “Slot Resolution by Type”Different types resolve to different inventory slots:
// From InteractionContext.forInteraction()switch (type) { case Equipped: return entityInventory.getArmor().getItemStack(equipSlot); case HeldOffhand: return entityInventory.getUtilityItem(); case Primary: case Secondary: case Ability1: case Ability2: case Ability3: // Complex priority resolution between main hand and offhand // See InteractionContext.java for full logic default: return entityInventory.getItemInHand();}Priority Resolution
Section titled “Priority Resolution”When both main hand and offhand have interactions for the same type, priority determines which runs:
// From item configint prioPrimary = mainHandItem.getInteractionConfig() .getPriorityFor(type, PrioritySlot.MainHand);int prioSecondary = offhandItem.getInteractionConfig() .getPriorityFor(type, PrioritySlot.OffHand);
// Higher priority winsif (prioPrimary < prioSecondary) { // Use offhand} else { // Use main hand}Priority Configuration
Section titled “Priority Configuration”{ "InteractionConfig": { "Priority": { "Primary": { "MainHand": 10, "OffHand": 5 }, "Secondary": { "MainHand": 5, "OffHand": 10 } } }}Related
Section titled “Related”- Interaction System Overview - System architecture
- Asset-Based Interactions - JSON interaction definitions
- Interaction Lifecycle - Execution flow
- Items Overview - Item interaction configuration