Skip to content

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.

com.hypixel.hytale.protocol.InteractionType

ValueNameTriggerDescription
0PrimaryLeft clickMain attack or action
1SecondaryRight clickAlternate attack or block
2Ability1Ability key 1First ability slot
3Ability2Ability key 2Second ability slot
4Ability3Ability key 3Third ability slot
5UseUse keyInteract with blocks/entities
6PickPick keyPick block (like creative mode)
7PickupAutomaticPick up item from ground
8CollisionEnterPhysicsEntity enters collision with another
9CollisionLeavePhysicsEntity leaves collision
10CollisionPhysicsOngoing collision tick
11EntityStatEffectEffect systemStatus effect applied to entity
12SwapToInventoryItem swapped into active slot
13SwapFromInventoryItem swapped out of active slot
14DeathDeath eventEntity dies
15WieldingHolding itemActive while holding item (blocking)
16ProjectileSpawnProjectileProjectile is created
17ProjectileHitProjectileProjectile hits target
18ProjectileMissProjectileProjectile misses/expires
19ProjectileBounceProjectileProjectile bounces off surface
20HeldPassivePassive effect while item in main hand
21HeldOffhandPassivePassive effect while item in offhand
22EquippedPassivePassive effect while armor equipped
23DodgeDodge keyDodge/roll action
24GameModeSwapGame mode changePlayer switches game mode

These types are triggered by direct player input:

InteractionType.Primary // Left click - attack
InteractionType.Secondary // Right click - alt attack/block
InteractionType.Ability1 // First ability
InteractionType.Ability2 // Second ability
InteractionType.Ability3 // Third ability
InteractionType.Dodge // Dodge/roll

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)

These types are triggered by game events, not player input:

// Collision events
InteractionType.CollisionEnter // First frame of collision
InteractionType.CollisionLeave // Frame collision ends
InteractionType.Collision // Each frame during collision
// Projectile events
InteractionType.ProjectileSpawn // When projectile is created
InteractionType.ProjectileHit // When projectile hits target
InteractionType.ProjectileMiss // When projectile expires
InteractionType.ProjectileBounce // When projectile bounces
// State change events
InteractionType.SwapTo // Item becomes active
InteractionType.SwapFrom // Item becomes inactive
InteractionType.Death // Entity death
InteractionType.EntityStatEffect // Effect applied
InteractionType.GameModeSwap // Game mode changed

Items define which interaction types they support in their Interactions field:

Weapon_Sword_Example.json
{
"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.

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_Empty.json
{
"Id": "Empty",
"Interactions": {
"Primary": "Root_Unarmed_Primary",
"Secondary": "Root_Unarmed_Secondary",
"Use": "Root_Use_Block"
}
}
import com.hypixel.hytale.protocol.InteractionType;
// From enum value
InteractionType type = InteractionType.Primary;
// From integer value
InteractionType type = InteractionType.fromValue(0); // Primary
// All values
InteractionType[] all = InteractionType.VALUES;
import com.hypixel.hytale.server.core.entity.InteractionContext;
// Standard creation - determines slot based on type
InteractionContext context = InteractionContext.forInteraction(
manager,
entityRef,
InteractionType.Primary,
componentAccessor
);
// For equipped interactions - must specify slot
InteractionContext armorContext = InteractionContext.forInteraction(
manager,
entityRef,
InteractionType.Equipped,
slotIndex, // 0-3 for armor slots
componentAccessor
);

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();
}

When both main hand and offhand have interactions for the same type, priority determines which runs:

// From item config
int prioPrimary = mainHandItem.getInteractionConfig()
.getPriorityFor(type, PrioritySlot.MainHand);
int prioSecondary = offhandItem.getInteractionConfig()
.getPriorityFor(type, PrioritySlot.OffHand);
// Higher priority wins
if (prioPrimary < prioSecondary) {
// Use offhand
} else {
// Use main hand
}
Item interaction priority
{
"InteractionConfig": {
"Priority": {
"Primary": { "MainHand": 10, "OffHand": 5 },
"Secondary": { "MainHand": 5, "OffHand": 10 }
}
}
}