Item constructor

Item(
  1. dynamic type, {
  2. int? count,
  3. Slot? slot,
  4. int? damage,
  5. int? model,
  6. int? hideFlags,
  7. TextComponent? name,
  8. List<TextComponent>? lore,
  9. Map<String, dynamic>? nbt,
})

The Item class represents an item in an inventory in Minecraft. It is used in the Give or Nbt Commands.

constructor
Item | Block | String the type of item(required, see example)
count Integer value for the amount of stacked items
slot The current Slot of the item(does not work for give)
damage the used durability of the item
hideFlags int from 1 to 63 describing which information to hide
model int describing which model variant should be used
name a TextComponent showing a name
lore a List of TextComponents giving extra information
nbt additional NBT as Dart Map

Example:

Give(Entity.Selected(),
	item: Item(
		Items.iron_axe, // OR Blocks.stone OR "whatever id"
		count: 5,
		name: TextComponent("My Item",color:Color.Black),
		lore: [
			TextComponent("My Description",color:Color.Blue),
		],
		damage: 40,
		model: 3390001,
		nbt: {
			"customNBT":1
		}
	)
)

⇒ give  @s minecraft:iron_axe{"customNBT":1,"Damage":40,"CustomModelData":3390001,"display":{"Name":"{\"text\":\"My Item\",\"color\":\"black\"}","Lore":["{\"text\":\"My Description\",\"color\":\"blue\"}"]}} 5

Implementation

Item(
  dynamic type, {
  this.count,
  this.slot,
  this.damage,
  int? model,

  /// Used to hide flags, VALUE ranges from 1 to 63
  int? hideFlags,
  TextComponent? name,
  List<TextComponent>? lore,
  Map<String, dynamic>? nbt,
})  : assert(
        type is String || type is Item || type is Block,
        'Please provide either a String, Item or Block',
      ),
      tag = {},
      type = type.toString() {
  // check tags
  _checkTags(model, type, hideFlags, name, lore, nbt);
}