Hardcoded item properties (Java Edition)
Minecraft Wiki article. Categories: Upcoming, Java_Edition_upcoming_tag, Java_Edition, Minecraft_Work_in_progress, Minecraft_Work_in_progress_with_a_note, Hardcoded_item, Cleanup_without_a_reason, Article_cleanup…
This article is reproduced from Hardcoded item properties (Java Edition) on the Minecraft Wiki. Mirrored from revision 3725413. It is licensed CC BY-NC-SA 3.0 by the Minecraft Wiki contributors — not under the Codex’s CC BY-SA 4.0, and it may not be used commercially. Edits belong upstream, not here.
- Item stacks properties
- Count
- Components
- Id
- Mixed properties
- Code structure
- Item.Properties
- Item subclasses (code structure)
- List
- Items class member access
- List
- Item class
- onUseTick(...)
- onDestroyed(...)
- canDestroyBlock(...)
- useOn(...)
- use(...)
- finishUsingItem(...)
- isBarVisible(...)
- getBarWidth(...)
- getBarColor(...)
- overrideStackedOnOther(...)
- overrideOtherStackedOnMe(...)
- getAttackDamageBonus(...)
- getItemDamageSource(...)
- hurtEnemy(...)
- postHurtEnemy(...)
- mineBlock(...)
- interactLivingEntity(...)
- inventoryTick(...)
- onCraftedPostProcess(...)
- getUseAnimation(...)
- getUseDuration(...)
- releaseUsing(...)
- appendHoverText(...)
- getTooltipImage(...)
- getName(...)
- isFoil(...)
- useOnRelease(...)
- getDefaultInstance()
- canFitInsideContainerItems()
- shouldPrintOpWarning(...)
- Item subclasses
- AirItem
- ArmorStandItem
- ArrowItem
- AxeItem
- BannerItem
- BedItem
- BlockItem
- Item overrides methods
- Place
- Block by item
- Usage in instanceof
- BoatItem
- BoneMealItem
- BottleItem
- BowItem
- BrushItem
- BucketItem
Note:
Hardcoded item properties are aspects of items which are tied to the IDs and cannot be customized fully via the use of commands or data packs.
Many of the properties associated with items in the game have been made controllable with the newly-introduced data component format; this intends to track things that are not currently controllable via components, item tags, recipes, advancements, enchantments and trades (though may be in future).
Item stacks properties
Most item instances in the game are through item stacks. An item stack is defined by its id, count and components.
Count
The count of an item is the easiest to control, and can largely be controlled even in Survival mode. Changing commands and components gives you more freedom to control it, although items with a count higher than their max_stack_size have some side effects and it is not possible, even with commands, to exceed a count of 99 or be less than 1.
However, the count is rarely used to affect the property of an item stack. Exceptions include the weight of the item in a bundle to test if it is full, the weight of the item in a container to be used by comparators, and using the item in trades. It is possible to control the quantity of items needed for a trade by commands and datapacks, the weight of the item in container is partially controlled by max_stack_size, and in bundles, in addition to being partially controlled by max_stack_size, it is also by bees and by bundle_contents.
Furthermore, most uses of item stacks that do not depend on their count cannot be controlled to have to need it.
Components
Some components are partially controlled by changes made to the item in Survival mode. All components are strongly controlled by commands, although not entirely, as valid data is still required.
It is also possible to control the components of future item instances via datapacks, such as controlling the components of items in a loot table, the components of the result of many recipes (but not all, especially when the recipe result depends on the ingredient components), the components of the gives in villager trade, or the components of items that are in structures but are not part of a loot table (such as some chests in secret rooms of the woodland mansion).
However, there are origins of items that are not controlled by datapacks or commands, thus making it impossible to control the initial components of these items without mods (although it is possible to test when these items are originated and change their components later using datapacks).
Changes to an item's stack properties, depending on whether or not a certain component has it, can vary considerably. In some cases, the component affects all items that possess it and is highly customizable. In other cases, the component only affects stack items with certain IDs, or the component doesn't have much customizable data. Furthermore, some components affect more than one item property, making it impossible to activate only some of them.
Sometimes, properties that can be controlled by components have a lower priority than properties that depend on the item's ID, to the point that being used on certain items partially or completely loses its effect.
Default components
Default components are components that are defined for each item ID. If an item stack does not have a component defined in the component field, but has it as its default component, it will consider the value of its default component. If it has the component in the component field, it will consider the value of the component field.
With commands and datapacks, this control only extends to additional components, not default components. Default components depend solely on the item's ID and cannot be customized.
It is possible to remove a component of an item stack with ![component name]. However, this will modify the item's data, adding a new component that serves to remove the previous one. This can impact, for example, comparisons of item data via commands, or picking up a block with a mouse click (since the block is only selected from your inventory if it doesn't have additional components).
Furthermore, some aspects of the items depend on their default component. For example, knowing which spawn egg will be picked up when clicking on an entity, or the villager controlling the number of items in the inventory to know whether to drop it.
Id
Often, an item's stack property depends on its ID. Sometimes it depends only on its ID, and other times it depends on both its ID and its components or count. The main objective of this article is to describe the item properties that depend on their ID; however, not all will be covered, as some item properties that depend on their ID are actually controlled by data packs and not hardcoded.
Note that all these properties, being controlled by ID and not by component, cannot be made so that only some item stacks possess them, because when adding an ID, all item stacks with the same ID will share it. Thus, customizing properties by component instead of ID is more powerful. Due to this and the impossibility of registering new IDs, it is possible that data pack projects will not be viable because they do not have enough items to define properties with different IDs.
Item tags
Many of an item's properties depend exclusively on it belonging to a certain item tag. Sometimes an item tag is used to describe a property that can also be changed at another time; for example, using a tag in a vanilla datapack file would allow you to directly use the item IDs there. However, there are item properties that can only be manipulated without mods by adding them to a tag. See item tag.
Recipes
Recipes can control the properties of items to be used in the manufacture of others. Although largely customizable, there are still some limitations, especially when considering the components of the ingredients for the final result. See recipes.
Enchantment definition
When defining an enchantment, it is necessary to define the items in supported_items and primary_items to specify which items can be crafted at the anvil and the enchanting table, respectively. See enchantment definition.
Mixed properties
Some properties may depend on the item's id, component, and count. Below is a list of these properties that can be controlled by data packs or commands.
Trade
Trade can be controlled either by commands (with /data, editing villager data) or by villager trade definition. With them, you define the properties of an item stack, which can be trade for another by the villagers.
Item predicate
The item predicate is a subpredicate of predicates. Predicates can be used to test if a certain item satisfies a certain condition, and if so, contribute to the activation a certain loot table or advancement trigger. Loot tables are used to obtain items at various times. Advancement triggers, in addition to being used to receive advancements, are also used to unlock recipes.
Predicates are even more important for customizations, being used in commands or in advancement triggers to activate functions. Some commands like /execute (if|unless) items ... are also very important in testing items and have an effect. Although we can use such commands to simulate a hardcoded item property or inhibit properties of certain items, this will hardly be done in a completely similar way, and the hardcoded properties will continue to exist, only being inhibited or copied.
Code structure
There are at least three ways in which the game code describes the properties of an item associated with its ID.
Item.Properties
In class Item.Properties, the game defines a series of functions that can be applied to an item and change its properties. However, the vast majority of these properties ultimately only modify the item's default data components.
A complete list of default components in 26.2 can be seen at misode/mcmeta. The list for 26.3 Snapshot 9 can be found here.
A notable exception is the craftRemainder property, which defines which item will remain in a recipe when using the item as a recipe. See below for a list of all craft reminders:
| Item | Craft remainder | Vanilla use |
|---|---|---|
| Cake recipe. | ||
| Fuel remainder in smelting. | ||
| None. | ||
| Honey block and sugar recipes. | ||
| Ingredient remainder in brewing.[note 1] |
All craft remainder can also be used in custom recipes via data packs. In code is also used in the craft display item, however it apparently hasn't been implemented in the game[more information needed].
Adding some tags, such as #wooden_trapdoors, to one of the items above, allow to use it as fuel and have the crafting remainder after. In the book and banner cloning recipe, the cloned item remains if it doesn't have a craft remainder[note 2]; if it does have a crafting remainder, the crafting remainder takes priority. Therefore, when placing one of the above items with a source in the book cloning recipe, instead of keeping the item, it will keep its crafting remainder.
Another exception is the item descriptionId, which can be minecraft.item.<id> or minecraft.block.<id>. Although its primary use is for the item name, the item_name default component, this description id is also used for other things, such as potion names and disc fragment descreipition.
The last exception is the requiredFeatures propertie, although it's not important in the current version. It serves to list which experiments must be active to use a certain item in many cases. Currently, no item is exclusive to any experiment; thus, all have this property with its default value VANILLA_SET.
Most of the Item.Properties applied to items are applied from the item's registered in Items.
Item subclasses (code structure)
In the item package, there are many classes that define properties for a certain item or a certain set of items; these classes extend the Item class. A large part of the hardcoded item properties come from here.
These classes have [something]Item as their name, such as DyeItem, HoeItem, and NameTagItem.
In many cases, when an item is registered in Items, it is already created as a new instance of one of these classes.
Some of them are abstract classes, not having any item that is restricted as a new instance of that class; however, these classes are extended by other classes, and so on until reaching a class that is at least one item, which is then restricted as a new instance of the class.
Most of the properties of an item defined as belonging to a specific subclass are defined within the subclass itself. However, sometimes in other classes, instanceof is used to test if a certain item is an item of that class, and thus new properties can be defined for the item.
List
The table below shows the classes that extend Item and the IDs of the items that are restricted as instances of them (in Items).
See § Item subclasses for details.
| Class | Items (id) |
|---|---|
| AirItem | air |
| ArmorStandItem | armor_stand |
| ArrowItem | arrow |
| AxeItem | wooden_axe, copper_axe, stone_axe, golden_axe, iron_axe, diamond_axe |
| BannerItem | white_banner, orange_banner, magenta_banner, light_blue_banner, yellow_banner, lime_banner, pink_banner, gray_banner, light_gray_banner, cyan_banner, purple_banner, blue_banner, brown_banner, green_banner, red_banner, black_banner |
| BedItem | white_bed, orange_bed, magenta_bed, light_blue_bed, yellow_bed, lime_bed, pink_bed, gray_bed, light_gray_bed, cyan_bed, purple_bed, blue_bed, brown_bed, green_bed, red_bed, black_bed |
| BlockItem | 15 items with
createBlockItemWithCustomItemName:
resin_clump, redstone, string, wheat_seeds, cocoa_beans, pumpkin_seeds, melon_seeds, nether_wart, carrot, potato, torchflower_seeds, pitcher_pod, beetroot_seeds, sweet_berries, glow_berries 989 items with |
| BoatItem | cherry_boat, birch_chest_boat, birch_boat, acacia_chest_boat, acacia_boat, spruce_chest_boat, spruce_boat, pale_oak_chest_boat, pale_oak_boat, oak_chest_boat, oak_boat, mangrove_chest_boat, mangrove_boat, jungle_chest_boat, jungle_boat, dark_oak_chest_boat, dark_oak_boat, cherry_chest_boat, bamboo_raft, bamboo_chest_raft |
| BoneMealItem | bone_meal |
| BottleItem | glass_bottle |
| BowItem | bow |
| BrushItem | brush |
| BucketItem | bucket, water_bucket, lava_bucket |
| BundleItem | bundle, white_bundle, orange_bundle, magenta_bundle, light_blue_bundle, yellow_bundle, lime_bundle, pink_bundle, gray_bundle, light_gray_bundle, cyan_bundle, purple_bundle, blue_bundle, brown_bundle, green_bundle, red_bundle, black_bundle |
| CompassItem | compass |
| CrossbowItem | crossbow |
| DebugStickItem | debug_stick |
| DiscFragmentItem | disc_fragment_5 |
| DoubleHighBlockItem | small_dripleaf, sunflower, lilac, rose_bush, peony, tall_grass, large_fern, iron_door, oak_door, spruce_door, birch_door, jungle_door, acacia_door, cherry_door, dark_oak_door, pale_oak_door, mangrove_door, bamboo_door, crimson_door, warped_door, copper_door, exposed_copper_door, weathered_copper_door, oxidized_copper_door, waxed_copper_door, waxed_exposed_copper_door, waxed_weathered_copper_door, waxed_oxidized_copper_door
|
| DyeItem | white_dye, orange_dye, magenta_dye, light_blue_dye, yellow_dye, lime_dye, pink_dye, gray_dye, light_gray_dye, cyan_dye, purple_dye, blue_dye, brown_dye, green_dye, red_dye, black_dye |
| EggItem | egg, blue_egg, brown_egg |
| EmptyMapItem | map |
| EndCrystalItem | end_crystal |
| EnderEyeItem | ender_eye |
| EnderpearlItem | ender_pearl |
| ExperienceBottleItem | experience_bottle |
| FireChargeItem | fire_charge |
| FireworkRocketItem | firework_rocket |
| FishingRodItem | fishing_rod |
| FlintAndSteelItem | flint_and_steel |
| FoodOnAStickItem | carrot_on_a_stick, warped_fungus_on_a_stick |
| GameMasterBlockItem | command_block, repeating_command_block, chain_command_block, structure_block, jigsaw, test_block, test_instance_block |
| GlowInkSacItem | glow_ink_sac |
| HangingEntityItem | painting |
| HangingSignItem | warped_hanging_sign, spruce_hanging_sign, pale_oak_hanging_sign, oak_hanging_sign, mangrove_hanging_sign, jungle_hanging_sign, dark_oak_hanging_sign, crimson_hanging_sign, cherry_hanging_sign, birch_hanging_sign, bamboo_hanging_sign, acacia_hanging_sign |
| HoeItem | wooden_hoe, copper_hoe, stone_hoe, golden_hoe, iron_hoe, diamond_hoe |
| HoneycombItem | honeycomb |
| InkSacItem | ink_sac |
| InstrumentItem | goat_horn |
| Item | All, see Java_Edition_data_values/Items |
| ItemFrameItem | item_frame |
| KnowledgeBookItem | knowledge_book |
| LeadItem | lead |
| LingeringPotionItem | lingering_potion |
| MaceItem | mace |
| MapItem | filled_map |
| MinecartItem | minecart, chest_minecart, furnece_minecart, tnt_minecart, hopper_minecart, command_block_minecart |
| MobBucketItem | pufferfish_bucket, salmon_bucket, cod_bucket, tropical_fish_bucket, axolotl_bucket, tadpole_bucket |
| NameTagItem | name_tag |
| PlaceOnWaterBlockItem | lily_pad, frogspawn |
| PlayerHeadItem | player_head |
| PotionItem | potion |
| ProjectileWeaponItem | |
| ScaffoldingBlockItem | scaffolding |
| ShearsItem | shears |
| ShieldItem | shield |
| ShovelItem | wooden_shovel, copper_shovel, stone_shovel, golden_shovel, iron_shovel, diamond_shovel |
| SignItem | warped_sign, spruce_sign, pale_oak_sign, oak_sign, mangrove_sign, jungle_sign, dark_oak_sign, crimson_sign, cherry_sign, birch_sign, bamboo_sign, acacia_sign |
| SmithingTemplateItem |
netherite_upgrade_smithing_template, sentry_armor_trim_smithing_template, dune_armor_trim_smithing_template, coast_armor_trim_smithing_template, wild_armor_trim_smithing_template, ward_armor_trim_smithing_template, eye_armor_trim_smithing_template, vex_armor_trim_smithing_template, tide_armor_trim_smithing_template, snout_armor_trim_smithing_template, rib_armor_trim_smithing_template, spire_armor_trim_smithing_template, wayfinder_armor_trim_smithing_template, shaper_armor_trim_smithing_template, silence_armor_trim_smithing_template, raiser_armor_trim_smithing_template, host_armor_trim_smithing_template, flow_armor_trim_smithing_template, bolt_armor_trim_smithing_template
|
| SnowballItem | snowball |
| SolidBucketItem | powder_snow_bucket |
| SpawnEggItem |
chicken_spawn_egg, cow_spawn_egg, pig_spawn_egg, sheep_spawn_egg, camel_spawn_egg, donkey_spawn_egg, horse_spawn_egg, mule_spawn_egg, cat_spawn_egg, parrot_spawn_egg, wolf_spawn_egg, armadillo_spawn_egg, bat_spawn_egg, bee_spawn_egg, fox_spawn_egg, goat_spawn_egg, llama_spawn_egg, ocelot_spawn_egg, panda_spawn_egg, polar_bear_spawn_egg, rabbit_spawn_egg, axolotl_spawn_egg, cod_spawn_egg, dolphin_spawn_egg, frog_spawn_egg, glow_squid_spawn_egg, nautilus_spawn_egg, pufferfish_spawn_egg, salmon_spawn_egg, squid_spawn_egg, tadpole_spawn_egg, tropical_fish_spawn_egg, turtle_spawn_egg, allay_spawn_egg, mooshroom_spawn_egg, sniffer_spawn_egg, copper_golem_spawn_egg, iron_golem_spawn_egg, snow_golem_spawn_egg, trader_llama_spawn_egg, villager_spawn_egg, wandering_trader_spawn_egg, bogged_spawn_egg, camel_husk_spawn_egg, drowned_spawn_egg, husk_spawn_egg, parched_spawn_egg, skeleton_spawn_egg, skeleton_horse_spawn_egg, stray_spawn_egg, wither_spawn_egg, wither_skeleton_spawn_egg, zombie_spawn_egg, zombie_horse_spawn_egg, zombie_nautilus_spawn_egg, zombie_villager_spawn_egg, cave_spider_spawn_egg, spider_spawn_egg, breeze_spawn_egg, creaking_spawn_egg, creeper_spawn_egg, elder_guardian_spawn_egg, guardian_spawn_egg, phantom_spawn_egg, silverfish_spawn_egg, slime_spawn_egg, warden_spawn_egg, witch_spawn_egg, evoker_spawn_egg, pillager_spawn_egg, ravager_spawn_egg, vindicator_spawn_egg, vex_spawn_egg, blaze_spawn_egg, ghast_spawn_egg, happy_ghast_spawn_egg, hoglin_spawn_egg, magma_cube_spawn_egg, piglin_spawn_egg, piglin_brute_spawn_egg, strider_spawn_egg, zoglin_spawn_egg, zombified_piglin_spawn_egg, ender_dragon_spawn_egg, enderman_spawn_egg, endermite_spawn_egg, shulker_spawn_egg
|
| SpectralArrowItem | spectral_arrow |
| SplashPotionItem | splash_potion |
| SpyglassItem | spyglass |
| StandingAndWallBlockItem | torch, soul_torch, copper_torch, tube_coral_fan, brain_coral_fan, bubble_coral_fan, fire_coral_fan, horn_coral_fan, dead_tube_coral_fan, dead_brain_coral_fan, dead_bubble_coral_fan, dead_fire_coral_fan, dead_horn_coral_fan, redstone_torch, skeleton_skull, wither_skeleton_skull, zombie_head, creeper_head, dragon_head, piglin_head |
| ThrowablePotionItem | |
| TippedArrowItem | tipped_arrow |
| TridentItem | trident |
| WindChargeItem | wind_charge |
| WritableBookItem | writable_book |
| WrittenBookItem | written_book |
Items class member access
In many parts of the game's code, within many contexts, direct access to an item's restricted area is used, by Items member access, allowing to determine a property of that item.
In certain cases, this item call only serves to create the vanilla datapack, for example by creating item tags, recipes, loot tables and trades. Therefore, this is a property that can be fully controlled by datapacks. However, it's worth noting that many of these properties that we can fully control through data packs (and not through components) can only be controlled by the item's ID, not by its components.
Furthermore, in some cases, it creates a new instance of the item. This could be due to an item origin not controlled by a loot table (such as equipment or wither flowers), a visual effect (such as using items in a GUI), or some other use (such as a mob using an item as a projectile). In these cases, we are not strictly talking about an item property, as we are not discussing how a pre-existing item modifies the game.[note 3]
List
The table below shows all the classes that has a Items memmber access, and the number of uses in each class. According to the code of 26.1.
Legend:
- red The background indicates that all items within that class are used only for generating the vanilla datapack/resourepack.
- yellowThe background indicates that all items within them are a new instance, representing an item's origin, visual use, etc., and not a property of a pre-existing item.
See § Items member access, for details of the classes without note
| Class | Note | Usages |
|---|---|---|
| EntityEquipmentPredicate | 1 | |
| TriggerInstance | Vanilla datapack | 2 |
| BlockModelGenerators | Vanilla resourcepack | 39 |
| ItemModelGenerators | Vanilla resourcepack | 493 |
| LayerEntry | Gui | 3 |
| ItemStatisticsList | Gui | 1 |
| GameModeIcon | Gui | 3 |
| BeaconScreen | Gui | 5 |
| BlastFurnaceScreen | Gui | 3 |
| CartographyTableScreen | Gui | 3 |
| CreativeModeInventoryScreen | Gui | 1 |
| FurnaceScreen | Gui | 4 |
| SmokerScreen | Gui | 1 |
| CraftingRecipeBookComponent | Gui | 6 |
| TabInfo | Gui | 1 |
| ClientLevel | 2 | |
| ClientPacketListener | Display | 1 |
| CobwebProvider | Particle | 1 |
| SlimeProvider | Particle | 1 |
| SnowballProvider | Particle | 1 |
| AbstractClientPlayer | 1 | |
| ItemInHandRenderer | 8 | |
| LevelEventHandler | Particle | 2 |
| AbstractSkeletonRenderer | 2 | |
| DrownedRenderer | 1 | |
| LivingEntityRenderer | 1 | |
| WitchRenderer | 1 | |
| AvatarRenderer | 2 | |
| CuboidItemModelWrapper | 1 | |
| Charge | 1 | |
| CauldronInteractions | 48 | |
| DispenseItemBehavior | 81 | |
| BuiltInRegistries | New instance | 1 |
| VanillaAdventureAdvancements | Vanilla datapack | 59 |
| VanillaHusbandryAdvancements | Vanilla datapack | 100 |
| VanillaNetherAdvancements | Vanilla datapack | 25 |
| VanillaStoryAdvancements | Vanilla datapack | 26 |
| VanillaTheEndAdvancements | Vanilla datapack | 7 |
| BlockLootSubProvider | Vanilla datapack | 10 |
| TradeRebalanceChestLoot | Trade rebalance datapack | 95 |
| VanillaArchaeologyLoot | Vanilla datapack | 77 |
| VanillaBlockInteractLoot | Vanilla datapack | 5 |
| VanillaBlockLoot | Vanilla datapack | 54 |
| VanillaChargedCreeperExplosionLoot | Vanilla datapack | 5 |
| VanillaChestLoot | Vanilla datapack | 703 |
| VanillaEntityInteractLoot | Vanilla datapack | 1 |
| VanillaEntityLoot | Vanilla datapack | 116 |
| VanillaEquipmentLoot | Vanilla datapack | 13 |
| VanillaFishingLoot | Vanilla datapack | 20 |
| VanillaGiftLoot | Vanilla datapack | 75 |
| VanillaPiglinBarterLoot | Vanilla datapack | 19 |
| VanillaShearingLoot | Vanilla datapack | 5 |
| RecipeProvider | Vanilla datapack | 41 |
| VanillaRecipeProvider | Vanilla datapack | 1,482 |
| VanillaItemTagsProvider | Vanilla datapack | 495 |
| ServerGamePacketListenerImpl | New instance | 1 |
| AgeableMob | 1 | |
| Entity | 3 | |
| EntityType | New instance | 20 |
| Leashable | New instance | 2 |
| LivingEntity | 6 | |
| Mob | 25 | |
| CelebrateVillagersSurvivedRaid | New instance | 1 |
| CrossbowAttack | 3 | |
| TradeWithVillager | 3 | |
| UseBonemeal | 3 | |
| WorkAtComposter | 6 | |
| BegGoal | 1 | |
| OfferFlowerGoal | New instance | 1 |
| RangedBowAttackGoal | 2 | |
| RangedCrossbowAttackGoal | 2 | |
| RemoveBlockGoal | New instance | 1 |
| Bucketable | 1 | |
| Armadillo | 1 | |
| Axolotl | 3 | |
| Camel | 1 | |
| AbstractCow | 2 | |
| MushroomCow | 4 | |
| AbstractChestedHorse | 4 | |
| AbstractHorse | 9 | |
| Horse | 1 | |
| Llama | 2 | |
| SkeletonTrapGoal | New instance | 1 |
| ZombieHorse | New instance | 1 |
| Cod | New instance | 1 |
| Pufferfish | New instance | 1 |
| Salmon | New instance | 1 |
| TropicalFish | New instance | 1 |
| Fox | New instance | 7 |
| FoxEatBerriesGoal | New instance | 2 |
| Tadpole | New instance | 1 |
| Goat | 4 | |
| CopperGolem | 2 | |
| IronGolem | 1 | |
| SnowGolem | 2 | |
| AbstractNautilus | New instance | 1 |
| Panda | 1 | |
| Pig | 2 | |
| Sheep | 1 | |
| Sniffer | New instance | 1 |
| Wolf | 3 | |
| EndCrystal | New instance | 1 |
| WitherBoss | New instance | 1 |
| ArmorStand | 3 | |
| GlowItemFrame | New instance | 1 |
| ItemFrame | New instance | 1 |
| LeashFenceKnotEntity | 2 | |
| Painting | New instance | 2 |
| Creeper | 1 | |
| CrossbowAttackMob | 1 | |
| EnderMan | New instance | 1 |
| Monster | New instance | 1 |
| Strider | 3 | |
| Vex | New instance | 1 |
| Witch | New instance | 3 |
| Illusioner | 2 | |
| Pillager | 6 | |
| Vindicator | New instance | 2 |
| Piglin | 9 | |
| PiglinAi | 4 | |
| PiglinBrute | 2 | |
| AbstractSkeleton | 5 | |
| Bogged | 1 | |
| WitherSkeleton | New instance | 1 |
| Drowned | 7 | |
| DrownedTridentAttackGoal | 1 | |
| Husk | New instance | 1 |
| Zombie | 4 | |
| ZombieVillager | 1 | |
| ZombifiedPiglin | New instance | 2 |
| Villager | 5 | |
| VillagerProfession | 4 | |
| WanderingTrader | 4 | |
| Player | 3 | |
| EyeOfEnder | New instance | 1 |
| FireworkRocketEntity | 2 | |
| FishingHook | 2 | |
| ProjectileUtil | 1 | |
| Arrow | New instance | 2 |
| SpectralArrow | New instance | 1 |
| ThrownTrident | New instance | 1 |
| Fireball | New instance | 1 |
| Snowball | New instance | 1 |
| ThrownEgg | New instance | 1 |
| ThrownEnderpearl | New instance | 1 |
| ThrownExperienceBottle | New instance | 1 |
| ThrownLingeringPotion | New instance | 1 |
| ThrownSplashPotion | New instance | 1 |
| Raid | 1 | |
| Minecart | New instance | 2 |
| MinecartChest | New instance | 2 |
| MinecartCommandBlock | New instance | 2 |
| MinecartFurnace | New instance | 2 |
| MinecartHopper | New instance | 2 |
| MinecartSpawner | New instance | 2 |
| MinecartTNT | New instance | 2 |
| AnvilMenu | 1 | |
| PotionSlot | 4 | |
| CartographyTableMenu | 9 | |
| EnchantmentMenu | 5 | |
| FurnaceFuelSlot | 1 | |
| GrindstoneMenu | 2 | |
| BottleItem | New instance | 2 |
| BucketItem | New instance | 1 |
| CompassItem | New instance | 1 |
| CreativeModeTabsItem | New instance | 1,696 |
| CrossbowItem | 3 | |
| FoodOnAStickItem | New instance | 1 |
| HoeItem | New instance | 1 |
| Item | 2 | |
| Items | 1,517 | |
| ItemStack | 4 | |
| ItemStackTemplate | 1 | |
| MapItem | New instance | 1 |
| PotionItem | 1 | |
| ProjectileWeaponItem | 2 | |
| PotionBrewing | 61 | |
| BlastingRecipe | New instance | 1 |
| CampfireCookingRecipe | New instance | 1 |
| DyeRecipe | New instance | 1 |
| ImbueRecipe | New instance | 1 |
| Ingredient | 1 | |
| ShapedRecipe | New instance | 1 |
| ShapelessRecipe | New instance | 1 |
| SmeltingRecipe | New instance | 1 |
| SmithingTransformRecipe | New instance | 1 |
| SmithingTrimRecipe | New instance | 1 |
| SmokingRecipe | New instance | 1 |
| StonecutterRecipe | New instance | 1 |
| TransmuteRecipe | New instance | 1 |
| EnchantmentHelper | 5 | |
| Enchantments | New instance | 1 |
| TradeRebalanceVillagerTrades | Trade rebalance datapack | 171 |
| VillagerTrades | Vanilla datapack | 625 |
| BambooSaplingBlockBlock | New instance | 1 |
| BeehiveBlockBlock | 5 | |
| BeetrootBlockBlock | New instance | 1 |
| BubbleColumnBlockBlock | New instance | 1 |
| CandleCakeBlockBlock | 2 | |
| CarrotBlockBlock | New instance | 1 |
| CaveVinesBlockBlock | New instance | 1 |
| CaveVinesPlantBlockBlock | New instance | 1 |
| ChiseledBookShelfBlockBlock | 2 | |
| ComposterBlockBlock | 117 | |
| ComposterBlock.OutputContainerBlock | 1 | |
| CropBlock | New instance | 1 |
| LightBlock | 1 | |
| NetherWartBlock | New instance | 1 |
| PotatoBlock | New instance | 1 |
| PowderSnowBlock | 2 | |
| PumpkinBlock | 2 | |
| RespawnAnchorBlock | 1 | |
| SimpleWaterloggedBlock | New instance | 1 |
| SweetBerryBushBlock | New instance | 2 |
| TntBlock | 3 | |
| TorchflowerCropBlock | New instance | 1 |
| TripWireBlock | 1 | |
| WeatheringCopperGolemStatueBlock | 1 | |
| WitherSkullBlock | 1 | |
| AbstractFurnaceBlockEntity | 7 | |
| BrewingStandBlockEntity | 5 | |
| DecoratedPotBlockEntity | New instance | 1 |
| DecoratedPotPatterns | 24 | |
| FuelValues | 15 | |
| PotDecorations | 3 | |
| VaultConfig | 1 | |
| Bootstrap | Vanilla datapack | 3 |
| EndCityPiece | New instance | 1 |
| EmptyFluid | New instance | 1 |
| LavaFluid | New instance | 1 |
| WaterFluid | New instance | 1 |
| EnchantRandomlyFunction | 3 | |
| ExplorationMapFunction | 1 | |
| FillPlayerHead | 1 | |
| SetEnchantmentsFunction | 2 | |
| SetStewEffectFunction | 1 |
Item class
onUseTick(...)
| Declaration Header |
public void |
|---|---|
| Parameters |
Level level, LivingEntity livingEntity, ItemStack itemStack, int ticksRemaining |
Empty, for most items, it doesn't add any properties. However, it can add properties with its implementations, see below.
Uses tree
- Item.
onUseTick(...)- ItemStack.
onUseTick(...): Calls the method implemented in the item stack as item, after properties relating toconsumableandkinetic_waaponcomponents.- LivingEntity.
updateUsingItem(...): Called at the beginning, in the ServerPlayer implementation after activatingusing_itemtiger criteria.- LivingEntity.
updatingUsingItem(): Calls if the item stack used remains in the same hand of the entity.- LivingEntity.
tick(): Called at the beginning aftersuper.tick()(i.e., activated in each ticks after the common updates of all entities but before the other specific updates of living entity). - LivingEntity.
releaseUsingItem(): Called only if theuseItem.useOnRelease(). It only affects crossbow, see § useOnRelease(...).
- LivingEntity.
- LivingEntity.
- LivingEntity.
- ItemStack.
Implementations
onDestroyed(...)
| Declaration Header |
public void |
|---|---|
| Parameters |
ItemEntity itemEntity |
Used for items to drop their contents to be destroyed. By default, nothing happens, having an effect only on instances of classes that implement it, see below.
Uses tree
- Item.
onDestroyed(...)- ItemStack.
onDestroyed(...): This method simply callsonDestroyed(...)implemented in the item stack as item.- ItemEntity.
hurtServer(...): Only called when the hurt is not ignored and the item's health is less than or equal to zero after reviewing the hurt.
- ItemEntity.
- ItemStack.
Implementations
canDestroyBlock(...)
| Declaration Header |
public boolean |
|---|---|
| Parameters |
ItemStack itemStack, BlockState state, Level level, BlockPos pos, LivingEntity user |
Returns false if the player is in creative mode and the item has the tool component with can_destroy_blocks_in_creative set to false. In other cases it returns true.
Note that this method depends exclusively on the component and is not hardcoded. However, the method still has an implementation.
Uses tree
- Item.
canDestroyBlock(...)- ItemStack.
canDestroyBlock(...): This method simply callscanDestroyBlock(...)implemented in the item stack as item.- ServerPlayerGameMode.
destroyBlock(...): Initially, it returns false if the player cannot destroy the block in that position. However, it is still possible for it to return false later in other situations. If it does not return false, the player destroys the block, in addition to some other possible effects (such as dropping).
- ServerPlayerGameMode.
- ItemStack.
Implementations
useOn(...)
| Declaration Header |
public InteractionResult |
|---|---|
| Parameters |
UseOnContext context |
Until Java Edition 26.3, it only returns the interaction result PASS. However, in implementations, in addition to the side effects (the core of the method), it can return interaction results such as FAIL and SUCCESS. These returns can have some subsequent effect as shown in the tree below.
Upcoming Java Edition 26.3, if the block_transformer data default of the item in hand is not empty, it attempts to transform the interacted block, with the return value depending on the transformation; otherwise, it returns FAIL. However, default block_transformer data components exist only for hoes, shovels, and axes; many items still rely on hardcoded usage logic (see the implementations below).
Uses tree
- Item.
useOn(...)- ItemStack.
useOn(...): See below.- ServerPlayerGameMode.
useItemOn(...): See below.- ServerGamePacketListenerImpl.
handleUseItemOn(...): See below.
- ServerGamePacketListenerImpl.
- GameTestHelper.
useBlock(...)andplaceAt(...): Used in GameTest.
- ServerPlayerGameMode.
- PlaceOnWaterBlockItem.
use(...): See § PlaceOnWaterBlockItem.
- ItemStack.
Description of the methods:
- ItemStack.
useOn(...): If the player is in adventure mode and the item stack does not have thecan_place_oncomponent corresponding to the clicked block, it returns fail.
- Otherwise, call the method implemented in the item stack as item. If the method returns
SUCCESSincreases the itemusedstatistic by one. Returns the return value of the called method.
- ServerPlayerGameMode.
useItemOn(...): Returns falls if the block being hit is exclusive of a unenabled experiment. The current version 1.21.11 does not have such blocks in the game.
- If the player is in the spectator mode: if the block has a menu, open the menu and return
CONSUME, otherwise returnPASS. - If the player is not sneaking or doesn't have items in either hand:
- The player will attempt to use the item, or the empty hand, on the block. However, for this use, the previous method will not be used, but rather
state.useItemOn(...), which is a method controlled by the block (state). Sometimes this method will give different results depending on the item used; see § Items member access for details. - If the interaction returns any success,
item_used_on_blockis activated and the method is completed, returning the same result. - If the interaction returns
TRY_WITH_EMPTY_HANDand the interacting hand is the mainhand, the player attempts to interact with the block using thestate.useWithoutItem(...)method.- If the interaction returns any success,
default_block_useis activated the method is completed, returning the same result.
- If the interaction returns any success,
- If neither
state.useItemOn(...)norstate.useWithoutItem(...)returns success, the method continues.
- The player will attempt to use the item, or the empty hand, on the block. However, for this use, the previous method will not be used, but rather
- If the item stack is empty or in cooldown, return
PASS. - Finally, the
ItemStack.useOn(...)method is called. If the player is in creative mode, the stack item quantity is restored, preventing any loss due to the called method. If the return is successful, theitem_used_on_blockis activated. Returns the return of the called method. - In DemoMode, output demo reminder and return
PASS, if demo timer has end. Otherwise, it calls the supermethod, so the method will proceed normally.
- ServerGamePacketListenerImpl.
handleUseItemOn: Initially, it tests if the interaction is allowed, if positive, call the method. If the return of the called method is successful, theany_block_useis activated.
- If the interaction is unsuccessful, the interaction direction is up, the interacted block is at its maximum height, and the item is a § BlockItem or § BucketItem instance with non-empty fluid and is not on cooldown, then send the system error message in action bar with the translation of
build.tooHighwith the maximum height value of the dimension. - If the return of the called method is
SUCCESSorSUCCESS_SERVER, the player swings the hand used.
Implementations
ArmorStandItem
AxeItem[until: JE 26.3]
BlockItem
BoneMealItem
BrushItem
CompassItem*
CushionItem[upcoming: JE 26.3]
DebugStickItem
EndCrystalItem
EnderEyeItem
FireChargeItem
FireworkRocketItem
FlintAndSteelItem
HangingEntityItem
HoeItem[until: JE 26.3]
HoneycombItem
LeadItem
MapItem*
MinecartItem
PlaceOnWaterBlockItem
PotionItem
ShearsItem*
ShovelItem[until: JE 26.3]
SolidBucketItem*
SpawnEggItem
* The implementation uses a supermethod, calling that method.
use(...)
finishUsingItem(...)
isBarVisible(...)
getBarWidth(...)
getBarColor(...)
overrideStackedOnOther(...)
overrideOtherStackedOnMe(...)
getAttackDamageBonus(...)
getItemDamageSource(...)
hurtEnemy(...)
postHurtEnemy(...)
mineBlock(...)
interactLivingEntity(...)
inventoryTick(...)
onCraftedPostProcess(...)
getUseAnimation(...)
getUseDuration(...)
releaseUsing(...)
appendHoverText(...)
getTooltipImage(...)
getName(...)
isFoil(...)
useOnRelease(...)
getDefaultInstance()
canFitInsideContainerItems()
shouldPrintOpWarning(...)
Item subclasses
Only subsections marked with an asterisk (*) aren't empty.
AirItem*
ArmorStandItem*
ArrowItem*
AxeItem[until: JE 26.3]
BannerItem*
BedItem*[until: JE 26.3]
BlockItem*
BoatItem*
BoneMealItem*
BottleItem*
BowItem
BrushItem
BucketItem
BundleItem
CompassItem*
CrossbowItem
CushionItem*[upcoming: JE 26.3]
DebugStickItem*
DiscFragmentItem*
DoubleHighBlockItem*
DyeItem*
EggItem*
EmptyMapItem*
EndCrystalItem*
EnderEyeItem*
EnderpearlItem*
ExperienceBottleItem*
FireChargeItem*
FireworkRocketItem*
FishingRodItem*
FlintAndSteelItem*
FoodOnAStickItem*
GameMasterBlockItem*
GlowInkSacItem*
HangingEntityItem
HangingSignItem
HoeItem[until: JE 26.3]
HoneycombItem
InkSacItem
InstrumentItem
Item
ItemFrameItem
KnowledgeBookItem
LeadItem
LingeringPotionItem
MaceItem
MapItem
MinecartItem
MobBucketItem
NameTagItem*
PlaceOnWaterBlockItem
PlayerHeadItem
PotionItem*
ProjectileWeaponItem
ScaffoldingBlockItem
ShearsItem
ShieldItem*
ShovelItem[until: JE 26.3]
SignItem
SmithingTemplateItem*
SnowballItem
SolidBucketItem
SpawnEggItem
SpectralArrowItem
SplashPotionItem
SpyglassItem
StandingAndWallBlockItem
ThrowablePotionItem
TippedArrowItem
TridentItem
WindChargeItem
WritableBookItem*
WrittenBookItem*
AirItem
{
"title": "AirItem",
"rows": [
{
"field": "AirItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:BlockSprite air.png article, displayed as 16x16px|link=Air|alt=|class=pixel-image|)</span>(link to Air article, displayed as <span class=\"sprite-text\">Air</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
Air has a block descriptionId, meaning its translation key is minecraft.block.air. However, unlike other items with this descriptionId, air is not an instance of BlockItem, because AirItem does not extend BlockItem.
getName(...)
Defined ignoring the item stack components, therefore, it is always a translation of minecraft.block.air regardless of the component item_name.
This has an effect on stacked items that are treated as if they were air (for example, items with a count of 0).
Note that many other properties of the air item are defined elsewhere in the code. See § Items member access.
ArmorStandItem
{
"title": "ArmorStandItem",
"rows": [
{
"field": "ArmorStandItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite armor-stand.png article, displayed as 16x16px|link=Armor Stand|alt=|class=pixel-image|)</span>(link to Armor Stand article, displayed as <span class=\"sprite-text\">Armor Stand</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
useOn(...)
If the interaction involves clicking on the bottom face of a block, it fails.
The target position for placing the armor stand is the bottom center of the block next to the interacted block, in the direction of the interacted face. The game simulates the hitbox of an armor stand in this position; if the hitbox collides with a block or intersects with an entity hitbox (except spectators), the interaction fails.
The game attempts to obtain the armor stand, based on the item's components custom_name, custom_data, and entity_data. If it cannot be generated, the interaction fails.
If the armor stand is generated, apply in the following order:
- The armor stand rotates 202.5° according to the player's rotation, but rounds its rotation down to some multiple of 45°;
- The sound event armor stand place (
entity.armor_stand.place) is played; - The game event
entity_placeis produced; - The item stack is shrunk by one.
The interaction returns success given no aforementioned fails occur.
Armor stand entity data:
- [NBT Compound / JSON Object] Entity data
- Default tags apply components from the item stack when creating an entity. see Template:Nbt inherit/apply_components_from_item_stack/template
- [String] id:
minecraft:armor_stand. - [NBT List / JSON Array] Pos: The target position. Try moving up to one block down, looking for a collision box that connects with the armor support's hitbox. This attempt is made before applying the
entity_datacomponent. - [NBT List / JSON Array] Rotation:
- [Float]: See above.
- [Float]:
0.0f.
- [Undefined] <most tag>: With the exception of id, Rotation, Passengers , and UUID, it can be defined by
entity_data. Theentity_dataonly has an effect if theentity_data.idisminecraft:armor_stand. CustomName, data, and Pos have priority to be defined by componententity_data.
ArrowItem
{
"title": "ArrowItem",
"rows": [
{
"field": "ArrowItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite arrow.png article, displayed as 16x16px|link=Arrow|alt=|class=pixel-image|)</span>(link to Arrow article, displayed as <span class=\"sprite-text\">Arrow</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite spectral-arrow.png article, displayed as 16x16px|link=Spectral Arrow|alt=|class=pixel-image|)</span>(link to Spectral Arrow article, displayed as <span class=\"sprite-text\">Spectral Arrow</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite tipped-arrow.png article, displayed as 16x16px|link=Tipped Arrow|alt=|class=pixel-image|)</span>(link to Tipped Arrow article, displayed as <span class=\"sprite-text\">Tipped Arrow</span>)</span></div>",
"label": "Items"
},
{
"field": "<div class=\"hlist \" ><code>ProjectileItem</code></div>",
"label": "Implements"
},
{
"field": "<div class=\"hlist \" >\n*(link to #SpectralArrowItem article, displayed as <span nowrap;\">§ SpectralArrowItem</span>)\n*(link to #TippedArrowItem article, displayed as <span nowrap;\">§ TippedArrowItem</span>)</div>",
"label": "Implementations"
}
],
"invimages": [],
"images": []
}
createArrow(...)
Creates an AbstractArrow projectile entity from the item.
Used by createProjectile in § ProjectileWeaponItem, and by skeletons and illusioners via § ProjectileUtil.
For regular arrows, creates an arrow projectile with:
- [NBT Compound / JSON Object] Entity data
- Default tags apply components from the item stack when creating an entity. see Template:Nbt inherit/apply_components_from_item_stack/template
- [String] id:
minecraft:arrow. - [NBT List / JSON Array] Pos:
- [Double]: Owner's X coordinate.
- [Double]: Owner's eye Y coordinate minus
0.1. - [Double]: Owner's Z coordinate.
- [NBT Compound / JSON Object] item: The item stack copy, with count 1.
- [NBT Compound / JSON Object] weapon: The fired from weapon copy, if it exists.
- [Byte] PierceLevel: According to the effect components
projectile_piercingof the weapon enchantments, if it exists. The item stack can be used for requirements. - [Byte] pickup:
2b(creative only) if the item has the componentintangible_projectile,1b(allowed) otherwise. - [Int Array] Owner: The owner UUID.
asProjectile(...)
Creates an arrow projectile not fired from any weapon, used by dispensers and ominous item spawners, with:
- [NBT Compound / JSON Object] Entity data
- Default tags apply components from the item stack when creating an entity. see Template:Nbt inherit/apply_components_from_item_stack/template
- [String] id:
minecraft:arrow. - [NBT List / JSON Array] Pos: The position.
- [NBT Compound / JSON Object] item: The item stack copy, with count 1.
- [Byte] pickup:
1b(allowed), regardless ofintangible_projectile.
AxeItem
Note: Class removed in 26.3-snap2. Axes are now just Item.
{
"title": "AxeItem",
"rows": [
{
"field": "AxeItem",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
}
],
"invimages": [],
"images": []
}
useOn(...)
BannerItem
{
"title": "BannerItem",
"rows": [
{
"field": "BannerItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" ><span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite banners.png article, displayed as 16x16px|link=Banner|alt=|class=pixel-image|)</span>(link to Banner article, displayed as <span class=\"sprite-text\">Banner</span>)</span> (ColorCollection)</div>",
"label": "Items"
},
{
"field": "(link to #StandingAndWallBlockItem article, displayed as <span nowrap;\">§ StandingAndWallBlockItem</span>) ((link to #BlockItem article, displayed as <span nowrap;\">§ BlockItem</span>) )",
"label": "Extends"
}
],
"invimages": [],
"images": []
}
getColor()
Used by the crafting_special_bannerduplicate recipe type to determine whether the banner colors match, and by the crafting_special_shielddecoration recipe type to set the base_color of the shield.
This is done by calling the getColor method of AbstractBannerBlock on the item's block form, and as such the block forms of a BannerItem must extend AbstractBannerBlock.
BedItem
Note: Class removed in 26.3-snap1. Beds are now just BlockItem.
{
"title": "BedItem",
"rows": [
{
"field": "BedItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" ><span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite beds.png article, displayed as 16x16px|link=Bed|alt=|class=pixel-image|)</span>(link to Bed article, displayed as <span class=\"sprite-text\">Bed</span>)</span> (ColorCollection)</div>",
"label": "Items"
},
{
"field": "(link to #BlockItem article, displayed as <span nowrap;\">§ BlockItem</span>)",
"label": "Extends"
}
],
"invimages": [],
"images": []
}
placeBlock(...)
Set the block with update flags of 26 instead of 11.
BlockItem
{
"title": "BlockItem",
"rows": [
{
"field": "BlockItem",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Implementations"
}
],
"invimages": [],
"images": []
}
Each item in this class is associated with a block, defined in Items. With few exceptions, the item has the same id as the associated block and minecraft.block.<id> is the item's descriptionId.
Item overrides methods
useOn(...)
Try placing the block with place(...) (see § Place for details).
If the result of place is any success and the item does not have the component consumable, return that result from place.
Otherwise, use the item (see § use(...)) and return the result of use.
shouldPrintOpWarning(...)
If the player has Permission level gamemaster (level 2) and the item has the component block_entity_data, it returns true if the block entity id is command_block, lectern, sign, hanging_sing, mob_spawner, or trial_spawner. Otherwise, it returns false.
canFitInsideContainerItems()
Returns false if the associated block is an instance of ShulkerBoxBlock, in other words, one of the 17 shulker boxes.
onDestroyed(...)
Set the container component of the entity item to empty. If the component existed previously, drop all the item stacks it contained at the entity item's position.
Place
Block by item
There are two methods in BlockItem related to associating the item with its associated block and vice-versa:
getBlock(): Returns the blockthis.block, defined when registering the item in Items.registerBlocks(...): Put the pair(this.getBlock(), item)inmap. Used only with the Item.BY_BLOCKmap.
In Items, ItemBlocks are registered using either the registerBlock(...) method or the createBlockItemWithCustomItemName(...) method.
In registerBlock() given a block, an item is created with the same id, and with the block description id, after that registerBlocks is used to save the block and item in Item.BY_BLOCK. There are some variations, which can be summarized as: adding default components to the item (by § Item.Properties), making the item a different class, a subclass of ItemBlock and put alternative blocks in Item.BY_BLOCK.
Only two items have alternate blocks:
Big Dripleaf: has the
Big Dripleaf Stem as an alternate block,
Cauldron: has
Water Cauldron,
Lava Cauldron, and
Powder Snow Cauldron as alternate blocks.
However, in § StandingAndWallBlockItem, there is an override of registerBlocks(...), adding the wallblock corresponding to each item in the list.
In createBlockItemWithCustomItemName(...) the item's ID is defined separately and uses the item's description ID. Items can have other default components, but it is always a BlockItem and not a subclass. Below is the complete list of items registered with this method:
| Item | Item id | Block | Block id |
|---|---|---|---|
resin_clump |
resin_clump
| ||
redstone |
redstone_wire
| ||
string |
tripwire
| ||
wheat_seeds |
wheat
| ||
cocoa_beans |
cocoa
| ||
pumpkin_seeds |
pumpkin_stem
| ||
melon_seeds |
melon_stem
| ||
nether_wart |
nether_wart
| ||
carrot |
carrots
| ||
potato |
potatoes
| ||
torchflower_seeds |
torchflower
| ||
pitcher_pod |
pitcher_crop
| ||
beetroot_seeds |
beetroots
| ||
sweet_berries |
sweet_berry_bush
| ||
glow_berries |
cave_vines
|
Resin clump and nether wart has the same ID but it still has different ID descriptions.
The method registerBlocks(...) is only used in Items, however getBLock() has many more uses.
[...]
The Item.BY_BLOCK map is used in the Item.byBlock(...) method, where for each block it searches for its associated item, and if it doesn't exist, it associates it with the air item. This method is used only in Block.asItem() which returns the item associated with the block. The Block.asItem() method, however, has multiple uses.
[...]
Usage in instanceof
BoatItem
{
"title": "BoatItem",
"rows": [
{
"field": "BoatItem",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
}
],
"invimages": [],
"images": []
}
use(...)
Checks if the player is looking at a block (including fluids) and passes if not. Then checks if any pickable entities' pick hitboxes contain the player's eye position and passes if so.
Then tries to create a boat entity with a type hardcoded for each item ID at the block targeted and fails if the entity cannot be created. If it is spawned, its yaw rotation is set to the player's yaw rotation. Then fails if the boat is intersecting anything except fluid.
Finally, adds the boat to the world, produces an entity_place game event, consumes one item from the stack, adds to the item used statistic, and succeeds.
BoneMealItem
{
"title": "BoneMealItem",
"rows": [
{
"field": "BoneMealItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite bone-meal.png article, displayed as 16x16px|link=Bone Meal|alt=|class=pixel-image|)</span>(link to Bone Meal article, displayed as <span class=\"sprite-text\">Bone Meal</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
All the behavior of bone meal is hardcoded in this class.
useOn(...)
First calls growCrop. If it returns true, the interaction succeeds, the stack shrinks by one, world event 1505 (bone meal particles and sound) is caused, and an item_interact_finish game event is produced.
Otherwise, checks if a full solid face was clicked (passing if not) and calls growWaterPlant, succeeding as described above if it returns true. If it returns false, the interaction passes.
growCrop(...)
Tries to bone meal a BonemealableBlock. If it is valid, regardless of whether it succeeds, returns true (otherwise returns false).
Also used by dispensers and § UseBonemeal.
growWaterPlant(...)
Attempts to grow plants underwater, defaulting to seagrass. Returns false if the block next to the clicked face is not a full water block, and true otherwise.
If used in a biome in #produces_corals_from_bonemeal, the block next to the clicked face is replaced with a random block in #wall_corals if a side face was clicked, and other seagrass blocks that would be placed have a 1/4 chance of being replaced with random blocks from #underwater_bonemeals.
Also used by dispensers.
BottleItem
{
"title": "BottleItem",
"rows": [
{
"field": "BottleItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite glass-bottle.png article, displayed as 16x16px|link=Glass Bottle|alt=|class=pixel-image|)</span>(link to Glass Bottle article, displayed as <span class=\"sprite-text\">Glass Bottle</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
use(...)
First checks for area effect clouds owned by an ender dragon (i.e. dragon's breath) within 2 blocks of the player's hitbox. If there is at least one, picks one and reduces its radius by 0.5, plays the item.bottle.fill_dragonbreath sound event, produces a fluid_pickup game event, triggers the player_interacted_with_entity advancement trigger, transforms a bottle (or all of them, if the player is in Creative mode) into dragon's breath, and succeeds.
If there is not any dragon's breath, checks if the player is interacting with water (passing otherwise) and plays the item.bottle.fill sound event, produces a fluid_pickup game event, transforms a bottle (or all of them) into a water bottle, and succeeds.
BowItem
BrushItem
BucketItem
BundleItem
CompassItem
{
"title": "CompassItem",
"rows": [
{
"field": "CompassItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite compass.png article, displayed as 16x16px|link=Compass|alt=|class=pixel-image|)</span>(link to Compass article, displayed as <span class=\"sprite-text\">Compass</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
isFoil(...)
Overridden to true if this stack has the lodestone_tracker component.
inventoryTick(...)
If this stack has the lodestone_tracker component, updates the tracker (i.e. sets it to empty if it is invalidated).
useOn(...)
If the clicked block was a lodestone, instead play the item.lodestone_compass.lock sound event and create a lodestone compass by setting the lodestone_tracker component. If in creative mode or with a stack size greater than 1, all components are copied to a new item that gains lodestone_tracker and the original stack is shrunk by one. The interaction succeeds.
getName(...)
If this stack has the lodestone_tracker component, instead return the lodestone compass item name (translation item.minecraft.lodestone_compass)
CrossbowItem
CushionItem
Note: Class add in 26.3-snap3.
Reason: Significant changes in 26.3-snap4
{
"title": "CushionItem",
"rows": [
{
"field": "CushionItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" ><span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite cushions.png article, displayed as 16x16px|link=Cushion|alt=|class=pixel-image|)</span>(link to Cushion article, displayed as <span class=\"sprite-text\">Cushion</span>)</span> (ColorCollection)</div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
useOn(...)
Position the cushion. Method partially described in Cushion § Placement.
The interaction fails if the clicked face is not the up fece. Otherwise, summon an Axis-Aligned Bounding Box (AABB) with size of a cushion's hitbox (16×4×16 pixels), the X and Z axes centered on the interlocking block, and the minimum of the Y-axis at the clicked position.
If a cushion cannot survive in the AABB block (Cushion.wouldSuriveAt(level, spawnAABB)), the interaction fails. The test consists of invoking a new AABB block with the same width, but 1⁄4 of a pixel higher than the existing AABB block, below the existing AABB. Then, it checks if at least one block position (entire position) containing the new AABB has a block whose interaction box intersects the AABB. If no block intersects, the test fails.
At this point, the interaction returns success on the client side, and so the player moves their hand. Although the interaction may still fail on the server side, as described below:
- If the hitbox of an existing cushion is intersected by the AABB, the interaction fails.
- Try summoning a cushion, with
CustomNameanddatadefined repeatedly by thecustom_nameandcustom_datacomponents of the item stack. If, for some reason, it is not possible to invoke it, the interaction fails. - Position the cushion in the same position as the AABB. The y-rotation of the cushion is defined by
mod(90 × floor((yRot + 0.5) ÷ 90), 360), whereyRotis the player's y-rotation. The x-rotation is defined as zero. - Set the cushion color to match the item color (the item color is defined by ColorCollection when registering them).
- Play sound event cushion place (
entity.cushion.place) - Produce the game event
entity_place(output 14) - Consumes one item from the player, except if the player is in creative mode.
The interaction returns success given no aforementioned fails occur.
DebugStickItem
{
"title": "DebugStickItem",
"rows": [
{
"field": "DebugStickItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite debug-stick.png article, displayed as 16x16px|link=Debug Stick|alt=|class=pixel-image|)</span>(link to Debug Stick article, displayed as <span class=\"sprite-text\">Debug Stick</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
Handles all the behavior of the debug stick as described on its page.
canDestroyBlock(...)
Always returns false, and triggers an interaction selecting a block state.
useOn(...)
Triggers an interaction cycling the value of a block state, failing if that interaction fails (if the player cannot use game master blocks, if the block has no properties, or if the item does not have the debug_stick_state component) and succeeding otherwise.
DiscFragmentItem
{
"title": "DiscFragmentItem",
"rows": [
{
"field": "DiscFragmentItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite disc-fragment.png article, displayed as 16x16px|link=Disc Fragment|alt=|class=pixel-image|)</span>(link to Disc Fragment article, displayed as <span class=\"sprite-text\">Disc Fragment</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
appendHoverText(...)
Define the first line of the tooltip as the translation of item.minecraft.disc_fragment.desc in gray (
#AAAAAA).
This line cannot be hidden by the tooltip_display component, except to completely hide the tooltip with hide_tooltip set to true.
DoubleHighBlockItem
{
"title": "DoubleHighBlockItem",
"rows": [
{
"field": "DoubleHighBlockItem",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "(link to #BlockItem article, displayed as <span nowrap;\">§ BlockItem</span>)",
"label": "Extends"
}
],
"invimages": [],
"images": []
}
placeBlock(...)
Sets the block above to water if there is water above (including waterlogged blocks) and air otherwise before placing the block normally, effectively replacing the block above while leaving water intact for waterlogging.[more information needed]
DyeItem
{
"title": "DyeItem",
"rows": [
{
"field": "DyeItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" ><span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite dye.png article, displayed as 16x16px|link=Dye|alt=|class=pixel-image|)</span>(link to Dye article, displayed as <span class=\"sprite-text\">Dye</span>)</span> (ColorCollection)</div>",
"label": "Items"
},
{
"field": "<div class=\"hlist \" ><code>SignApplicator</code></div>",
"label": "Implements"
}
],
"invimages": [],
"images": []
}
Each item has a default dye component, defined in Items.
When two sheep, cats, or dogs breed, take the color of each parent (the color of the wool or the color of the collar) and search all items that have the component dye of that color as a default and try to create the first recipe for each pair. If the result of some of these recipes is an item with the component dye, that color will be used for the offspring; otherwise, a random color from the parents is added.
Thus, the color of these animals depends on the hardcoded property of the dyes, and the color can only be edited along with the item's recipes. Only dyes have the component dye by default, and each value of the component exists in exactly one dye.
interactLivingEntity(...)
The interaction is only successful, instead of pass, when the interacting entity is a non-sheared live sheep of a different color than the dye component and the item stack has a dye component.
In case of success, the sound dye use is played, set the sheep color and shrink the item stack by one.
tryApplyToSign(...)
If the stack item does not contain the dye component, it returns false.
Try changing the text color on the sign, on the side being interacted with, to the color of the dye.
In case of success, the dye used sound is played and returns true. Otherwise, returns false.
EggItem
{
"title": "EggItem",
"rows": [
{
"field": "EggItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite blue-egg.png article, displayed as 16x16px|link=Blue Egg|alt=|class=pixel-image|)</span>(link to Blue Egg article, displayed as <span class=\"sprite-text\">Blue Egg</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite brown-egg.png article, displayed as 16x16px|link=Brown Egg|alt=|class=pixel-image|)</span>(link to Brown Egg article, displayed as <span class=\"sprite-text\">Brown Egg</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite egg.png article, displayed as 16x16px|link=Egg|alt=|class=pixel-image|)</span>(link to Egg article, displayed as <span class=\"sprite-text\">Egg</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
use(...)
Always succeeds. Plays the entity.egg.throw sound effect, consumes an item, awards statistics, and spawns an egg projectile with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:egg - [NBT List / JSON Array] Pos:
- [Double]: Owner's X coordinate.
- [Double]: Owner's eye Y coordinate minus
0.1. - [Double]: Owner's Z coordinate.
- [NBT Compound / JSON Object] Item: a copy of the item stack with the count set to 1.
- [Int Array] Owner: The player UUID.
- [String] id:
The projectile is fired with an uncertainty of 1 and a power of 1.5.
asProjectile(...)
Used by dispensers and ominous item spawners. Creates an egg projectile with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:egg - [NBT List / JSON Array] Pos: The position.
- [NBT Compound / JSON Object] Item: a copy of the item stack with the count set to 1.
- [String] id:
No item components are used.
EmptyMapItem
{
"title": "EmptyMapItem",
"rows": [
{
"field": "EmptyMapItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite empty-map.png article, displayed as 16x16px|link=Empty Map|alt=|class=pixel-image|)</span>(link to Empty Map article, displayed as <span class=\"sprite-text\">Empty Map</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
use(...)
Always succeeds. Consumes an item, awards statistics, plays the ui.cartography_table.take_result sound effect, creates map data from the player's X and Z position, with a scale of 0, that tracks their position within range, and gives the player a filled map with its map_id component pointing to that map data.
EndCrystalItem
{
"title": "EndCrystalItem",
"rows": [
{
"field": "EndCrystalItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite end-crystal.png article, displayed as 16x16px|link=End Crystal|alt=|class=pixel-image|)</span>(link to End Crystal article, displayed as <span class=\"sprite-text\">End Crystal</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
useOn(...)
Fails if the block clicked is not obsidian or bedrock, or if the block above the one clicked is not empty. Then checks for entities in a 1x2x1 box above the clicked block and fails if there are any.
If none of those checks failed, the interaction succeeds, the stack is shrunk by 1, and an end crystal is spawned with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:end_crystal - [NBT List / JSON Array] Pos: The bottom center of the block above the one clicked.
- [Boolean] ShowBottom:
false
- [String] id:
No item components are used.
Triggers an entity_place game event, and checks if the ender dragon should be respawned if the current dimension has a dragon fight.
EnderEyeItem
{
"title": "EnderEyeItem",
"rows": [
{
"field": "EnderEyeItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite eye-of-ender.png article, displayed as 16x16px|link=Eye of Ender|alt=|class=pixel-image|)</span>(link to Eye of Ender article, displayed as <span class=\"sprite-text\">Eye of Ender</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
getUseDuration(...)
Always returns 0, ignoring item components.
useOn(...)
Passes if the targeted block is not an end portal frame or if the frame is already with eye. Then always succeeds, pushes entities up to compensate for the block's new shape (see details below), sets the targeted frame's eye state to true, shrinks the stack by 1, updates attached comparators, and causes world event 1503.
Then checks if and where an end portal should be activated, and fills the end portal blocks accordingly, causing world event 1038 globally from the center of the 3x3 portal. See End portal § Creation for more information on activating the portal.
Entity push details: all entities, except spectator players, whose bounding box intersects the new parte of the end portal frame's collision box (known as 8x3x8 pixels, centered on the top face) are subject to push attempts. The entity attempts to move one block upward and stops when it ceases to intercept the collision box; if it fails, it does not move. If it succeeds, it teleports. Note that this moves entities like cushions[upcoming: JE 26.3], which normally don't move.
use(...)
Passes if the player is targeting an end portal frame, even if filled.
Then starts using the item, and tries to find a structure in #eye_of_ender_located, using the same method used in /locate structure #eye_of_ender_located. The found structure is not necessarily the closest[2]. The search process occurs in the following steps.
- If the tag is empty, the debug flag
DISABLE_FEATURESis enable, or world option Generate Structures is false, return null - List all structure sets that have at least one structure in the tag, prioritizing structures in tag order. If the list is empty, return null.
- For all
concentric_ringstype structure sets, search for all chunks where the set of structures can be positioned and check if any exist. If found a structure that is in the tag, consider it as block position(chunkX+8, 32, chunkZ+8). Save the block position innearestand indthe euclidian distance from the player's block to that position, if it is the first structure found or if the distance is less than or equal to the previousd. - For all
random_spreadtype structure sets, search for structures in a 201×201 grid of N×N chunks, where N is the [Int] spacing of the structure set. For each region, a structure is searched for up to one structure.- First, search in regions closest to the center, with a manhattan distance (radius varying from 0 to 100). For regions with the same manhattan distance, prioritize those with the smallest X-axis; for regions with the same X-axis, prioritize those with the smallest Z-axis.
- Upon finding a structure (that is in the tag) with a certain radius, no further searches are made for structures with larger radius, from any structure set. This can lead to premature searches when finding a structure with a large spacing.
- Upon finding a structure (that is in the tag) with a certain radius, no further searches are made for structures from the same structure set. This creates priority for structures with smaller X or Z axes, even if they are further away from other structures in the same structure set.
- Each structure found saves its position depending on its chunk position and the [NBT List / JSON Array] locate_offset of the structure set. If the player's block position distance is less than or equal to
d, updatedandnearest.
- Retunr
nearest(null if none is found).
The interaction ends and returns to consume if nothing is found.
If one is found, a projectile_shoot game event is produced, and an eye of ender projectile is created with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:eye_of_ender - [NBT List / JSON Array] Pos: The center of the player's bounding box.
- [NBT Compound / JSON Object] Item: The item stack with the count set to 1.
- [String] id:
The ender eye is set to target to the structure, but this is not serialized as NBT data[3]. They are saved in three local variables, all of which are reset when the entity is reloaded:
- [NBT List / JSON Array] target: It may not exist. If this exists, each tick changes the [NBT List / JSON Array] Motion of the ender eye as it approaches that position. Defined as
(dx, dy, dz)ifh = (dx^2 + dz^2) ≥ 12or(dx/h, dy, dz/h)otherwise, wheredx,dy, anddzare the distance from the corner of the block positionnearestminus the initial position of the ender eye. Set to null on reload. - [Int] live: Each tick increases by one; if it exceeds 80, it emits the
entity.ender_eye.deathsound event (volume 1, pitch 1) and the eye is destroyed. Set to 0. Set to 0 on reload. - [Boolean] surviveAfterDeath: Defines what happens after the eye is destroyed, in the entity's position. If true, it summons an item entity with the same ID as the eye; the components are "not" preserved. If false, causes world event 2003. Randomly defined with an 80% chance of being
true. Set tofalseon reload.
Finally, trigger the advancement trigger used_ender_eye, with a distance is calculated by xd^2 + zd^2, where xd, and zd are the distance from the player and nearest, the entity.ender_eye.launch sound event is played at a random pitch between 0.33 and 0.5, an item is consumed, and statistics (used:ender_eye) are awarded. Return success_server.
EnderpearlItem
{
"title": "EnderpearlItem",
"rows": [
{
"field": "EnderpearlItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite ender-pearl.png article, displayed as 16x16px|link=Ender Pearl|alt=|class=pixel-image|)</span>(link to Ender Pearl article, displayed as <span class=\"sprite-text\">Ender Pearl</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
use(...)
Always succeeds. Plays the entity.ender_pearl.throw sound effect, consumes an item, awards statistics, and spawns an ender pearl projectile with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:ender_pearl - [NBT List / JSON Array] Pos:
- [Double]: Owner's X coordinate.
- [Double]: Owner's eye Y coordinate minus
0.1. - [Double]: Owner's Z coordinate.
- [NBT List / JSON Array] Motion: It depends on the owner's rotation ( and ):
- [Double]:
- [Double]:
- [Double]:
- [NBT List / JSON Array] Rotation: It depends on the [NBT List / JSON Array] Motion (, , ):
- [Float]:
- [Float]:
- [NBT Compound / JSON Object] Item: a copy of the item stack with the count set to 1.
- [Int Array] Owner: The player UUID.
- [Undefined] <any tag>: NBT ags that vary by entity effect according to enchantments with the
projectile_spawnedeffect component on theenchantmentsitem component. It is calculated last. Such effects have an eventual scope beyond the tags.
- [String] id:
The projectile is fired with an uncertainty of 1 and a power of 1.5, defined the motion and rotation (see above).
ExperienceBottleItem
{
"title": "ExperienceBottleItem",
"rows": [
{
"field": "ExperienceBottleItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite bottle-o'-enchanting.png article, displayed as 16x16px|link=Bottle o' Enchanting|alt=|class=pixel-image|)</span>(link to Bottle o' Enchanting article, displayed as <span class=\"sprite-text\">Bottle o' Enchanting</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
use(...)
Always succeeds. Plays the entity.experience_bottle.throw sound effect, consumes an item, awards statistics, and spawns an experience bottle projectile with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:experience_bottle - [NBT List / JSON Array] Pos:
- [Double]: Owner's X coordinate.
- [Double]: Owner's eye Y coordinate minus
0.1. - [Double]: Owner's Z coordinate.
- [NBT Compound / JSON Object] Item: a copy of the item stack with the count set to 1.
- [Int Array] Owner: The player UUID.
- [String] id:
The projectile is fired with an uncertainty of 1, a power of 0.7, and a pitch offset of -20°.
asProjectile(...)
Used by dispensers and ominous item spawners. Creates an experience bottle projectile with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:experience_bottle - [NBT List / JSON Array] Pos: The position.
- [NBT Compound / JSON Object] Item: a copy of the item stack with the count set to 1.
- [String] id:
No item components are used.
createDispenseConfig()
Sets the projectile to be dispensed at 0.5 times the default uncertainty and 1.25 times the default power.
See Projectile#Shot from dispenser for these values.
FireChargeItem
{
"title": "FireChargeItem",
"rows": [
{
"field": "FireChargeItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite fire-charge.png article, displayed as 16x16px|link=Fire Charge|alt=|class=pixel-image|)</span>(link to Fire Charge article, displayed as <span class=\"sprite-text\">Fire Charge</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
useOn(...)
First checks if the targeted block is an unlit campfire, soul campfire, candle, dyed candle, cake with candle, or cake with dyed candle. If so, its lit state is set to true, the item.firecharge.use sound effect is played, a block_change game event is produced.
If not, checks if a fire block can be placed adjacent to the clicked face, and if so places the fire block, emits the sound effect, produces a block_place game event.
If either case succeeded, the stack is shrunk by 1 and the interaction succeeds. Otherwise the interaction fails.
asProjectile(...)
Used by dispensers and ominous item spawners. Randomizes the direction slightly and creates a small fireball projectile with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:small_fireball - [NBT List / JSON Array] Pos: The position.
- [NBT List / JSON Array] Motion: The randomized direction. Each axis receives the value -1, 0, or 1 (depending on the direction) plus a random number
(nextDouble()−nextDouble())×0.11485000000000001. Each axis has the random number calculated separately. After that, the vector is normalized and mutilates by 0.1.[more information needed] - [NBT Compound / JSON Object] Item: A copy of the item stack with the count set to 1.
- [String] id:
shoot(...)
Overridden to do nothing, since [NBT List / JSON Array] Motion is set by asProjectile instead.
createDispenseConfig()
Sets the projectile to be dispensed fully outside the dispenser, with an uncertainty of 6.6666665, a power of 1, and a world event override of 1018.
FireworkRocketItem
{
"title": "FireworkRocketItem",
"rows": [
{
"field": "FireworkRocketItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite firework-rocket.png article, displayed as 16x16px|link=Firework Rocket|alt=|class=pixel-image|)</span>(link to Firework Rocket article, displayed as <span class=\"sprite-text\">Firework Rocket</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
useOn(...)
Passes if not used by a gliding player. Otherwise succeeds, shrinking the stack by 1 and spawning a firework rocket projectile with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:firework_rocket - [NBT List / JSON Array] Pos: The clicked location, offset away from the block by 0.15 blocks.
- [NBT Compound / JSON Object] FireworksItem: A copy of the item stack.
- [Int] Life: 0
- [Int] LifeTime: The firework lifetime depending on its
fireworkscomponent: 10 *flight_duration(or 0 if there is nofireworkscomponent) + random(0 to 5) + random(0 to 6) - [Int Array] Owner: The player UUID.
- [String] id:
use(...)
Passes unless the player is gliding. Otherwise succeeds, breaking all leads attached to the player (and playing item.lead.break if there were any), consuming one item, awarding statistics, and spawning a firework rocket projectile stuck to the player (which is not serialized as NBT data) with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:firework_rocket - [NBT List / JSON Array] Pos: The player's position.
- [NBT Compound / JSON Object] FireworksItem: A copy of the item stack.
- [Int] Life: 0
- [Int] LifeTime: The firework lifetime, same formula as above.
- [Int Array] Owner: The player UUID.
- [String] id:
asProjectile(...)
Creates a firework rocket projectile with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:firework_rocket - [NBT List / JSON Array] Pos: The position.
- [NBT Compound / JSON Object] FireworksItem: A copy of the item stack with the count set to 1.
- [Int] Life: 0
- [Int] LifeTime: The firework lifetime, same formula as above.
- [Boolean] ShotAtAngle:
true
- [String] id:
createDispenseConfig()
Sets the projectile to be dispensed 0.50001 blocks away from the center of the dispenser, with an uncertainty of 1, a power of 0.5, and a world event override of 1004.
FishingRodItem
{
"title": "FishingRodItem",
"rows": [
{
"field": "FishingRodItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite fishing-rod.png article, displayed as 16x16px|link=Fishing Rod|alt=|class=pixel-image|)</span>(link to Fishing Rod article, displayed as <span class=\"sprite-text\">Fishing Rod</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
use(...)
Always succeeds.
If the player does not already have a fishing hook attached:
- The
entity.fishing_bobber.throwsound effect is played. - The
fishing_time_reductionandfishing_luck_bonuseffect components are applied from enchantments on the item stack, they define local fishing bobber variables without saving them in the NBT tag:- [Int] luck: Used in the loot context of the fishing loot table,
LootContext.luck = this.luck + owner.getLuck(). Defined by the maximum between 0 and the value given byfishing_luck_bonus. - [Int] lureSpeed: How much is timeUntilLured reduced after being defined as a random number between 100 and 600 (both inclusive). Defined as a maximum between 0 and 20 times the value given by
fishing_time_reduction.
- [Int] luck: Used in the loot context of the fishing loot table,
- A fishing bobber is spawned with the fishing time reduction and luck bonus (which are not serialized) and with:
- [NBT Compound / JSON Object] Entity data
- [String] id:
minecraft:fishing_bobber - [Int Array] Owner: The player UUID.
- [NBT List / JSON Array] Pos: The player's eye position, offset by 0.3 blocks in the XZ plane in the direction of their Y rotation.
- [NBT List / JSON Array] Motion: The vector pointing away from the player in the XZ plane, with a Y motion of , normalized with a length of 0.6, and then offset on each axis by random numbers in a triangular distribution around 0.5 with a spread of 0.0103365.
- [NBT List / JSON Array] Rotation:
- [Float] to degrees
- [Float] to degrees
- [Undefined] <any tag>: NBT ags that vary by entity effect according to enchantments with the
projectile_spawnedeffect component on theenchantmentsitem component. It is calculated last. Such effects have an eventual scope beyond the tags.
- [String] id:
- [NBT Compound / JSON Object] Entity data
- The item used statistic is awarded.
- An
item_interact_startgame event is produced.
If the player does already have a fishing hook attached:
- The fishing bobber is retrieved.
- The item stack is damaged by one of these criteria:
- 3 if an item stack was hooked.
- 5 if another entity was hooked.
- 1 if the bobber got a bite fishing, which then rolls the
gameplay/fishingloot table and creates the resulting item. - 2 if the bobber was on the ground.
- 0 by default.
- The
entity.fishing_bobber.retrievesound effect is played. - An
item_interact_finishgame event is produced.
FlintAndSteelItem
{
"title": "FlintAndSteelItem",
"rows": [
{
"field": "FlintAndSteelItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite flint-and-steel.png article, displayed as 16x16px|link=Flint and Steel|alt=|class=pixel-image|)</span>(link to Flint and Steel article, displayed as <span class=\"sprite-text\">Flint and Steel</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
useOn(...)
First checks if the targeted block is an unlit campfire, soul campfire, candle, dyed candle, cake with candle, or cake with dyed candle. If so, its lit state is set to true, the item.flintandsteel.use sound effect is played, a block_change game event is produced, the item stack is damaged by 1, and the interaction succeeds.
If not, checks if a fire block can be placed adjacent to the clicked face, and if so places the fire block, emits the sound effect, produces a block_place game event, triggers the minecraft:placed_block advancement trigger, damages the item by 1, and succeeds.
If the fire block cannot be placed the interaction fails.
FoodOnAStickItem
{
"title": "FoodOnAStickItem",
"rows": [
{
"field": "FoodOnAStickItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite carrot-on-a-stick.png article, displayed as 16x16px|link=Carrot on a Stick|alt=|class=pixel-image|)</span>(link to Carrot on a Stick article, displayed as <span class=\"sprite-text\">Carrot on a Stick</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite warped-fungus-on-a-stick.png article, displayed as 16x16px|link=Warped Fungus on a Stick|alt=|class=pixel-image|)</span>(link to Warped Fungus on a Stick article, displayed as <span class=\"sprite-text\">Warped Fungus on a Stick</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
Each FoodOnAStickItem has an interactable entity type and an amount to damage the item when used, set for each item ID:
- Carrot on a Stick can interact with pigs and is damaged by 7 when used.
- Warped Fungus on a Stick can interact with striders and is damaged by 1 when used.
use(...)
If the player is riding an entity that is ItemSteerable and that is the entity type set for this item, the entity is boosted, the item is damaged by the amount set for this item, and if it breaks it is converted to minecraft:fishing_rod (with all components copied, count set to 1, and damage set to 0). The interaction succeeds.
If those conditions are not met, the item used statistic is awarded and the interaction passes.
GameMasterBlockItem
{
"title": "GameMasterBlockItem",
"rows": [
{
"field": "GameMasterBlockItem",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "(link to #BlockItem article, displayed as <span nowrap;\">§ BlockItem</span>)",
"label": "Extends"
}
],
"invimages": [],
"images": []
}
getPlacementState(...)
Overridden to null if placed by a player that cannot use game master blocks (i.e. is not in Creative mode), making place interactions fail.
GlowInkSacItem
{
"title": "GlowInkSacItem",
"rows": [
{
"field": "GlowInkSacItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite glow-ink-sac.png article, displayed as 16x16px|link=Glow Ink Sac|alt=|class=pixel-image|)</span>(link to Glow Ink Sac article, displayed as <span class=\"sprite-text\">Glow Ink Sac</span>)</span></div>",
"label": "Items"
},
{
"field": "<div class=\"hlist \" ><code>SignApplicator</code></div>",
"label": "Implements"
}
],
"invimages": [],
"images": []
}
tryApplyToSign(...)
Try changing has_glowing_text on the sign's front or back text (depending on isFrontText) to true.
If successful, the item.glow_ink_sac.use sound effect is played and returns true. Otherwise (if the text was already glowing) returns false.
HangingEntityItem
HangingSignItem
HoeItem
Note: Class removed in 26.3-snap2. Hoes are now just Item.
{
"title": "HoeItem",
"rows": [
{
"field": "HoeItem",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
}
],
"invimages": [],
"images": []
}
useOn(...)
HoneycombItem
InkSacItem
InstrumentItem
ItemFrameItem
KnowledgeBookItem
LeadItem
LingeringPotionItem
MaceItem
MapItem
MinecartItem
MobBucketItem
NameTagItem
{
"title": "NameTagItem",
"rows": [
{
"field": "NameTagItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite name-tag.png article, displayed as 16x16px|link=Name Tag|alt=|class=pixel-image|)</span>(link to Name Tag article, displayed as <span class=\"sprite-text\">Name Tag</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
interactLivingEntity(...)
The interaction will only be successful, instead of pass, when:
- the item has a
custom_namecomponent, and - the entity isn't a player, leash knot, lightning bolt, or fishing bobber.
If the entity is alive, sets its CustomName to be the same as the name tag. If the entity is a mob, also sets PersistenceRequired true. Shrink the item stack of the item by one.
Note: This method is only called for living entities, so it ends up being a redundant under certain conditions. Even though the ender dragon is a living entity, this method is never called by it because when trying to interact with it, the EnderDragonPart is actually being interacted, which is not a living entity.
PlaceOnWaterBlockItem
PlayerHeadItem
PotionItem
{
"title": "PotionItem",
"rows": [
{
"field": "PotionItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite potion.png article, displayed as 16x16px|link=Potion|alt=|class=pixel-image|)</span>(link to Potion article, displayed as <span class=\"sprite-text\">Potion</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite splash-potion.png article, displayed as 16x16px|link=Splash Potion|alt=|class=pixel-image|)</span>(link to Splash Potion article, displayed as <span class=\"sprite-text\">Splash Potion</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite lingering-potion.png article, displayed as 16x16px|link=Lingering Potion|alt=|class=pixel-image|)</span>(link to Lingering Potion article, displayed as <span class=\"sprite-text\">Lingering Potion</span>)</span></div>",
"label": "Items"
},
{
"field": "<div class=\"hlist \" >\n* <code>SplashPotionItem</code>\n* <code>ThrowablePotionItem</code>\n* <code>LingeringPotionItem</code></div>",
"label": "Implementations"
}
],
"invimages": [],
"images": []
}
useOn(...)
The interaction will only be successful, instead of pass, when:
- the face of the interacted block was not directed downward,
- the block is in the #convertable_to_mud tag, and
- the potion's content is water.
In case of success, apply in the following order:
- Play the generic splash sound event (
entity.generic.splash), - Set glass bottle in hand,
- Send splash particles,
- Play the bottle empty sound event (
item.bottle.empty), - Produce the game event
fluid_place, - Convert the block to mud.
getName(...)
If the item has the component potion_contents, the name name is defined from it. The item uses the translation key item.minecraft.<item type>.effect.<potion name>, where <potion name> is the custom name of the potion contents, if available, and otherwise is the name of the potion in potion contents (see Potion § Item data), if available. If nether is available, is "empty".
This name will replace the name defined by item_name. However, it can still be replaced by the custom_name, if available.
Usage in instanceof
The class PotionItem has one instanceof usage[until: JE 26.3]. This usage occurs in PotionBrewing.expectPotion(...) to validate the method that adds container recipes.
In vanilla, this method adds the brewing recipes that transform potions into splash potions and splash potions into lingering potions. If the source item or the destination item is not an instance of PotionItem, it throws an IllegalArgumentException, immediately aborting the method and logging the error Expected a potion, got: <item ID>.
However, currently, this doesn't affect the vanilla game at all, because besides the vanilla container recipes already being potions, it's not possible to customize them. Upcoming Java 26.3, potion recipes began to be controlled by data packs; however, that instanceof has been discontinued.
ProjectileWeaponItem
ScaffoldingBlockItem
ShearsItem
ShieldItem
{
"title": "ShieldItem",
"rows": [
{
"field": "ShieldItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite shield.png article, displayed as 16x16px|link=Shield|alt=|class=pixel-image|)</span>(link to Shield article, displayed as <span class=\"sprite-text\">Shield</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
getName(...)
If the item has the component base_color, the name is defined from it. The item uses the translation key item.minecraft.shield.<color>.
This name will replace the name defined by item_name component. However, it can still be replaced by the custom_name component, if available.
ShovelItem
Note: Class removed in 26.3-snap2. Shovels are now just Item.
{
"title": "ShovelItem",
"rows": [
{
"field": "ShovelItem",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
}
],
"invimages": [],
"images": []
}
useOn(...)
SignItem
Note: Class removed in 26.3-snap4. Non-hanging signs are now just StandingAndWallBlockItem. This property is now controlled by SingBlock.
{
"title": "SignItem",
"rows": [
{
"field": "SignItem",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<div class=\"hlist \" >(link to #HangingSignItem article, displayed as <span nowrap;\">§ HangingSignItem</span>)</div>",
"label": "Implementations"
},
{
"field": "<div class=\"hlist \" >\n*(link to #StandingAndWallBlockItem article, displayed as <span nowrap;\">§ StandingAndWallBlockItem</span>) \n*(link to #BlockItem article, displayed as <span nowrap;\">§ BlockItem</span>)</div>",
"label": "Extends"
}
],
"invimages": [],
"images": []
}
All instance of SignItem, being an instance of StandingAndWallBlockItemItem, have an attachmentDirection, and a wallBlock. The attachmentDirection of non-hanging signs is defined as down, and of hanging boards it is defined in HangingSignItemItem as up.
updateCustomBlockEntityTag(...)
If there is no custom data on the sign (for example block_entity_data) or it cannot be applied (because the player does not have permission), then open the sign text editor (sign.openTextEdit(player, signEntity, true)).
SmithingTemplateItem
{
"title": "SmithingTemplateItem",
"rows": [
{
"field": "SmithingTemplateItem",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
}
],
"invimages": [],
"images": []
}
New SmithingTemplateItem
Each instance of SmithingTemplateItem has a series of class-specific attributes, which are defined by SmithingTemplateItem(...). However, these attributes are not defined separately for each item; instead, they are defined by the createNetheriteUpgradeTemplate(...) and createArmorTrimTemplate(...) methods, where respectively defines the attributes of netherite upgrade and of all armor trims. In Items, only the item components are defined (by § Item.Properties, which in this case is only the rarity component).
These methods use the createTrimmableArmorIconList(), createTrimmableMaterialIconList(), createNetheriteUpgradeIconList(), and createNetheriteUpgradeMaterialList() auxiliary methods, and many auxiliary constants to create these attributes. Below is the complete table of these attributes:
| Attribute | Items | Value | |
|---|---|---|---|
| appliesTo | Armor Trim | Text component format | {"translate":"item.minecraft.smithing_template.armor_trim.applies_to",color:"blue"}
|
| Text in en_us | "Armor" ( Blue) | ||
| Netherite Upgrade | Text component format | {"translate":"item.minecraft.smithing_template.netherite_upgrade.applies_to",color:"blue"}
| |
| Text in en_us | "Diamond Equipment" ( Blue) | ||
| ingredients | Armor Trim | Text component format | {"translate":"item.minecraft.smithing_template.armor_trim.ingredients",color:"blue"}
|
| Text in en_us | "Ingots & Crystals" ( Blue) | ||
| Netherite Upgrade | Text component format | {"translate":"item.minecraft.smithing_template.netherite_upgrade.ingredients",color:"blue"}
| |
| Text in en_us | "Netherite Ingot" ( Blue) | ||
| baseSlotDescription | Armor Trim | Text component format | {"translate":"item.minecraft.smithing_template.armor_trim.base_slot_description"}
|
| Text in en_us | "Add a piece of armor" ( White) | ||
| Netherite Upgrade | Text component format | {"translate":"item.minecraft.smithing_template.netherite_upgrade.base_slot_description"}
| |
| Text in en_us | "Add diamond armor, weapon, or tool" ( White) | ||
| additionsSlotDescription | Armor Trim | Text component format | {"translate":"item.minecraft.smithing_template.armor_trim.additions_slot_description"}
|
| Text in en_us | "Add ingot or crystal" ( White) | ||
| Netherite Upgrade | Text component format | {"translate":"item.minecraft.smithing_template.netherite_upgrade.additions_slot_description"}
| |
| Text in en_us | "Add Netherite Ingot" ( White) | ||
| baseSlotEmptyIcons | Armor Trim | Asset ID |
|
| Textures | |||
| Netherite Upgrade | Asset ID |
| |
| Textures | |||
| additionalSlotEmptyIcons | Armor Trim | Asset ID |
|
| Textures | |||
| Netherite Upgrade | Asset ID |
| |
| Textures | |||
Asset ID refers to textures file path in /assets/minecraft/textures/gui/sprites/.
Append hover text
public void appendHoverText(...)
Add the following lines to the beginning of the item's tooltip, in order:
- "Smithing Template" (
Gray){"translate":"item.minecraft.smithing_template",color:"gray"}
- Empty line
{"text":""}
- "Applies to:" (
Gray){"translate":"item.minecraft.smithing_template.applies_to",color:"gray"}
- Space append to
appliesTo[{"text":" "},appliesTo]
- "Ingredients:" (
Gray){"translate":"item.minecraft.smithing_template.ingredients",color:"gray"}
- Space append to
ingredients[{"text":" "},ingredients]
Smithing table screen
There are 4 methods that always give the assigned values of the sprint items, namely getBaseSlotDescription(), getAdditionSlotDescription(), getBaseSlotEmptyIcons(), and getAdditionalSlotEmptyIcons(). All of them are used only in the SmithingScreen class. This class defines the behavior of the menu slots in the smithing table, controlling both the sprint that appears in empty slots and the tooltip when hovering the mouse over an empty slot. Furthermore, this class uses two instanceof of SmithingTemplateItem (and in no other class of the code is it used instanceof of SmithingTemplateItem).
Slot background
Slots 0, 1, and 2 of the menu use a rendering of their variable background given by a list of identifiers (asset IDs), defined by the class CyclingSlotBackground. With each tick update:
- If the icons list is different from the old icons list, update the icons list and reset the index of the list to zero.
- If the current list is not empty:
- Increase the tick count by one.
- If the tick count is a multiple of 30, increase the index of the identifier by one; return to zero if it exceeds the limit of the list.
And when render the slot background:
- If the list is empty or the slot is not empty: do nothing.
- If the tick count is greater than 30 and fewer than t + a < 4.0, where t is how many ticks have passed the last multiple of 30: render the previous icon (one index lower or the last one in the list if the index is zero) with
1–(t+a)/4.0transparency.[more information needed] - Renderize the current index with
(t+a)/4.0of transparency.
Note that in this way each icon occupies the slot for 30 ticks and has a smooth transition of 4 ticks.
In SmithingScreen, each tick updates the tick of CyclingSlotBackground, from slots 0, 1, and 2, with a list that may vary:
- For slot 0, a list of two elements is always used; these are: container/slot/smithing_template_armor_trim and container/slot/smithing_template_netherite_upgrade.
- For slot 1, if there is no instance of SmithingTemplateItem in slot 0, the list is empty. If there is, it is the
baseSlotEmptyIconsof the item. - For slot 2, if there is no instance of SmithingTemplateItem in slot 0, the list is empty. If there is, it is the
additionalSlotEmptyIconsof the item.
Boarding Tooltips
Depending on the mouse position, among other factors, the switcher table menu renders a tooltip.
- Mouse over a rectangular area around the arrow: if the recipe has an error (has items in slots 0, 1, and 3 but no result): "Item can't be upgraded this way" (
White) - If the mouse is in slot 0 and it is empty: "Add Smithing Template" (
White){"translate":"container.upgrade.missing_template_tooltip"}
- If the mouse is in slot 1, it is not empty, and slot 0 has an instance of SmithingTemplateItem: the
baseSlotDescriptionfrom item in slot 0. - If the mouse is in slot 2, it is not empty, and slot 0 has an instance of SmithingTemplateItem: the
additionsSlotDescriptionfrom item in slot 0. - In any other case: it does not render a menu tooltip (although it continues to render item tooltips normally).
SnowballItem
SolidBucketItem
SpawnEggItem
SpectralArrowItem
SplashPotionItem
SpyglassItem
StandingAndWallBlockItem
ThrowablePotionItem
TippedArrowItem
TridentItem
WindChargeItem
WritableBookItem
{
"title": "WritableBookItem",
"rows": [
{
"field": "WritableBookItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite book-and-quill.png article, displayed as 16x16px|link=Book and Quill|alt=|class=pixel-image|)</span>(link to Book and Quill article, displayed as <span class=\"sprite-text\">Book and Quill</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
use(...)
Open item GUI and increases the used statistic by one. Always returns successful.
Note:
The item GUI depends on the components writable_book_content and written_book_content. Therefore:
- If the item does not have either component: nothing is opened, but there is still an increase in statistics and usage animation.
- If the item has only one of these components: the corresponding GUI opens.
- If both components are present: both GUIs open, but the written book content GUI completely overlays the writable book content GUI, which the player can see briefly on the screen.
Therefore, the GUI are entirely dependent on the components and independent of the item ID. However, it is only possible to open them with the book and quill and written book, since only these items attempt to open the GUI.
WrittenBookItem
{
"title": "WrittenBookItem",
"rows": [
{
"field": "WrittenBookItem",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite written-book.png article, displayed as 16x16px|link=Written Book|alt=|class=pixel-image|)</span>(link to Written Book article, displayed as <span class=\"sprite-text\">Written Book</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
use(...)
Completely identical to WritableBookItem; see the § WritableBookItem.
Items member access
Blocks
CauldronInteractions
DispenseItemBehavior
AnvilMenu
PotionSlot[until: JE 26.3]
CartographyTableMenu
EnchantmentMenu
FurnaceFuelSlot
GrindstoneMenu
BeehiveBlock
CandleCakeBlock
ChiseledBookShelfBlock
ComposterBlock[until: JE 26.3]
ComposterBlock.OutputContainer
LightBlock
PowderSnowBlock
PumpkinBlock
RespawnAnchorBlock
SweetBerryBushBlock
TntBlock
TripWireBlock
WeatheringCopperGolemStatueBlock
WitherSkullBlock
AbstractFurnaceBlockEntity
BrewingStandBlockEntity
DecoratedPotPatterns[until: JE 26.3]
FuelValues
PotDecorations[until: JE 26.3]
VaultConfig
Entity
AgeableMob
Bucketable
Entity
LivingEntity[until: JE 26.3]
Mob
CrossbowAttack
TradeWithVillager
UseBonemeal
WorkAtComposter
BegGoal
RangedBowAttackGoal
RangedCrossbowAttackGoal
Armadillo
Axolotl
Camel
AbstractCow
MushroomCow
AbstractChestedHorse
AbstractHorse
Horse
Llama
Goat
CopperGolem
IronGolem
SnowGolem
Panda
Pig
Sheep
Wolf
ArmorStand
LeashFenceKnotEntity
Creeper
CrossbowAttackMob
Strider
Illusioner
Pillager
Piglin
PiglinAi
PiglinBrute
AbstractSkeleton
Bogged
Drowned
DrownedTridentAttackGoal
Zombie
ZombieVillager
Villager
VillagerProfession
WanderingTrader
Player
FireworkRocketEntity
FishingHook
ProjectileUtil
Raid
Client
Item
Loot
Misc
CauldronInteractions
DispenseItemBehavior
{
"title": "DispenseItemBehavior",
"rows": [
{
"field": "DispenseItemBehavior",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<code>net.minecraft.core.dispenser</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
bootStrap()
Defines the item's behavior when dispenser. The behaviors OptionalDispenseItemBehavior() and DefaultDispenseItemBehavior() are largely defined uniquely for each item.
| Item | Behavior |
|---|---|
| ProjectileBehavior | |
| DefaultDispenseItemBehavior | |
| OptionalDispenseItemBehavior | |
| BoatDispenseItemBehavior | |
| filledBucketBehavior | |
| DefaultDispenseItemBehavior | |
| OptionalDispenseItemBehavior | |
| OptionalDispenseItemBehavior | |
| OptionalDispenseItemBehavior | |
| shulkerBoxDispenseBehavior | |
| OptionalDispenseItemBehavior | |
| OptionalDispenseItemBehavior | |
| ShearsDispenseItemBehavior | |
| OptionalDispenseItemBehavior | |
| OptionalDispenseItemBehavior | |
| DefaultDispenseItemBehavior | |
| MinecartDispenseItemBehavior | |
AnvilMenu
{
"title": "AnvilMenu",
"rows": [
{
"field": "AnvilMenu",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite enchanted-book.png article, displayed as 16x16px|link=Enchanted book|alt=|class=pixel-image|)</span>(link to Enchanted book article, displayed as <span class=\"sprite-text\">Enchanted book</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.inventory</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
createResult()
If the anvil input is an enchanted book, it will initially consider any enchantment as compatible. However, if the enchantment is the same or does it conflict with any enchantment in the current list of enchantments in the result, it will no longer be considered compatible.
In other words, it's as if the enchanted book were in supported_items for all enchantment definition, when we consider the anvil.
PotionSlot
Note: Access to the item in 26.3-snap3 has been removed; it now uses the brewing inputs from the recipes. Glass bottle regained this property in 26.3-snap9 thanks to the tag
#brewing_potion_inputs
{
"title": "PotionSlot",
"rows": [
{
"field": "PotionSlot",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.inventory</code>",
"label": "Package"
},
{
"field": "<code>BrewingStandMenu</code>",
"label": "Outer Class"
}
],
"invimages": [],
"images": []
}
mayPlaceItem(...)
Returns true only if it is one of the four items listed above. Used to determine which items can be placed in the portion slot of the brewing stand.
It is also used in quickMoveStack, so that these items are attempted to be moved from the inventory to the potion slot with a quick click (⇧ Shift + click). Notes:
- If the item is in the
#brewing_fueltag, it will attempt to enter the fuel slot and not the potion slot (even if it fails to enter the fuel slot). The same occur with ingredients, however, ingredients are also hardcoded[until: JE 26.3] and don't have intersection. - This prevents quick clicking from moving them between storage slots and hotbar slots and vice versa, when the brewing stand menu is open. Even if the itens fails to move to the potion slot.
CartographyTableMenu
{
"title": "CartographyTableMenu",
"rows": [
{
"field": "CartographyTableMenu",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.inventory</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
mayPlace(...)
Returns true only if it is one of the three items listed above. Used to determine which items can be placed in the slot 1 of the cartography table.
setupResultSlot(...)
Used to define the result item of the cartography table:
- If the
mapStack(item in slot 0) does not have amapData(data associated with itsmap_idcomponent), it will not yield any results.
- If it's paper and the
mapDatais not locked and has a scale less than 4, the resulting is one copy of themapStackwith themap_post_processingcomponent set to 1 (SCALE).
- If it's glass and the
mapDatais not locked, the resulting is one copy of themapStackwith themap_post_processingcomponent set to 0 (LOCK).
- If it's empty map, the resulting is two copy of the
mapStack.
Note: It's possible to use the cartography table regardless of the mapStack ID; it only needs to have the map_id component with data. However, when retrieving an item that the ID isn't filled_map with the map_post_processing component, the game crashes[5]. However, using the empty map still works for item duplication.
quickMoveStack(...)
When using the quick click (⇧ Shift + click) in the inventory with the cartography table menu is open, it attempts to move these items to slot 1. Notes:
- If the item has the
map_idcomponent, it attempts to move it to slot 0 and does not go to slot 1 (even if it fails to go to slot 0). - This prevents quick clicking from moving them between storage slots and hotbar slots and vice versa, when the cartography table menu is open. Even if the itens fails to move to the slot 1.
EnchantmentMenu
{
"title": "EnchantmentMenu",
"rows": [
{
"field": "EnchantmentMenu",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite book.png article, displayed as 16x16px|link=Book|alt=|class=pixel-image|)</span>(link to Book article, displayed as <span class=\"sprite-text\">Book</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite lapis-lazuli.png article, displayed as 16x16px|link=Lapis Lazuli|alt=|class=pixel-image|)</span>(link to Lapis Lazuli article, displayed as <span class=\"sprite-text\">Lapis Lazuli</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.inventory</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
mayPlace(...)
Only lapis lazuli can be placed in the slot 1 of enchantment table.
clickMenuButton(...)
Right before a book is enchanted on an enchantment table, it becomes an enchanted book.
getEnchantmentList(...)
When creating a list of enchantments to enchant a book on an enchantment table, remove one enchantment at random if the list has more than one enchantment.
quickMoveStack(...)
When using the quick click (⇧ Shift + click) in the inventory with the enchantment table menu is open, it attempts to move the lapis lazuli to slot 1. This prevents quick clicking from moving the lapis lazuli to slot 0.
FurnaceFuelSlot
{
"title": "FurnaceFuelSlot",
"rows": [
{
"field": "FurnaceFuelSlot",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite bucket.png article, displayed as 16x16px|link=Bucket|alt=|class=pixel-image|)</span>(link to Bucket article, displayed as <span class=\"sprite-text\">Bucket</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.inventory</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
isBucket(...)
Check if the item is a bucket. Used twice to determine the behavior of the fuel slot (the lower left slot in blocks furnace, smoker, and blast furnace):
- In
mayPlace(...), to allow the bucket to be used in the fuel slot, even if it is not fuel (it is possible for it to be if it is added to a certain tag).- This does not change the quick move. Because what is tested to determine if an item can have a quick move to the fuel slot is whether it is a fuel.
- In
getMaxStackSize(...), to limit the maximum number of buckets in the fuel slot to one.
GrindstoneMenu
{
"title": "GrindstoneMenu",
"rows": [
{
"field": "GrindstoneMenu",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite enchanted-book.png article, displayed as 16x16px|link=Enchanted Book|alt=|class=pixel-image|)</span>(link to Enchanted Book article, displayed as <span class=\"sprite-text\">Enchanted Book</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.inventory</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
removeNonCursesFrom(...)
When using an enchanted book on the grindstone, after all non-curses enchantments have been removed, if the enchanted book does not retain an (curse) enchantment, it is transmuted into a book.
BeehiveBlock
{
"title": "BeehiveBlock",
"rows": [
{
"field": "BeehiveBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite shears.png article, displayed as 16x16px|link=Shears|alt=|class=pixel-image|)</span>(link to Shears article, displayed as <span class=\"sprite-text\">Shears</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite glass-bottle.png article, displayed as 16x16px|link=Glass Bottle|alt=|class=pixel-image|)</span>(link to Glass Bottle article, displayed as <span class=\"sprite-text\">Glass Bottle</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
useItemOn(...)
It encodes the interaction of an item on a bee nest and on a beehive.
If the honey level is less than 5, or the item is not one of those listed below, the interaction returns 'try with empathy hand', otherwise returns success. The interaction depends on the item:
- If the item is a shears, apply in the following order:
- drop the loot table
harvest/beehive(3x
Honeycomb); - the sound event beehive shear (
block.beehive.shear) is played; - causes one damage from the shear;
- and produce the game event
shear.
- drop the loot table
- If is glass bottle, apply in the following order:
- shrink the item by one;
- the sound event bottle fill (
item.bottle.fill) is played; - give the player a honey bottle, placing it in their hand if it's empty; otherwise, try placing it in their inventory. If that's not possible, the honey bottle is dropped;
- and produce the game event
fluid_pickup.
For both items, after that, increases the item used statistic by one and test if the beehive is in the smoke. If not, proceed in the following order:
- if there is at least one bee in the hive, each bee in a 17x13x17 area around the hive becomes aggressive toward a random player in the same area;
- all the bees leave the hive and become aggressive toward the player.
Then, even if the beehive is in the smoke, the honey level is reduced to zero.
CandleCakeBlock
{
"title": "CandleCakeBlock",
"rows": [
{
"field": "CandleCakeBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite flint-and-steel.png article, displayed as 16x16px|link=Flint and Steel|alt=|class=pixel-image|)</span>(link to Flint and Steel article, displayed as <span class=\"sprite-text\">Flint and Steel</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite fire-charge.png article, displayed as 16x16px|link=Fire Charge|alt=|class=pixel-image|)</span>(link to Fire Charge article, displayed as <span class=\"sprite-text\">Fire Charge</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
useItemOn(...)
When interacting with an flint and steel or a fire charge on a cake with candle or a cake with dyed candle, the method immediately returns PASS. The effect of these items on the cake is determined by useOn(...) in its classes (see § useOn(...), § FlintAndSteelItem and § FireChargeItem).
This also prevents the player from trying to eat the cake, unlike all other items. Note that with these items, the player cannot eat the cake even if the candle is already lit.
ChiseledBookShelfBlock
{
"title": "ChiseledBookShelfBlock",
"rows": [
{
"field": "ChiseledBookShelfBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite enchanted-book.png article, displayed as 16x16px|link=Enchanted Book|alt=|class=pixel-image|)</span>(link to Enchanted Book article, displayed as <span class=\"sprite-text\">Enchanted Book</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
addBook(...)
When adding an enchanted book to the chiseled bookshelf, use sound event block.chiseled_bookshelf.insert.enchanted () instead of block.chiseled_bookshelf.insert ().
Note: The items that can be added to the chiseled bookshelf are controlled by the tag #bookshelf_books, therefore it is not a hardcoded property.
removeBook(...)
When remove an enchanted book to the chiseled bookshelf, use sound event block.chiseled_bookshelf.pickup.enchanted () instead of block.chiseled_bookshelf.pickup ().
ComposterBlock
Note: Access to the item in 26.3-snap3 has been removed; it now uses the
compostable data component.{
"title": "ComposterBlock",
"rows": [
{
"field": "ComposterBlock",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
bootStrap()
Define compostable items. In other words, items that, when interacting with the composter, can increase its level and they can be used with a hopper, minecart with hopper, and dropper to increase the composter level.
When the composting is at level 0, all of these items will always increase its level to 1.
If the composting level are between 1 and 7, the chance of increasing its level depends on the item's group. For the low, low mid, mid, mid high, and higt groups, the chances are 30%, 50%, 65%, 85% and 100% respectively. After interacting:
- If increasing the level: produce the game event
block_change; - Player the sound event composter fill success (
block.composter.fill_success) if increasing the level, or the sound event composter fill (block.composter.fill); - Send composter particles;
- Increases the item
usedstatistic by one; - Shrink one item of the item stack;
- Return
SUCCESS.
When the composter reaches level 7, it will automatically change to level 8 in 20 ticks. Interacting with it will have no effect, but return 'success' iff the item is compostable.
Compostable items can be place through the top face of a compost, with level < 7, using a hopper, minecart with hopper, and dropper. When an item is placed in the composter, try to increase the level, the following occurs 1, 2, and 3 above and it is removed from the internal slot.
When a villager inserts an item stack into the composter, it will only take effect if it is a compostable item (which is always the case since the items used are also hardcoded, see § WorkAtComposter) and the composter is level < 7. When it takes effect, it attempts to increase the level and occurs 1, 2, and 5 above.
When interacting with the composter at level 8, the last level, regardless of what the player has on hand, the bone meal will be extracted and the composter will return to level 0.
OutputContainer
{
"title": "OutputContainer",
"rows": [
{
"field": "OutputContainer",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite bone-meal.png article, displayed as 16x16px|link=Bone Meal|alt=|class=pixel-image|)</span>(link to Bone Meal article, displayed as <span class=\"sprite-text\">Bone Meal</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
},
{
"field": "<code>ComposterBlock</code>",
"label": "Outer Class"
}
],
"invimages": [],
"images": []
}
canTakeItemThroughFace(...)
Returns whether a level 8 composter face can move an item to a hopper or minecart with hopper.
Returns true iff the face is dowm, the item to be removed is a bone meal, and no item has been removed from the container.
In practice, requiring the item to be bone meal doesn't change anything, as this is the only item that can be in the simple container, and this is hardcoded when generating the simple container. Although this may change with mods or future updates (such as composter extraction being controlled by a loot table).
Whenever a hopper is enabled and not full, it attempts to remove an item from the composter; even if it fails, the composter is emptied. For example, a hopper with a single redstone in each slot under a composter will empty it but won't extract anything.[6]
LightBlock
{
"title": "LightBlock",
"rows": [
{
"field": "LightBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" ><span class=\"nowrap\"><span class=\"sprite-file\" to File:Invicon Light.png article, displayed as 16x16px|link=Light (block)|alt=|class=pixel-image|)</span>(link to Light (block) article, displayed as <span class=\"sprite-text\">Light</span>)</span></span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
getShape(...)
Define the light block shape. The shape depends on the context; if the player is holding the light item, it will be a full block; otherwise, it will be empty.
PowderSnowBlock
{
"title": "PowderSnowBlock",
"rows": [
{
"field": "PowderSnowBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite leather-boots.png article, displayed as 16x16px|link=Leather Boots|alt=|class=pixel-image|)</span>(link to Leather Boots article, displayed as <span class=\"sprite-text\">Leather Boots</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
canEntityWalkOnPowderSnow(...)
Used in getCollisionShape(...) to help test whether the powder snow has a full block collision box.
Returns true iff the entity is in #powder_snow_walkable_mobs tag or the entity is a living entity and has a leather border in the feed slot.
By getCollisionShape(...) the powder snow's collision box is empty by default, but it can change depending on the context:
- If it is being placed or the context does not have an entity: empty
- If the entity is falling for more than 2.5 blocks: A column of 16×14.4×16 pixels
- If the entity is a falling block: Full block (16×16×16)
- If the entity is above the block, isn't sneaking and
canEntityWalkOnPowderSnow(...): Full block (16×16×16)
PumpkinBlock
{
"title": "PumpkinBlock",
"rows": [
{
"field": "PumpkinBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite shears.png article, displayed as 16x16px|link=Shears|alt=|class=pixel-image|)</span>(link to Shears article, displayed as <span class=\"sprite-text\">Shears</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
useItemOn(...)
When using a shears on a pumpkin, instead of returning 'try_with_empty_hand' like other items, returning 'success' and occurs:
- Set
directionas the direction of the interaction or in the opposite direction from the player if the interaction occurred on the y-axis, - Drop the loot table
carve/pumpkin(4x
Pumpkin Seeds), in direction, - Player the sound event pumpink carve (
block.pumpkin.carve). - Convert the pumpkin into a carved pumpkin with the face given by
direction, - Reduces the durability of the shear by 1,
- Produce the game event
shear, - Increases the item
usedstatistic by one.
RespawnAnchorBlock
{
"title": "RespawnAnchorBlock",
"rows": [
{
"field": "RespawnAnchorBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:Invicon Glowstone.png article, displayed as 16x16px|link=Glowstone|alt=|class=pixel-image|)</span>(link to Glowstone article, displayed as <span class=\"sprite-text\">Glowstone</span>)</span></span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
isRespawnFuel(...)
Used in useItemOn(...) to test if the item is fuel for the respawn anchor. Returns true iff the item is a glowstone.
In useOn(...), when use the glowstone on the respawn anchor with charge < 4, the following occurs:
- Increase the anchor's
chargeby one - Produce the game event
block_change, - Player the sound event respawn anchor charge (
block.respawn_anchor.charge), - Shrink the item stack by one,
- Retunr
SUCCESS
If the player has glowstone in their offhand but in their mainhand, and is interacting with the mainhand, and the charge is less than 4, returns 'pass' instead of 'try with empty hand'. This prevents the setting respawn and exploding at the anchor at the same time.
SweetBerryBushBlock
{
"title": "SweetBerryBushBlock",
"rows": [
{
"field": "SweetBerryBushBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite bone-meal.png article, displayed as 16x16px|link=Bone Meal|alt=|class=pixel-image|)</span>(link to Bone Meal article, displayed as <span class=\"sprite-text\">Bone Meal</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
useItemOn(...)
If the item stack is a bone meal and the sweet berry bush's age is not 3, the maximum, then return 'pass' instead of 'try with empty hand'. This causes the bone meal effect to be applied (see § useOn(...) and § BoneMealItem) and prevents the attempt to harvest the sweet berry bush.
TntBlock
{
"title": "TntBlock",
"rows": [
{
"field": "TntBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite flint-and-steel.png article, displayed as 16x16px|link=Flint and Steel|alt=|class=pixel-image|)</span>(link to Flint and Steel article, displayed as <span class=\"sprite-text\">Flint and Steel</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite fire-charge.png article, displayed as 16x16px|link=Fire Charge|alt=|class=pixel-image|)</span>(link to Fire Charge article, displayed as <span class=\"sprite-text\">Fire Charge</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
useItemOn(...)
If the item used in TNT is one of these:
- If the
tnt_explodesgame rule isfalse:- Send in action bar "TNT explosion are disabled" (
{"translate":"block.minecraft.tnt.disabled"}), - Return
PASS
- Send in action bar "TNT explosion are disabled" (
- If the game rule is
true:- Summon a primed TNT (with
fuse80) in the block's position, - Play the sound event tnt primed (
entity.tnt.primed), - Produce the game event
prime_fuse, - Set air block at the block's position,
- If the item is flint and steel, reduces the durability by 1, else, shrink the item stack by one,
- Increase the item used statistic by one,
- Return
SUCCESS.
- Summon a primed TNT (with
Otherwise, it returns 'try with empty hand' (but currently TNT has no effect on useWithoutItem(...), thus is the same that return 'pass').
TripWireBlock
{
"title": "TripWireBlock",
"rows": [
{
"field": "TripWireBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite shears.png article, displayed as 16x16px|link=Shears|alt=|class=pixel-image|)</span>(link to Shears article, displayed as <span class=\"sprite-text\">Shears</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
playerWillDestroy(...)
When a player destroys a tripwire, just before it is removed, if the item in mainhand is a shears:
- Set the tripwire's
disarmedto true and update the adjacent blocks, - Produce the game event
shear.
After the tripwire is broken, it updates the neighboring blocks as if it still existed and was powered true. This causes the connected tripwire hook to recalculate its stats, considering this wire as "wireSource". If disarmed is false, the tipwire hook will set its powered to true (because has a connected tripwire that is powered and not disarmed). If disarmed is true, because the disarmed tripwire is the "wireSource", it will set the tripwire hood's attempt to false, and consequently set powered to false. In both cases, because there is a "wireSource", the tripwire hood will be recalculated its stats at 10 ticks (this time without a "wireSource", and probably resulting in both attempt and powered false).
In other words, unless there are other tripwire interfering:
- Destroy a tripwire without shears: the connected tripwire hooks immediately set
poweredtrue and remainattempttrue. After 10 ticks they setpoweredandattemptto false. - Destroy a tripwire with shears: the tripwire hooks immediately set
attemptto false and remainpoweredfalse.
WeatheringCopperGolemStatueBlock
{
"title": "WeatheringCopperGolemStatueBlock",
"rows": [
{
"field": "WeatheringCopperGolemStatueBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite honeycomb.png article, displayed as 16x16px|link=Honeycomb|alt=|class=pixel-image|)</span>(link to Honeycomb article, displayed as <span class=\"sprite-text\">Honeycomb</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
useItemOn(...)
When using an item that is not in #axes in the copper golem statue, exposed copper golem statue, weathered copper golem statue, or oxidized copper golem statue:
- If the item is a honeycomb, return
PASS. Thus, the use of the item will depend on theHoneycombItem.useOn(...)(see § useOn(...) and § HoneycombItem) - Else, update the golem pose and return
SUCCESS.
If the item is in the tag #axes:
- If the block is (unaffected) copper golem statue it will try to generate a copper golem, if successful it will return
SUCCESS. - Else, return
PASS.
WitherSkullBlock
{
"title": "WitherSkullBlock",
"rows": [
{
"field": "WitherSkullBlock",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:Invicon Wither Skeleton Skull.png article, displayed as 16x16px|link=Wither Skeleton Skull|alt=|class=pixel-image|)</span>(link to Wither Skeleton Skull article, displayed as <span class=\"sprite-text\">Wither Skeleton Skull</span>)</span></span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
canSpawnMob(...)
Used to test if an item to be dispensed can be helpful in spawning the wither. For the item to be dispensed as a block, it is necessary that, in addition to this method returning true, that the pos (the target where the dispenser attempts to place the block) is air, cave air or void air.
Returns true if all the points below occur:
- The item is a wither skeleton skull.
- The y-axis of the
posis at least two blocks above the dimension y-minimum. - The difficulty is not peaceful.
- In any of the three axes and in any of the four rotations forms the pattern below, where some
is the pos(it can have any block in
),
is a block in the tag #wither_summon_base_blocksand
is air, cave air or void air.
Requiring the item to be a wither skeleton skull is circular, since only the wither skeleton skull has the behavior in the dispenser to try to spawn the wither, and this behavior is also hardcoded (see § DispenseItemBehavior). However, this property may be effective if in the future it becomes possible to customize item behaviors in the dispenser.
AbstractFurnaceBlockEntity
{
"title": "AbstractFurnaceBlockEntity",
"rows": [
{
"field": "AbstractFurnaceBlockEntity",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block.entity</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
Define the behavior of block entity associated with a furnace, blast furnace and smoker.
burn(...)
Used at the end of the smelting process, to add the result to output slot (slot 2).
After adding the result to output slot, if the item in ingredient slot (slot 0) is a wet sponge and the item in fuel slot (slot 1) is a bucket, set a water bucket in fuel slot.
After that, shrink 1 item from ingredient slot.
canTakeItemThroughFace(...)
Tests whether the container item can be take by a hopper or minecart with hopper. Returns true only if the face is the down. If it's the fuel slot (slot 1), the item must also be a bucket or a bucket of water.
Note: the down face only gives access to fuel and output slots (slots 1 and 2), so only items from the slots can be take.
canPlaceItem(...)
Tests whether a hopper, minecart with hopper or a dropper can place item in the container.
It always returns true for ingredient slot (slot 0) and always returns false for output slots (slot 2).
For fuel slot (slot 1), it returns true if the item is fuel (see § FuelValues) or if the item is a bucket but there is no bucket already in the slot.
Note: the up face only gives access to ingredient slot (slot 0), and the side faces only give access to fuel slot (slot 1).
BrewingStandBlockEntity
{
"title": "BrewingStandBlockEntity",
"rows": [
{
"field": "BrewingStandBlockEntity",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block.entity</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
Define the behavior of block entity associated with a brewing stand.
canPlaceItem(...)[until: JE 26.3]
Tests whether a hopper, minecart with hopper or dropper can place item in the container.
- If it's slot 3, it returns if the item is a potion brewing ingredient (see § PotionBrewing),
- If it's slot 4, it return true if the item is in the tag
#brewing fuel, - If it's a potion slot (slot 0, 1 or 2), return true if the item is a potion, splash potion, lingering potion, or a glass bottle and the slot is empty
Note: the up face only gives access to slot 3; the side faces only give access to slots 0, 1, 2 and 4; and the down face only give access to slots 0, 1, 2 and 3.
canTakeItemThroughFace(...)
Tests whether the item in the container can be take by a hopper or minecart with hopper.
Returns true only if the slot is not the slot 3, or if the slot is 3 and the item is a glass bottle.
This was probably intended to take the glass bottle that could be obtained by using a single dragon's breath in slot 3, however, due to a bug, the craft remainder doesn't work in this situation[note 1]. Currently, it's only possible to place a glass bottle in slot 3 via command (like /item).[until: JE 26.3]
Note: The down face not give access to slot 4, since the hoppers only try to take items from the down face, they should never take items from slot 4.
DecoratedPotPatterns
Note: Access to the item in 26.3-snap1 has been removed; it now uses the decorated pot pattern registry.
{
"title": "DecoratedPotPatterns",
"rows": [
{
"field": "DecoratedPotPatterns",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block.entity</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
ITEM_TO_POT_TEXTURE
Associates each item id[note 4] with a decorated pot pattern, which is associated with a texture in assets\minecraft\textures\entity\decorated_pot\<assetId>.png.
Used for decorated pot block model, with the pot_decorations component. Used in the special item model, type decorated_pot.
For items that do not have a pattern or when they is empty in one side, the texture decorated_pot_side is used; therefore, this property currently has no effect on the brick.
| Item | Pattern | Asset ID | Texture |
|---|---|---|---|
| blank | decorated_pot_side | ||
| angler | angler_pottery_pattern | ||
| archer | archer_pottery_pattern | ||
| arms_up | arms_up_pottery_pattern | ||
| blade | blade_pottery_pattern | ||
| brewer | brewer_pottery_pattern | ||
| burn | burn_pottery_pattern | ||
| danger | danger_pottery_pattern | ||
| explorer | explorer_pottery_pattern | ||
| flow | flow_pottery_pattern | ||
| friend | friend_pottery_pattern | ||
| guster | guster_pottery_pattern | ||
| heart | heart_pottery_pattern | ||
| heartbreak | heartbreak_pottery_pattern | ||
| howl | howl_pottery_pattern | ||
| miner | miner_pottery_pattern | ||
| mourner | mourner_pottery_pattern | ||
| plenty | plenty_pottery_pattern | ||
| prize | prize_pottery_pattern | ||
| scrape | scrape_pottery_pattern | ||
| sheaf | sheaf_pottery_pattern | ||
| shelter | shelter_pottery_pattern | ||
| skull | skull_pottery_pattern | ||
| snort | snort_pottery_pattern |
FuelValues
Note: Access to the item in 26.3-snap4 has been removed; it now uses the
cooking_fuel data component.
{
"title": "FuelValues",
"rows": [
{
"field": "FuelValues",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block.entity</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
vanillaBurnTimes(...)
Used to set the time and which items can be used as fuel. Added both directly to items, item tags, and blocks as items (see § BlockItem).
When an item appears twice, for example because it's in a tag, the last value is used, according to the table below.
Adding any item to tag #non_flammable_wood causes it to cease being a fuel item.
Only lava bucket, block of coal, blaze rod, coal, charcoal, dried kelp block, bamboo[until: JE 26.3-snap3] and scaffolding[until: JE 26.3-snap3] have times that cannot be added to any other item via tags.
Note that the higher up in the table, or when it doesn't belong to the table, the more customizable the item is, as its value can be substituted from a tag. Ironically, most hardcoded fuels have less customizable fuel time than other items. Tags with a green or orange background are the most suitable for adding items, as they can change a greater number of items. Items below these tags cannot have the fuel value given by them. Tags with an orange background are also used in other places, however, they are only used in the vanilla datapack, making it easy to substitute other uses.
Many fuel times exist for both items and tags, but some are exclusive to items, giving items with that time a unique property. Times marked in dark green are unique to a certain item, while light green times are unique to items, but more than one item has that time. There are also times unique to tags, marked in gray.
Only items bamboo mosaic, bamboo mosaic stairs, and bamboo mosaic slab are hardcoded fuel items and can be as customizable as a non-hardcoded fuel item and do not have a unique time.
* Lines marked with asterisks no longer have a background color in JE 26.3-snap1 or JE 26.3-snap3.
The fuel list is used in:
- AbstractFurnaceMenu.
quickMoveStack(...): Used to allow fuel o be moved from the inventory to the fuel slot (slot 1) with a quick click (⇧ Shift + click), in any furnace.- If the item can smelt, it will attempt to go to the ingredient slot (slot 0), and not to the fuel slot (slot 1).
- This also prevents quick clicking from moving fuel to the between storage slots (slots 3–29) and hotbar slots (slots 30–38) and vice versa, when the any furnace menu is open. Even if the fuel fails to move to the fuel slot.
- FurnaceFuelSlot.
mayPlace(...): Used to enable fuel to be placed in the fuel slot, by the menu, in any furnace. - AbstractFurnaceBlockEntity.
canPlaceItem(...): Used to enable fuel to be placed in the fuel slot, by hopper, minecart with hopper and dropper, in any furnace. - AbstractFurnaceBlockEntity.
getBurnDuration(...): Return the burn duration time (in ticks)- Used in
serverTick(...), so that if the block is notlit, it has fuel, an ingredient, and the recipe is available, then:- it defines the
litTimeRemainingand thelitTotalTime; - if it is greater than 0, it consumes the fuel (shrinks 1 item from the item stack and leaves the craft remaining if it is the last one), set the
littrue (included for effects in this same metody).
- it defines the
- In implementations SmokerBlockEntity and BlastFurnaceBlockEntity, returns half the time (rounding down). However, in the vanilla datapack, the recipes in that block take 100 ticks instead of 200 ticks, so the quantity of smelted items is approximately the same (it changes slightly for items in
#wool_carpetstag and for the dried kelp block, where in the furnace it is respectively 0.335 and 20.005 items and in smoker and blast furnace it is respectively 0.33 and 20 items).
- Used in
PotDecorations
Note: Access to the item in 26.3-snap1 has been removed. This property no longer exists.
{
"title": "PotDecorations",
"rows": [
{
"field": "PotDecorations",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite brick.png article, displayed as 16x16px|link=Brick|alt=|class=pixel-image|)</span>(link to Brick article, displayed as <span class=\"sprite-text\">Brick</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block.entity</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
getItem(...)
Returns the i-th item from the list sherds given when set the pot_decorations component. If i is greater or equal than the size of sherds, returns empty. If the i-th item is a brick, returns empty; otherwise, returns the item itself.
Used to define the component pot_decorations internally. Therefore, the items stack decorated_pot[pot_decorations=[]] and decorated_pot[pot_decorations=[brick,brick,brick,brick]] are the same. The same applies to stone[pot_decorations=[stone]] and stone[pot_decorations=[stone,brick]].
This also means that the pot crafted using the decorated_pot recipe, with just bricks, and the decorated_pot_simple (craftable via the recipe book) result in the same item.
However, sometimes when using the component it does the opposite (it considers the empty space as a brick):
- save the component NBT (except if in completely empty),
- add itens in tooltip,
- the drop of the decorated pot block (with
{"type":"dynamic","name":"sherds"}loot table), - the side with the empty item uses the same texture as the brick (see § DecoratedPotPatterns).
VaultConfig
{
"title": "VaultConfig",
"rows": [
{
"field": "VaultConfig",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite trial-key.png article, displayed as 16x16px|link=Trial Key|alt=|class=pixel-image|)</span>(link to Trial Key article, displayed as <span class=\"sprite-text\">Trial Key</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.level.block.entity.vault</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
VaultConfig()
Define the default key_item in the config in vault block entity as trial key. So the tiral key can open vaults whose key_item has not been changed.
However, it is possible to change the key_item using commands, this key property only applies to default vaults.
AgeableMob
{
"title": "AgeableMob",
"rows": [
{
"field": "AgeableMob",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:BlockSprite golden-dandelion.png article, displayed as 16x16px|link=Golden Dandelion|alt=|class=pixel-image|)</span>(link to Golden Dandelion article, displayed as <span class=\"sprite-text\">Golden Dandelion</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.entity</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
canUseGoldenDandelion(...)
Returns true when the following occur simultaneously:
- The item in hand is a golden dandelion
isBabyis truecooldownis zero- The mob is not in the
#cannot_be_age_lockedtag
This method is used twice:
- AgeableMob.
mobInteract(...)— TheisBabyparameter actually checks if the ageable mob is a baby (age< 0 and can be a baby), and thecooldownisageLockParticleTimer. If it returns true, sets age locked and returnsSUCCESS. Otherwise, it returnsPASS(via the super method). Most ageable mobs do not have this interaction directly, as the method has many overrides; however, at some point, it is activated via the super method.
- Tadpole.
mobInteract(...)— TheisBabyparameter is always true, and thecooldownis the same as above. Before testing whether the golden dandelion works, try feeding the tadpole (feed it when the item is in the#frog_foodtag and the tadpole is not age-locked). If it doesn't feed, try using the golden dandelion; if successful, set it to age-locked and return it to theSUCCESS. Otherwise, try to catch the tadpole in the bucket.
When age locked is set, it occurs in order:
- Invert the value of the NBT tag
age_locked; - Sets the
ageto 0 for tadpoles, −48000 for sniffers, and −24000 for other mobs; - Set
ageLockParticleTimerto 40; - Consume one item from the player's hand.
- If age is locked:
- Set persistence required
- Paly sound
golden_dandelion.use()
- Otherwise
- Paly sound
golden_dandelion.unuse()
- Paly sound
Bucketable
{
"title": "Bucketable",
"rows": [
{
"field": "Bucketable",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite water-bucket.png article, displayed as 16x16px|link=Water Bucket|alt=|class=pixel-image|)</span>(link to Water Bucket article, displayed as <span class=\"sprite-text\">Water Bucket</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.entity</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
Entity
{
"title": "Entity",
"rows": [
{
"field": "Entity",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite shears.png article, displayed as 16x16px|link=Shears|alt=|class=pixel-image|)</span>(link to Shears article, displayed as <span class=\"sprite-text\">Shears</span>)</span>\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite lead.png article, displayed as 16x16px|link=Lead|alt=|class=pixel-image|)</span>(link to Lead article, displayed as <span class=\"sprite-text\">Lead</span>)</span></div>",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.entity</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
interact(...)
Attempt to interact with the entity in the following order. If one attempt fails, try the next.
1. The player attempts to attach entities currently leashed to them onto the entity being interacted with. This interaction does not depend on the item held in hand. If at least one entity is successfully leashed, the interaction returns success (and concludes).
2. If the item held is shears, attempt to remove the leashes from the entity being interacted with.
- This attempts to remove both the leash securing the interacted entity and any leashes from nearby entities (within a 32×32×32 cuboid centered on the interacted entity) that are attached to the interacted entity.
- When a leash is removed, it is dropped at the position of the leashed entity.
If at least one leash is dropped:
- Produce the game event
sheargame event. - The
item.shears.snipsound plays. - The shears take one of damage.
- The interaction returns success.
3. Attempts to remove equipment from the entity. This is only possible if the following conditions are met simultaneously:
- The entity is a mob
- The player is holding shears
- The player is not crouching
- If the entity is a wolf, the player is its owner; otherwise, the entity is not being ridden
- At least one item in the entity's equipment slots has
equippable.can_be_shearedset to true and, unless the player is in Creative mode, does not have an enchantment withprevent_armor_changeeffect components (e.g., Curse of Binding in vanilla)
In this case, a piece of equipment can be removed:
- The shears take one of damage
- Produce the game event
shear - Drop the equipment
- Triggered
player_sheared_equipmentadvancement trigger - The interaction returns success.
At most, one piece of equipment is dropped at a time, in the following order of slot priority: mainhand, offhand, feet, legs, chest, head, body and saddle.
4. wip
LivingEntity
Note: Access to the item in 26.3-snap4 has been removed; it now uses the
mob_visibility data component. This class still has access to the item wither rose, but it describes a hardcode origin and not a property.
{
"title": "LivingEntity",
"rows": [
{
"field": "LivingEntity",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.entity</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
getVisibilityPercent(...)
It reduces the range of view of skeleton, zombie, piglin, piglin brute, and creepy when detecting entities with a corresponding head or skull by 50%. Piglin head also reduces piglin brute.
See Mob AI § Targeting condition for more details.
Mob
CrossbowAttack
TradeWithVillager
UseBonemeal
WorkAtComposter
BegGoal
BowAttackGoal
RangedCrossbowAttackGoal
Armadillo
Axolotl
Camel
AbstractCow
MushroomCow
AbstractChestedHorse
AbstractHorse
Horse
Llama
Goat
CopperGolem
IronGolem
SnowGolem
Panda
Pig
Sheep
Wolf
ArmorStand
LeashFenceKnotEntity
Creeper
CrossbowAttackMob
Strider
Illusioner
Pillager
Piglin
PiglinAi
PiglinBrute
AbstractSkeleton
Bogged
Drowned
DrownedTridentAttackGoal
Zombie
ZombieVillager
Villager
{
"title": "LivingEntity",
"rows": [
{
"field": "LivingEntity",
"label": "Class"
},
{
"field": "(values exceeds 1000 characters...)",
"label": "Items"
},
{
"field": "<code>net.minecraft.world.entity</code>",
"label": "Package"
}
],
"invimages": [],
"images": []
}
mobInteract(...)
When interacting with a villager, if the interaction use a villager spawn egg, if the villager is sleeping, currently trading, or is not alive, the interaction returns the result of the supermethod (see § AgeableMob). Note that if the item is the villager spawn egg, it always returns pass.
This prevents starting a trade or setUnhappy() (for babies and villagers without trades), and returns success.
However, if the supermethod returns pass, it try to equip the item on the villager, by the equippable component, via the ItemStack.interactLivingEntity(...) method.
The addition of the villager spawn egg check was likely intended to ensure the egg spawns a baby villager instead starting a trade; however, in the interaction check order, the attempt to spawn a baby villager with a spawn egg occurs before this method. Consequently, it is possible to spawn a baby villager using any spawn egg that possesses the entity_data component with the ID villager. This property also allows the villager spawn egg to be equipped, provided it does not have the entity_data component with the ID villager (which requires removing the default component), which does not occur with other items.[7]
Map<Item, Integer> FOOD_POINTS
Note: Access to the item in 26.3-snap4 has been removed; it now uses the
villager_food data component.Define as the map:
| Items | Poits |
|---|---|
| 4 | |
| 1 | |
| 1 | |
| 1 |
Used to test if the villager drops food (in TradeWithVillager). The villager A drops food (an item on the map) for villager B if it occurs simultaneously:
- Villager A has has 24 or more foodpoints.
- Villager A is a farmer, or villager B needs more food (i.e less than 12 foodpoints)
A villager's food points are calculated by summing the points of each food item in their inventory.
In both cases, when attempting to drop an item, scan the villager's slots looking for a slot that contains an item food. The first slot of a item food that has c>24 items is used. If c<33, the villager drops c-24 items; if c>32, the villager drops c/2 items (rounded down).
The dropped item is always a new item stack, without data components, regardless of the components of the item in the slot.
VillagerProfession
WanderingTrader
Player
FireworkRocketEntity
FishingHook
ProjectileUtil
ClientLevel
AbstractClientPlayer
ItemInHandRenderer
AbstractSkeletonRenderer
DrownedRenderer
LivingEntityRenderer
WitchRenderer
AvatarRenderer
CuboidItemModelWrapper
Charge
PotionBrewing
Note: Class removed in 26.3-snap3. Now, potion are based on recipes.
Ingredient
CrossbowItem
EnchantmentHelper
Item (member access)
ItemStack
ItemStackTemplate
ProjectileWeaponItem
EnchantRandomlyFunction
ExplorationMapFunction
Note: Access to the item in 26.3-snap6 has been removed; it now is applied to all non-empty items.
{
"title": "LivingEntity",
"rows": [
{
"field": "LivingEntity",
"label": "Class"
},
{
"field": "<div class=\"hlist \" >\n*<span class=\"nowrap\"><span class=\"sprite-file\" to File:ItemSprite empty-map.png article, displayed as 16x16px|link=Empty Map|alt=|class=pixel-image|)</span>(link to Empty Map article, displayed as <span class=\"sprite-text\">Empty Map</span>)</span></div>",
"label": "Items"
}
],
"invimages": [],
"images": []
}
run(...)
Applies the item modifier exploration_map.
Returns the item stack itself without modification if the item is not empty map (minecraf:map).
FillPlayerHead
SetEnchantmentsFunction
SetStewEffectFunction
EntityEquipmentPredicate
Old article stub
List
- Is entity_data used by spawn eggs, boats, minecarts, armor stands, paintings, item frames and end crystals by default, or are those controlled by the item ID?
- Block items
- ID of the block placed
block_statecan control the specific state an item places, but cannot control the exact ID.
- ID of the block placed
- Projectile items: eggs, snowballs, splash potions, lingering potions, bottles o' enchanting, eyes of ender, ender pearls, firework rockets(?), wind charges
- The entity spawned does not appear to be customizable.
- Fishing rods
- What entity is spawned, and presumably many other things.
- Bows
- Almost all aspects of behavior. [more information needed]
- Crossbows
- Much the same: defaults for animation, charge time, accepted items for loading, ...
- Tridents
- Animation, charge time
- Swords
- The ability to sweep attack
- Mace
- Items which can be fed to zombie villagers to cure them
- Lead
- Fire charge
- Dispenser behavior appears to be hardcoded
- ID of block placed
- Flint and Steel
- ID of block placed
- Things in buckets
- ID of block placed, and possibly entity spawned if this isn't handled already
- Cauldron interaction
- Buckets
- What block IDs (and states) / fluid IDs can be deleted on right click
- Milking cows
- Interacting with empty cauldrons
- Bowls
- Milking mooshrooms
- Items that interact with blocks on right click, possibly including a loot table for dropped items, and whether the item should be deleted, damaged, or converted to something else on use
- Hoes on tillable blocks - converting things to farmland, or coarse dirt to dirt
- Shovels on dirt-like blocks, converting them into dirt paths
- Axes on logs/wood and stems/hyphae, stripping
- Axes on oxidised copper, reducing
- Axes on waxed copper, dewaxing
- Honeycomb on unwaxed copper, waxing
- Water bottle on dirt-like blocks, converting to mud
- Eye of Ender on empty end portal frame, adding the eye
- Pottable plants used on flower pots, turning the pot into a potted plant
- Shears on an uncarved pumpkin, carving it and producing seeds
- Shears on a full beehive or bee nest, producing honeycomb and setting honey level to 0
- Empty bottle on a full beehive or bee nest, converting it to a honey bottle and setting honey level to 0
- Bone meal usage
- Items used on entities
- Shears
- On sheep, to shear them
- On mooshrooms, to shear them
- On snow golems, to remove the pumpkin
- On bogged, to obtain mushrooms
- On leashed mobs, to obtain the lead
- On some equipped mobs, to obtain the equipment
- It is possible to control which equipment will be picked up with the scissors with the component
equippable~{can_be_sheared:true}, but not which scissors (and not another item) will be used for this.
- It is possible to control which equipment will be picked up with the scissors with the component
- On copper golems, to obtain the poppy
- Iron ingots
- On iron golems, to heal them
- Dyes
- On sheep, to dye their wool
- On wolves, to dye their collars
- On cats, to dye their collars
- Brush
- On armadillos to get scutes
- Axe
- On oxidized copper golem, reducing
- On waxed copper golem, dewaxing
- Honeycomb
- On unwaxed copper golem, waxing
- Shears
- Empty bottles
- Using on water or water cauldrons to fill the bottle
- Using on dragon breath to fill the bottle
- Water bottles
- Using on empty cauldrons or non-full water cauldrons to fill the cauldron
- Brush usage
History
| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.13 | 17w43a | Add datapack that control advancement. Items used in advancement triggers are no longer hardcoded, such as iron bars, stone pickaxes, and lava buckets. | |||||
| 17w48a | Recipes are now controlled by datapacks, so most recipes are no longer hardcoded, with the exception of special crafting recipes | ||||||
| 17w49a | Added tags, with the item tags #planks, and #wool. So, the properties of planks, repair tools, shields, and wool to be used with fuel were no longer hardcoded. | ||||||
| 1.14 | 18w43a | Added match_tool loot table condition, Now, the drop rate for using shears is controlled by loot tables.[more information needed] | |||||
| 1.20.5 | 24w09a | Item NBT has been effectively removed, being replaced by the new data component format. Some hardcoded properties of items have also been migrated to this system.[more information needed] | |||||
| 1.21 | 24w18a | Enchantments are now controlled by datapacks, so the property of being enchanted by a certain enchantment has ceased to be hardcoded, except for book. | |||||
| 26.1 | snap1 | Villager trades are now controlled by datapack, so the property of wants items for default trades is no longer hardcoded. Note that the trade could already be modified by command. Removing the classes VillagerTrades which had many Items accesses | |||||
| snap3 | The bundle_contents component can now handle errors in the weight,[note 5] considering the weight equal to error and keeping its data. Previously, the component was only deleted. Therefore, instances of BundleItem considers it as full for the purpose of displaying the bar. However, it continues to delete items when trying to remove an item from the bundle, transfer an item, or view the tooltip.
| ||||||
The eggs() method has been removed from SpawnEggItem and added new use of instanceof of SpawnEggItem in DispenseItemBehavior. Previously, the eggs() was only used in DispenseItemBehavior to set the behavior of the spawn eggs in the dispenser. However, it only saved one spawn egg for each id in the default entity_data; in practice, this did not change anything, given that there does not exist two spawn eggs with the same id in the default entity_data, but this could affect mods and future additions to the game.
| |||||||
|
The spawn egg behavior is now given to any instance of SpawnEggItem that has an | |||||||
|
Added ItemStackTemplate class with reference to | |||||||
Items stack with invalid data[note 6] are now considered empty for many uses of the bundle_contents, container, and charged_projectiles components, meaning that items which rely on these components treat such stacks as empty, even though the invalid data may still exist in the data component. For example:
| |||||||
| snap5 | Instances of DyeItem are no longer associated with a dyeColor; instead, each dye has the default dye component. Therefore, their methods use the dye component from item stack, instead of DyeColor, and pass or return false if the component does not exist. Thus, the tryApplyToSign() SignApplicator method has a ItemStack parameter.
| ||||||
The methods getDyeColor() and byColor(...) have been removed from DyeItem, due to the dye component.
| |||||||
All uses of instanceof of DyeItem have been removed, due to the dye component.
| |||||||
| Added the item golden dandelion as a new BlockItem instance. | |||||||
| Added the block golden dandelion as a new FlowerBlock instance. Thus adding the propeidae hardcoded of the item golden dandelion to set the stew effects when feeding a brown mooshroom. | |||||||
Added potted golden dandelion, a new instance of FlowerPotBlock. Thus, through the useItemOn(...) method in FlowerPotBlock, which import the BlockItem, the golden dandelion has the hardcoded property of interacting with the flower pot.
| |||||||
| Add new Items member access in AgeableMob, Camel, AbstractChestedHorse, Horse, and Panda classes for properties of the golden dandelion. | |||||||
In AbstractHorse and Llama, added hay bale Items member access, for testing as a possible food. Previously, the Blocks class was used with the asItem() method. Furthermore, these classes require that the animal not be age-locked in order to use a hardcoded food to increase the age.
| |||||||
| The classes FireworkRocketRecipe, FireworkStarRecipe, FireworkStarFadeRecipe, MapExtendingRecipe, and ShieldDecorationRecipe no longer have member access to Items.
The items in these recipes are controlled by datapacks, no longer being a hardcoded item properties, except for ShieldDecorationRecipe; see details below. For the vanilla datapack, the items are controlled by VanillaRecipeProvider. | |||||||
| The classes MapCloningRecipe and TippedArrowRecipe, which previously had access to members of Items, have been removed.
The recipes previously coded by these classes are now coded by the classes TransmuteRecipeBuilder and ImbueRecipe, respectively. The items in these recipes are controlled by datapacks, no longer being a hardcoded item propeties. For the vanilla datapack, the items are controlled by VanillaRecipeProvider. | |||||||
|
The classes BannerDuplicateRecipe, and ShieldDecorationRecipe, those that uses instanceof of BannerItem have been changed Now, in addition to using | |||||||
| snap6 |
In the class AgeableMob the golden dandelion is referenced by the new | ||||||
The implementation of the saveToBucketTag(...) and loadFromBucketTag(...) methods in the Axolotl and Tadpole classes has changed to now save and load the AgeLocked tag and, just for the tadpole, the Age tag. This changes the hardcoded property of the water bucket, bucket of axolotl and bucket of tadpole items, as they use these methods.
| |||||||
| snap7 | In the class AgeableMob the method setAgeLocked(...), activated only with the golden dandelion, now set persistence required when locked the age.
| ||||||
| snap8 | The method isValidBonemealTarget(...) used in BoneMealItem has been modified in several classes: AzaleaBlock, BambooSaplingBlock, BambooStalkBlock, BigDripleafBlock, BigDripleafStemBlock, GrassBlock, GrowingPlantBodyBlock, HangingMossBlock, MushroomBlock, NetherFungusBlock, NyliumBlock, PitcherCropBlock (indirectly), RootedDirtBlock, SaplingBlock, SweetBerryBushBlock, TallDryGrassBlock and TallGrassBlock
| ||||||
The method performBonemeal(...) used in BoneMealItem has been modified in BambooStalkBlock, BigDripleafBlock, GrassBlock, GrowingPlantHeadBlock, NyliumBlock (indirectly) and PitcherCropBlock (indirectly)
| |||||||
The interaction result when using BoneMealItem and grow crop is now PASS for the client and SUCCESS_SERVER for the server. Previously it was always SUCCESS.
| |||||||
|
The cauldron interactions list has been moved from CauldronInteraction to the new class CauldronInteractions. | |||||||
Dyed item iteration in CauldronInteractions is now controlled by the #cauldron_can_remove_dye tag instead of the items leather boots, leather pants, leather tunic, leather cap, leather horse armor, and wolf armor.
| |||||||
| Brown mooshrooms now only receive the suspicious effect from BlockItem if they are not babies. Because of this, the golden dandelion agge locked is now applied to baby brown mooshrooms, and other flowers are no longer applicable. | |||||||
| snap10 | The bindPlayerMobs(...) method of LeadItem hears some changes: early return pass if no leashable entities found in area, split LeashFenceKnotEntity.getOrCreateKnot(...) into LeashFenceKnotEntity.getKnot(...) and LeashFenceKnotEntity.createKnot(...) for explicit control, activeKnot.playPlacementSound() moved to post-loop (only plays on success), discard newly created knot if no entity was successfully leashed.
| ||||||
The releaseUsing(...) method of TridentItem now only activates the spin attack if the player is not a passenger.
| |||||||
The method makeAgeLockedParticle(...) in AgeableMob has undergone significant changes. Now, the position and type of particle depend on whether the age is locked. Previously, the particle happy_villager was used.
| |||||||
| pre1 | In Items, when registering items with the default components damage_resistant, blocks_attacks, and provides_banner_patterns, the method Properties.delayedComponent(...) is now used instead of Properties.component(...). This makes the items more sensitive to changes in datapack.
| ||||||
| pre2 | The method registerBlock(...) in items registered with receive their requiredFeatures matching from the associated block. Previously, this was done in a BlockItem method.
| ||||||
The method requiredFeatures() has been removed from BlockItem. However, most instances of BlockItem will remain copied requiredFeatures from the associated block, except for those defined by createBlockItemWithCustomItemName(...).
| |||||||
In Properties: the method fireResistant(), which adds the default damage_resistant component with tag is_fire, now uses the method delayedComponent(...) and the method spawnEgg(...), in addition to adding entity_data with the entity's id, and adding requiredFeatures equal to the entity.
| |||||||
The method requiredFeatures() has been removed from SpawnEggItem.
| |||||||
| pre3 | In AgeableMob, when setting age locked data, the age is defined according to getBabyStartAge(), which by default is −24000 and for the sniffer -48000. Previously it was always −24000.
| ||||||
| 26.2 | snap1 | Added items sulfur, potent sulfur, sulfur slab, sulfur stairs, sulfur wall, polished sulfur block, polished sulfur slab, polished sulfur stairs, polished sulfur wall, sulfur bricks, sulfur brick slab, sulfur brick stairs, sulfur brick wall, cinnabar, cinnabar slab, cinnabar stairs, cinnabar wall, polished cinnabar block, polished cinnabar slab, polished cinnabar stairs, polished cinnabar wall, cinnabar bricks, cinnabar brick slab, cinnabar brick stairs and cinnabar brick wall as new instances of BlockItem | |||||
| Added the item sulfur cube bucket as a new MobBucketItem instance, with content (fluid) and emptySound is empty. | |||||||
| Added the item sulfur cube spawn egg as a new SpawnEggItem instance. | |||||||
| Added SulfurCube class, with 3 Items member access: sulfur cube bucket, bucket and shears. | |||||||
Colored items, such as wool and dyed shulker box, are referenced as ColorCollection<Item>, instead of 16 separate instances. Similarly, copper items, such as copper block and chiseled copper, are referenced as CopperCollection<Item>, instead of 8 separate instances. This modified many classes, but only in the code organization, and not in game properties.
| |||||||
Added override of the emptyContents(...) method in MobBucketItem, which returns true if the fluid is empty and a supermethod otherwise.
| |||||||
The new sulfur cube bucket item has the behavior filledBucketBehavior in DispenseItemBehavior
| |||||||
The tryShearEntity(...) method in ShearsDispenseItemBehavior now checks if the shearable entity is alive before shearing it. Previously, this test was performed using the readyForShearing() method on each entity.
| |||||||
| snap3 | Some changes to the Items class, but without much impact on the final properties:
| ||||||
MobBucketItem overrides BucketItem.getFluidContext(), always using the NONE context. Previously, the getFluidContext() method did not exist, and the context was determined by use(...).
| |||||||
| snap4 | Sulfur cube bucket now has item.bucket.empty_sulfur_cube sound event as emptySound.
| ||||||
The override of the emptyContents(...) method in MobBucketItem, now plays emptySound before returning true when the fluid is empty.
| |||||||
| snap5 | The use(...) and useOn(...) methods in SpawnEggItem return FALL whenever there is no entity or the entity cannot be spawned at the level (for some when the difficulty is peaceful). Previously, this test was performed at different times, allowing the use of any entity on the monster spawner even in passive difficulty.[9] A small exception occurs in use(...), because the test to ensure the hit result is not a block to return PASS is performed beforehand.
| ||||||
| snap7 | Added the item music disc bounce, as just a instance of Item. | ||||||
| pre1 | The interaction result when using BoneMealItem and grow crop is now SUCCESS on the client side. Previously, it returned PASS on the client side.
| ||||||
Notes
- ↑ a b With two or more dragon's breath in the brewing stand, after the brewing process, a glass bottle drops as an entity. However, with one dragon's breath in the brewing stand, the glass bottle is consumed and cannot be retrieved.[1][until: JE 26.3]
- ↑ If the material in the book cloning recipe has the component
written_book_content, it will also remains. - ↑ It is possible for certain properties of item A to cause the creation of a new instance of item B, but in these cases it will be a property of item A and not item B.
- ↑ Uses instances of ItemIds rather than Items.
- ↑ An error in the weight of the
bundle_countscomponent, in addition to invalid count data, occurs when the weight exceeds 231-1 (equivalent to 231-1 stacks). This can happen by using/giveto generate items with many layers of thebundle_countscomponent, and then using/datato place these items in the bundle. - ↑ This happens when: the count is greater than
max_stack_size; has a componentmax_damageandmax_stack_size> 1; has componentbundle_contents,container, orcharged_projectilesthat has an item stack with count greater thanmax_item_stack; or hasbundle_contentswith a weight error.
References
Sources
- Hardcoded item properties (Java Edition) — Minecraft Wiki, CC BY-NC-SA 3.0, revision 3725413.