And now the last command block. It will be a chain block and it will face up. it must be always active and unconditional:
/replaceitem entity @a[score_SCOREBOARD_NAME_min=2] slot.weapon.mainhand minecraft:TOOL_NAME 1 0 {HideFlags:8,display:{Name:"THE NAME THAT YOU CALLED YOUR TOOL"},CanDestroy:["sand","grass","gravel","dirt","mycelium","clay","farmland","grass_path","soul_sand","snow","snow_layer","FakeBlock"]}
/replaceitem entity @a[score_Diapick_min=2] slot.weapon.mainhand minecraft:diamond_pickaxe 1 0 {HideFlags:8,display:{Name:"Diamond Pickaxe"},CanDestroy:["obsidian","ender_chest","anvil","coal_block","diamond_block","emerald_block","iron_block","gold_block","lapis_block","redstone_block","enchanting_table","iron_bars","iron_door","mob_spawner","dispenser","dropper","furnace","coal_ore","diamond_ore","emerald_ore","gold_ore","iron_ore","redstone_ore","lapis_ore","quartz_ore","end_stone","hopper","iron_trapdoor","brick_stairs","brick_block","cauldron","cobblestone","stone_stairs","cobblestone_wall","mossy_cobblestone","nether_brick","nether_brick_fence","nether_brick_stairs","stone_slab","andesite","deorite","granite","polished_andesite","polished_deorite","polished_granite","stone","stone_bricks","stone_brick_stairs","prismarine","prismarine_bricks","dark_prismarine","stained_hardened_terracotta","hardened_clay","quartz_block","quartz_stairs","sandstone","sandstone_stairs","brewing_stand","stone_pressure_plate","heavy_weighted_pressure_plate","light_weighted_pressure_plate","netherrack","rail","ice","packed_ice"]}
Best Answer
First, you can stop a specific item from despawning unless it is picked up and then dropped again by setting it's
Age
to -32768 with a command block.Second, you can add arbitrary custom NBT data to an item, which will be preserved across drop-and-pickup cycles.
You can combine these two techniques to make specific items never despawn by running the command:
This would make any item given with a
noDespawn:1b
NBT tag (/give <player> <item>{noDespawn:1b}
) never despawn, even if it is picked up and dropped again.