Skip to main content

Overview

The L2J Mobius item system handles all game items including weapons, armor, consumables, quest items, and more. The system uses templates for item definitions and instances for actual item objects in the game world. Package: org.l2jmobius.gameserver.model.item

Class Hierarchy

ListenersContainer
  └── ItemTemplate (Abstract)
      ├── Weapon
      ├── Armor
      └── EtcItem

WorldObject
  └── Item (Instance)

ItemTemplate

Base template class with item definitions

Item

Actual item instance in the world

Weapon

Weapon-specific template properties

Armor

Armor and accessory templates

ItemTemplate Class

Overview

Abstract base class containing static item information shared across all instances of that item type. Source: model/item/ItemTemplate.java:62

Core Properties

_itemId
int
required
Unique item ID
_displayId
int
Display ID for client (defaults to itemId)
_name
String
required
Item name
_icon
String
Icon file path
_weight
int
default:"0"
Item weight in inventory units
_stackable
boolean
default:"false"
Whether items can stack in inventory
_materialType
MaterialType
default:"STEEL"
Material type: STEEL, BRONZE, SILVER, GOLD, etc.
_crystalType
CrystalType
default:"NONE"
Crystal grade: NONE, D, C, B, A, S
_bodyPart
BodyPart
Equipment slot: CHEST, LEGS, HEAD, FEET, etc.
_referencePrice
int
default:"0"
Base price for NPC shops
_crystalCount
int
default:"0"
Number of crystals when destroyed

Item Flags

_sellable
boolean
default:"true"
Can be sold to NPCs
_dropable
boolean
default:"true"
Can be dropped on ground
_destroyable
boolean
default:"true"
Can be destroyed
_tradeable
boolean
default:"true"
Can be traded to other players
_depositable
boolean
default:"true"
Can be stored in warehouse
_enchantable
boolean
default:"false"
Can be enchanted
_questItem
boolean
default:"false"
Is a quest item

Key Methods

getItemId
int
Returns the item’s unique ID
int itemId = template.getItemId();
if (itemId == 57) {
    // This is Adena
}
getName
String
Returns the item name
String name = template.getName();
getWeight
int
Returns item weight
int weight = template.getWeight();
int totalWeight = weight * count;
isStackable
boolean
Checks if item can stack
if (template.isStackable()) {
    // Can combine stacks
}
getCrystalType
CrystalType
Returns crystal grade
CrystalType grade = template.getCrystalType();
if (grade.isGreaterThan(CrystalType.C)) {
    // High grade item
}

Weapon Class

Overview

Extends ItemTemplate with weapon-specific properties. Source: model/item/Weapon.java:45

Weapon Properties

_type
WeaponType
required
Weapon type: SWORD, BOW, DAGGER, BLUNT, etc.
_isMagicWeapon
boolean
default:"false"
Whether weapon is magic-based
_soulShotCount
int
default:"0"
Soulshots consumed per attack
_spiritShotCount
int
default:"0"
Spiritshots consumed per attack
_mpConsume
int
default:"0"
MP consumed per attack
_baseAttackRange
int
default:"40"
Base attack range
_baseAttackRadius
int
Attack radius for area weapons
_baseAttackAngle
int
Attack angle for area weapons

Weapon Methods

getWeaponType
WeaponType
Returns the weapon type
WeaponType type = weapon.getWeaponType();
if (type == WeaponType.BOW) {
    // Bow-specific logic
}
isMagicWeapon
boolean
Checks if weapon is magic-based
if (weapon.isMagicWeapon()) {
    // Use M.Atk instead of P.Atk
}
getSoulShotCount
int
Returns soulshot consumption
int ssCount = weapon.getSoulShotCount();
getAttackRange
int
Returns attack range
int range = weapon.getAttackRange();

Armor Class

Overview

Extends ItemTemplate for armor and accessories. Source: model/item/Armor.java:32

