https://github.com/PaperMC/Paper/pull/10845
Adds the ability to directly edit certain item data that mirrors the vanilla representation of the newly introduced data components.
This allows item manipulation that is separate from the item meta system.
Feedback
Please take a look at the task list on the pull request as we are trying to collect feedback on some of the points listed there.
Note: Some data types, most noteably components that contain just nbt blobs (entity data, etc) will not currently be exposed.
Non-Goals
This is not meant to replace ItemMeta, but to allow a more powerful way of interacting with items that may otherwise violate the inheritance tree defined by ItemMeta.
Examples
Old
ItemStack itemStack = new ItemStack(Material.CROSSBOW);
itemStack.editMeta(CrossbowMeta.class, (meta) -> {
meta.setMaxStackSize(10);
meta.setChargedProjectiles(List.of(new ItemStack(Material.FIREWORK_ROCKET)));
});
After
ItemStack itemStack = ItemStack.create(Material.CROSSBOW);
itemStack.setData(DataComponentTypes.MAX_STACK_SIZE, 10);
// All data types will go through a builder
itemStack.setData(DataComponentTypes.CHARGED_PROJECTILES, ChargedProjectiles.chargedProjectiles().add(ItemStack.create(Material.FIREWORK_ROCKET)).build());
New api!
Material.SNOWBALL.getDefaultData(DataComponentTypes.MAX_STACK_SIZE); // What's the default snowball stack size?
itemStack.resetData(DataComponentTypes.MAX_STACK_SIZE); // Lets reset the stack size back to its normal value
ItemStack itemStack = ItemStack.create(Material.BUNDLE);
itemStack.unsetData(DataComponentTypes.BUNDLE_CONTENTS); // A bundle that can't hold anything....




thanks




just not sure what more complex they would do with cmd for example







