getNbt method

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

Implementation

@override
Map<String, dynamic> getNbt([bool useId = true]) {
  final nbt = super.getNbt(useId);

  void addIfExist(dynamic val, String tag) {
    if (val != null) nbt[tag] = val;
  }

  addIfExist(billboardType?.name, 'billboard');
  addIfExist(itemDisplay?.name, 'display');
  addIfExist(shadowRadius, 'shadow_radius');
  addIfExist(shadowStrength, 'shadow_strength');
  addIfExist(viewRange, 'view_range');
  addIfExist(interpolationDuration?.ticks, 'interpolation_duration');
  addIfExist(startInterpolation?.ticks, 'start_interpolation');
  addIfExist(alignment?.name, 'alignment');
  addIfExist(textOpacity, 'textOpacity');
  addIfExist(seeThrough, 'see_through');
  addIfExist(item?.getMap(), 'item');
  addIfExist(block?.getBlockState(), 'block_state');
  addIfExist(text?.toJson(), 'text');
  addIfExist(lineWidth, 'line_width');
  addIfExist(transformation?.toMap(), 'transformation');
  return nbt;
}