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
Display ID for client (defaults to itemId)
Item weight in inventory units
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
Equipment slot: CHEST, LEGS, HEAD, FEET, etc.
Number of crystals when destroyed
Item Flags
Can be traded to other players
Can be stored in warehouse
Key Methods
Returns the item’s unique ID int itemId = template . getItemId ();
if (itemId == 57 ) {
// This is Adena
}
Returns the item name String name = template . getName ();
Returns item weight int weight = template . getWeight ();
int totalWeight = weight * count;
Checks if item can stack if ( template . isStackable ()) {
// Can combine stacks
}
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
Weapon type: SWORD, BOW, DAGGER, BLUNT, etc.
Whether weapon is magic-based
Soulshots consumed per attack
Spiritshots consumed per attack
Attack radius for area weapons
Attack angle for area weapons
Weapon Methods
Returns the weapon type WeaponType type = weapon . getWeaponType ();
if (type == WeaponType . BOW ) {
// Bow-specific logic
}
Checks if weapon is magic-based if ( weapon . isMagicWeapon ()) {
// Use M.Atk instead of P.Atk
}
Returns soulshot consumption int ssCount = weapon . getSoulShotCount ();
Returns attack range int range = weapon . getAttackRange ();
Armor Class
Overview
Extends ItemTemplate for armor and accessories.
Source: model/item/Armor.java:32
Armor Properties
Armor type: LIGHT, HEAVY, MAGIC, SHIELD, etc.
Skill activated when enchanted to +4
Armor Methods
Returns the armor type ArmorType type = armor . getArmorType ();
if (type == ArmorType . HEAVY ) {
// Heavy armor penalties
}
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
Object ID of the item owner
Quantity of items in this stack
Location: INVENTORY, WAREHOUSE, PAPERDOLL, etc.
Slot number or additional location data
Remaining mana for shadow items
When item was dropped (for cleanup)
Instance Methods
Returns the item template ItemTemplate template = item . getTemplate ();
String name = template . getName ();
Returns item quantity int count = item . getCount ();
Sets item quantity item . setCount ( item . getCount () + 10 );
Returns enchant level int enchant = item . getEnchantLevel ();
if (enchant >= 4 ) {
// Apply enchant skill
}
Sets enchant level item . setEnchantLevel ( item . getEnchantLevel () + 1 );
Returns owner’s object ID int ownerId = item . getOwnerId ();
Returns item location ItemLocation loc = item . getLocation ();
if (loc == ItemLocation . PAPERDOLL ) {
// Item is equipped
}
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
Type Value Description TYPE1_WEAPON_RING_EARRING_NECKLACE0 Weapons and accessories TYPE1_SHIELD_ARMOR1 Shields and armor TYPE1_ITEM_QUESTITEM_ADENA4 Items, quest items, currency TYPE2_WEAPON0 Weapons TYPE2_SHIELD_ARMOR1 Armor and shields TYPE2_ACCESSORY2 Accessories TYPE2_QUEST3 Quest items TYPE2_MONEY4 Currency
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