mc_vanilla/entity/
bat.rs

1use mc_core::entity::SingleEntityCodec;
2use mc_core::util::NbtExt;
3use mc_core::entity_component;
4use nbt::CompoundTag;
5
6#[derive(Debug, Default)]
7pub struct BatEntity {
8    hanging: bool
9}
10
11entity_component!(BatEntity: BatEntityCodec);
12
13pub struct BatEntityCodec;
14impl SingleEntityCodec for BatEntityCodec {
15
16    type Comp = BatEntity;
17
18    fn encode(&self, src: &Self::Comp, dst: &mut CompoundTag) {
19        dst.insert_bool("BatFlags", src.hanging);
20    }
21
22    fn decode(&self, src: &CompoundTag) -> Self::Comp {
23        BatEntity {
24            hanging: src.get_bool_or("BatFlags", false)
25        }
26    }
27
28}