35
35
36
36
public class Firefly extends PathfinderMob implements FlyingAnimal , GeoEntity {
37
37
private final AnimatableInstanceCache cache = GeckoLibUtil .createInstanceCache (this );
38
+
38
39
private static final EntityDataAccessor <Boolean > roost = SynchedEntityData .defineId (Firefly .class , EntityDataSerializers .BOOLEAN );
39
- private static final EntityDataAccessor <Boolean > baby = SynchedEntityData .defineId (Firefly .class , EntityDataSerializers .BOOLEAN );
40
+ private static final EntityDataAccessor <Integer > baby = SynchedEntityData .defineId (Firefly .class , EntityDataSerializers .INT );
41
+
40
42
public static final RawAnimation idleRaw = RawAnimation .begin ().thenLoop ("idle" );
41
43
public static final RawAnimation babyRaw = RawAnimation .begin ().thenLoop ("baby" );
42
44
public Firefly (EntityType <? extends PathfinderMob > type , Level level ) {
@@ -49,7 +51,7 @@ public Firefly(EntityType<? extends PathfinderMob> type, Level level) {
49
51
protected void defineSynchedData (SynchedEntityData .Builder builder ) {
50
52
super .defineSynchedData (builder );
51
53
builder .define (roost , false );
52
- builder .define (baby , false );
54
+ builder .define (baby , 0 );
53
55
}
54
56
55
57
@ Nullable
@@ -67,9 +69,24 @@ public boolean isRoost() {
67
69
return this .entityData .get (roost );
68
70
}
69
71
70
- public boolean isBaby () { return this .entityData .get (baby ); }
71
- public void setBaby (boolean b ) {this .entityData .set (baby , b );}
72
+ @ Override
73
+ public boolean isBaby () {
74
+ return this .entityData .get (baby ) < 300 ;
75
+ }
72
76
77
+ public int getBaby () {
78
+ return this .entityData .get (baby );
79
+ }
80
+
81
+ public void setBaby (int b ) {this .entityData .set (baby , b );}
82
+
83
+ @ Override
84
+ public void tick () {
85
+ super .tick ();
86
+ if (isBaby ()) {
87
+ setBaby (getBaby ()+1 );
88
+ }
89
+ }
73
90
74
91
@ Override
75
92
public boolean canBeLeashed () {
@@ -80,14 +97,14 @@ public boolean canBeLeashed() {
80
97
public void readAdditionalSaveData (CompoundTag compound ) {
81
98
super .readAdditionalSaveData (compound );
82
99
this .setRoost (compound .getBoolean ("roost" ));
83
- this .setBaby (compound .getBoolean ("baby" ));
100
+ this .setBaby (compound .getInt ("baby" ));
84
101
}
85
102
86
103
@ Override
87
104
public void addAdditionalSaveData (CompoundTag compound ) {
88
105
super .addAdditionalSaveData (compound );
89
106
compound .putBoolean ("roost" , isRoost ());
90
- compound .putBoolean ("baby" , isBaby ());
107
+ compound .putInt ("baby" , getBaby ());
91
108
}
92
109
93
110
@ Override
0 commit comments