Skip to content

These docs were made completely by AI, so they might be right, or wrong, you'll need to test them yourself. This was made for a easier understanding of everything. So use at your own risk. If anything is wrong, please don't hurt to make a PR on the page you have a problem with. ON GITHUB

Combat Items

Combat items cover ranged weapons and throwable projectiles. For melee weapons (swords), check out Tools & Weapons.

Files: Minecraft.World/BowItem.h, Minecraft.World/BowItem.cpp

PropertyValue
ID261
Max Durability384
Max Draw Duration20 ticks (1 second)
Enchantability1
Stack Size1
Use AnimationUseAnim_bow
Base Item TypeeBaseItemType_bow
MaterialeMaterial_bow

The bow uses releaseUsing instead of useTimeDepleted. When the player lets go of the use button, power is calculated like this:

int timeHeld = getUseDuration(itemInstance) - durationLeft;
float pow = timeHeld / (float)MAX_DRAW_DURATION;
pow = ((pow * pow) + pow * 2) / 3;
if (pow < 0.1) return; // too short, no shot
if (pow > 1) pow = 1; // capped at max

The arrow entity gets created with velocity pow * 2.0f. Fully drawn arrows (pow == 1.0) are flagged as critical via setCritArrow(true).

The max use duration is 20 * 60 * 60 ticks (one hour), so the player has plenty of time to hold the draw.

EnchantmentEffect
Power (arrowBonus)Adds level * 0.5 + 0.5 to arrow base damage
Punch (arrowKnockback)Sets arrow knockback to the enchantment level
Flame (arrowFire)Sets arrow on fire for 100 ticks
Infinity (arrowInfinite)Fires without consuming arrows; arrows drop with PICKUP_CREATIVE_ONLY

Creative mode and the Infinity enchantment both let you fire without using up arrows from inventory. The use() method checks for either instabuild or having arrows before starting the draw.

Uses 1 durability per shot, applied through itemInstance->hurt(1, player).

Three pull textures are registered (bow_pull_0, bow_pull_1, bow_pull_2) via the TEXTURE_PULL array. The getDrawnIcon(int amount) method returns the right icon based on draw progress. The constant BOW_ICONS_COUNT = 3 defines the number of draw stages.

Files: Minecraft.World/PotionItem.h, Minecraft.World/PotionItem.cpp

PropertyValue
ID373
Drink Duration32 ticks ((int)(20 * 1.6))
Stack Size1
Use AnimationUseAnim_drink

Potions use auxValue to encode the potion type and modifiers. The static method isThrowable(auxValue) checks if a potion is a splash potion. When thrown, a ThrownPotion entity gets created.

The item has multiple sprite layers (base + overlay for liquid color) and caches mob effects per aux value in an unordered_map<int, vector<MobEffectInstance*>*>. Three icons are registered: DEFAULT_ICON, THROWABLE_ICON, and CONTENTS_ICON. The getIcon and getLayerIcon methods pick the right sprites based on whether the potion is throwable and which sprite layer is being drawn.

For the full potion effect system, see Effects (Potions).

All throwable items work the same way: right-click calls use(), which decreases the stack, plays a bow-like sound, and spawns a projectile entity on the server side.

Files: Minecraft.World/SnowballItem.h, Minecraft.World/SnowballItem.cpp

PropertyValue
ID332
Stack Size16
Projectile EntitySnowball

Spawns a Snowball entity on use. Does knockback but no damage to most mobs. Blazes are the exception, taking 3 damage. Creative mode doesn’t consume the snowball.

Files: Minecraft.World/EnderpearlItem.h, Minecraft.World/EnderpearlItem.cpp

PropertyValue
ID368
Stack Size16
Projectile EntityThrownEnderpearl

Spawns a ThrownEnderpearl entity on use. Teleports the player to where it lands and deals 5 fall damage. You can’t throw one while riding an entity (player->riding != NULL). Creative mode doesn’t consume the pearl.

Note: The original Java code disabled ender pearl use in Creative mode entirely, but 4J commented that out (“Not sure why this was disabled for creative mode”) and instead just skips consuming the item.

Files: Minecraft.World/EggItem.h, Minecraft.World/EggItem.cpp

PropertyValue
ID344
Stack Size16
Projectile EntityThrownEgg

Spawns a ThrownEgg entity. There’s a 1/8 chance of spawning a chicken on impact, and a further 1/32 chance of spawning four chickens instead. Creative mode doesn’t consume the egg.

Files: Minecraft.World/ExperienceItem.h, Minecraft.World/ExperienceItem.cpp

PropertyValue
ID384
Stack Size64
Projectile EntityThrownExpBottle
Foil EffectAlways (isFoil returns true)

Spawns a ThrownExpBottle entity that releases experience orbs when it hits something. Always shows the enchantment glint. Creative mode doesn’t consume the bottle.

Files: Minecraft.World/FireChargeItem.h, Minecraft.World/FireChargeItem.cpp

PropertyValue
ID385
Stack Size64
Base Item TypeeBaseItemType_torch
MaterialeMaterial_setfire

Unlike other combat items, fire charges use useOn instead of use. You have to target a block face. The fire charge offsets the position by the face direction and checks if the target space is air (tile ID 0). If so, it places a fire block there and plays the FIRE_IGNITE sound. It’s consumed on use (unless you’re in Creative mode).

There’s also a secondary icon (dragonFireball) registered via registerIcons. When the aux value is > 0, getIcon returns this alternative icon instead of the default. This is used by the Ender Dragon’s fireball projectile.

Several items are tagged with potion brewing formulas through setPotionBrewingFormula(). See Raw Materials for the full brewing ingredient table.

IDItemType
261BowBowItem
262ArrowItem
332SnowballSnowballItem
344EggEggItem
368Ender PearlEnderpearlItem
373PotionPotionItem
384Bottle o’ EnchantingExperienceItem
385Fire ChargeFireChargeItem

The combat item system is mostly the same, but MinecraftConsoles adds firework rockets as a placeable/launchable item:

  • FireworksItem (ID 401) uses useOn to place a FireworksRocketEntity on a block face. It reads explosion data from NBT tags (TAG_FIREWORKS, TAG_EXPLOSIONS, TAG_FLIGHT, etc.) and supports five explosion shape types: small ball (TYPE_SMALL = 0), large ball (TYPE_BIG = 1), star (TYPE_STAR = 2), creeper face (TYPE_CREEPER = 3), and burst (TYPE_BURST = 4). Each explosion entry can have trail (TAG_E_TRAIL) and flicker (TAG_E_FLICKER) flags plus custom colors (TAG_E_COLORS) and fade colors (TAG_E_FADECOLORS). The base item type is eBaseItemType_fireworks.
  • FireworksChargeItem (ID 402) is a multi-layer sprite item that reads its tooltip text from the explosion compound tag. Has its own overlay icon and uses getExplosionTagField to pull specific fields out of the explosion NBT data. Also uses eBaseItemType_fireworks.

The BowItem, PotionItem, SnowballItem, EnderpearlItem, EggItem, ExperienceItem, and FireChargeItem classes are all the same between the two codebases.