Armor Properties

_type
ArmorType
required
Armor type: LIGHT, HEAVY, MAGIC, SHIELD, etc.
_enchant4Skill
SkillHolder
Skill activated when enchanted to +4

Armor Methods

getArmorType
ArmorType
Returns the armor type
ArmorType type = armor.getArmorType();
if (type == ArmorType.HEAVY) {
    // Heavy armor penalties
}
getEnchant4Skill
Skill
Returns the +4 enchant skill
Skill skill = armor.getEnchant4Skill();
if (skill != null) {
    skill.applyEffects(player, player);
}

Item Class (Instance)

Overview

Represents an actual item instance in the game world or inventory. Source: model/item/instance/Item.java:88

Instance Properties

_ownerId
int
Object ID of the item owner
_count
int
required
Quantity of items in this stack
_loc
ItemLocation
Location: INVENTORY, WAREHOUSE, PAPERDOLL, etc.
_locData
int
Slot number or additional location data
_enchantLevel
int
default:"0"
Current enchant level
_mana
int
default:"-1"
Remaining mana for shadow items
_dropTime
long
When item was dropped (for cleanup)

Instance Methods

getTemplate
ItemTemplate
Returns the item template
ItemTemplate template = item.getTemplate();
String name = template.getName();
getCount
int
Returns item quantity
int count = item.getCount();
setCount
void
Sets item quantity
item.setCount(item.getCount() + 10);
getEnchantLevel
int
Returns enchant level
int enchant = item.getEnchantLevel();
if (enchant >= 4) {
    // Apply enchant skill
}
setEnchantLevel
void
Sets enchant level
item.setEnchantLevel(item.getEnchantLevel() + 1);
getOwnerId
int
Returns owner’s object ID
int ownerId = item.getOwnerId();
getLocation
ItemLocation
Returns item location
ItemLocation loc = item.getLocation();
if (loc == ItemLocation.PAPERDOLL) {
    // Item is equipped
}
isEquipped
boolean
Checks if item is equipped
if (item.isEquipped()) {
    // Item bonuses are active
}

Usage Examples

Creating Items

// Get item template
ItemTemplate template = ItemData.getInstance().getTemplate(57);

// Create item instance
Item item = new Item(57);
item.setCount(10000);
item.setEnchantLevel(0);

Inventory Operations

// Add item to player inventory
PlayerInventory inv = player.getInventory();
Item item = inv.addItem("Reward", 57, 10000, player, null);

// Remove items
boolean removed = inv.destroyItemByItemId("Consume", 57, 5000, player, null);

// Get item by object ID
Item item = inv.getItemByObjectId(objectId);

// Get items by item ID
List<Item> items = inv.getItemsByItemId(itemId);

Equipment Management

// Equip weapon
Item weapon = inv.getItemByObjectId(weaponObjId);
if (weapon != null && weapon.isWeapon()) {
    inv.equipItem(weapon);
}

// Unequip armor
Item chest = inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST);
if (chest != null) {
    inv.unEquipItemInBodySlot(Inventory.PAPERDOLL_CHEST);
}

// Get equipped weapon
Weapon equippedWeapon = player.getActiveWeaponItem();
if (equippedWeapon != null) {
    int pAtk = equippedWeapon.getPAtk();
}

Enchanting Items

public boolean enchantItem(Player player, Item item, Item scroll) {
    ItemTemplate template = item.getTemplate();
    
    // Check if enchantable
    if (!template.isEnchantable()) {
        player.sendMessage("This item cannot be enchanted.");
        return false;
    }
    
    // Check crystal type
    if (scroll.getCrystalType() != item.getCrystalType()) {
        player.sendMessage("Scroll grade doesn't match item grade.");
        return false;
    }
    
    // Calculate success chance
    int currentEnchant = item.getEnchantLevel();
    int successChance = calculateChance(currentEnchant);
    
    // Attempt enchant
    if (Rnd.get(100) < successChance) {
        item.setEnchantLevel(currentEnchant + 1);
        player.sendMessage("Enchant successful! +" + item.getEnchantLevel());
        return true;
    } else {
        // Enchant failed
        if (currentEnchant >= 4) {
            player.getInventory().destroyItem("Enchant Failed", item, player, null);
            player.sendMessage("Enchant failed and item was destroyed.");
        } else {
            player.sendMessage("Enchant failed.");
        }
        return false;
    }
}

