getMap method

Map<String, dynamic> getMap([
  1. bool useId = true
])

Implementation

Map<String, dynamic> getMap([bool useId = true]) {
  final map = <String, dynamic>{};
  final id = useId ? 'id' : 'item';
  map[id] = 'minecraft:${getId()}';
  if (tag != null && tag!.isNotEmpty) map['tag'] = tag;
  if (count != null) map['Count'] = Byte(count!);
  if (slot != null) {
    if (slot!.id == null) throw ('An Item needs the Slot id!');
    if (slot!.id! < 0) {
      print(
        'Please note that you are using Item with a negative slot. This is reserved for a selected item and can\'t be accessed within the Inventory property!',
      );
    }
    map['Slot'] = Byte(slot!.id ?? 0);
  }
  return map;
}