getJson method

  1. @override
Map<String, dynamic> getJson()
override

Implementation

@override
Map<String, dynamic> getJson() {
  var ret = <String, dynamic>{
    'condition': 'minecraft:match_tool',
    'predicate': predicate?.getJson() ?? {},
  };
  if (count != null) ret['predicate']['count'] = _getRangeMap(count);
  if (durability != null) {
    ret['predicate']['durability'] = _getRangeMap(durability);
  }
  if (item != null) ret['predicate']['item'] = item!.getId();
  if (potion != null) ret['predicate']['potion'] = potion;
  if (potion != null) ret['predicate']['potion'] = potion;
  if (nbt != null) ret['predicate']['nbt'] = gson.encode(nbt);
  if (storedEnchantments != null && storedEnchantments!.isNotEmpty) {
    ret['predicate']['stored_enchantments'] =
        storedEnchantments!.map((e) => e.getJson()).toList();
  }
  return ret;
}