Drop System

// Drop item on ground
public void dropItem(Player player, Item item, int count) {
    Item drop = player.getInventory().dropItem("Drop", item, count, player, null);
    
    if (drop != null) {
        // Set drop location
        drop.setDropTime(System.currentTimeMillis());
        drop.setDropperObjectId(player.getObjectId());
        drop.dropMe(player, player.getX(), player.getY(), player.getZ());
        
        // Set drop protection
        drop.getDropProtection().protect(player);
    }
}

// Pick up item
public void pickupItem(Player player, Item item) {
    // Check distance
    if (!player.isInsideRadius3D(item, 150)) {
        player.sendMessage("Too far away.");
        return;
    }
    
    // Check drop protection
    if (!item.getDropProtection().tryPickup(player)) {
        player.sendMessage("This item is protected.");
        return;
    }
    
    // Add to inventory
    player.getInventory().addItem("Pickup", item, player, item);
    item.pickupMe(player);
}

Item Grants with Skills

// Check weapon skills
public void checkWeaponSkills(Player player) {
    Weapon weapon = player.getActiveWeaponItem();
    if (weapon == null) {
        return;
    }
    
    // Get weapon enchant level
    Item weaponItem = player.getActiveWeaponInstance();
    if (weaponItem != null && weaponItem.getEnchantLevel() >= 4) {
        SkillHolder skillHolder = weapon.getEnchant4Skill();
        if (skillHolder != null) {
            Skill skill = skillHolder.getSkill();
            if (player.getSkillLevel(skill.getId()) <= 0) {
                player.addSkill(skill, false);
            }
        }
    }
}

Custom Item Handler

public class CustomItemHandler implements IItemHandler {
    @Override
    public boolean useItem(Playable playable, Item item, boolean forceUse) {
        if (!playable.isPlayer()) {
            return false;
        }
        
        Player player = playable.getActingPlayer();
        
        // Check item
        if (item.getId() != CUSTOM_ITEM_ID) {
            return false;
        }
        
        // Check conditions
        if (player.getLevel() < 40) {
            player.sendMessage("You must be level 40 to use this.");
            return false;
        }
        
        // Consume item
        if (!player.destroyItem("Consume", item, 1, player, true)) {
            return false;
        }
        
        // Apply effect
        player.addExpAndSp(100000, 10000);
        player.sendMessage("You gained experience!");
        
        return true;
    }
}

Item Type Constants

TypeValueDescription
TYPE1_WEAPON_RING_EARRING_NECKLACE0Weapons and accessories
TYPE1_SHIELD_ARMOR1Shields and armor
TYPE1_ITEM_QUESTITEM_ADENA4Items, quest items, currency
TYPE2_WEAPON0Weapons
TYPE2_SHIELD_ARMOR1Armor and shields
TYPE2_ACCESSORY2Accessories
TYPE2_QUEST3Quest items
TYPE2_MONEY4Currency

PlayerInventory

Player’s main inventory management

Warehouse

Warehouse storage system

ItemData

Item template data manager

DropProtection

Drop protection system

Notes

  • Item templates are singleton instances shared across all item instances
  • Always use inventory methods for item operations (never modify directly)
  • Quest items cannot be dropped or traded by default
  • Enchant levels above +0 make items unique (cannot stack)
  • Shadow items have limited lifetime based on mana consumption

Build docs developers (and LLMs) love