29
29
use pocketmine \item \Item ;
30
30
use pocketmine \item \ItemFactory ;
31
31
use pocketmine \math \Vector3 ;
32
+ use pocketmine \nbt \tag \ByteTag ;
33
+ use pocketmine \nbt \tag \IntTag ;
32
34
use pocketmine \network \mcpe \protocol \ActorEventPacket ;
33
35
use function atan2 ;
34
36
use function mt_rand ;
38
40
class TropicalFish extends WaterAnimal{
39
41
public const NETWORK_ID = self ::TROPICAL_FISH ;
40
42
41
- public $ width = 0.5 ;
43
+ public const SHAPE_A = 0 ;
44
+ public const SHAPE_B = 1 ;
45
+
46
+ public const PATTERN_1 = 0 ;
47
+ public const PATTERN_2 = 1 ;
48
+ public const PATTERN_3 = 2 ;
49
+ public const PATTERN_4 = 3 ;
50
+ public const PATTERN_5 = 4 ;
51
+ public const PATTERN_6 = 5 ;
52
+
53
+ public const COLOR_WHITE = 0 ;
54
+ public const COLOR_ORANGE = 1 ;
55
+ public const COLOR_MAGENTA = 2 ;
56
+ public const COLOR_LIGHTBLUE = 3 ;
57
+ public const COLOR_YELLOW = 4 ;
58
+ public const COLOR_LIGHTGREEN = 5 ;
59
+ public const COLOR_PINK = 6 ;
60
+ public const COLOR_GRAY = 7 ;
61
+ public const COLOR_SILVER = 8 ;
62
+ public const COLOR_CYAN = 9 ;
63
+ public const COLOR_PURPLE = 10 ;
64
+ public const COLOR_BLUE = 11 ;
65
+ public const COLOR_BROWN = 12 ;
66
+ public const COLOR_GREEN = 13 ;
67
+ public const COLOR_RED = 14 ;
68
+
69
+ public $ width = 0.4 ;
42
70
public $ height = 0.4 ;
43
71
44
72
/** @var Vector3 */
@@ -48,8 +76,35 @@ class TropicalFish extends WaterAnimal{
48
76
private $ switchDirectionTicker = 0 ;
49
77
50
78
public function initEntity () : void {
51
- $ this ->setMaxHealth (3 );
52
- //TODO: Add diffrent styles of fish
79
+ $ this ->setMaxHealth (6 );
80
+
81
+ if ($ this ->namedtag ->hasTag ("Variant " , IntTag::class)){
82
+ $ this ->propertyManager ->setInt (self ::DATA_VARIANT , $ this ->namedtag ->getInt ("Variant " ));
83
+ }else {
84
+ $ this ->propertyManager ->setInt (self ::DATA_VARIANT , mt_rand (0 , 1 ));
85
+ }
86
+
87
+ if ($ this ->namedtag ->hasTag ("MarkVariant " , IntTag::class)){
88
+ $ this ->propertyManager ->setInt (self ::DATA_MARK_VARIANT , $ this ->namedtag ->getInt ("MarkVariant " ));
89
+ }else {
90
+ $ this ->propertyManager ->setInt (self ::DATA_MARK_VARIANT , mt_rand (0 , 5 ));
91
+ }
92
+
93
+ if ($ this ->namedtag ->hasTag ("Color " , ByteTag::class)){
94
+ $ this ->propertyManager ->setByte (self ::DATA_COLOR , $ this ->namedtag ->getByte ("Color " ));
95
+ }else {
96
+ $ this ->propertyManager ->setByte (self ::DATA_COLOR , mt_rand (0 , 14 ));
97
+ }
98
+
99
+ if ($ this ->namedtag ->hasTag ("Color2 " , ByteTag::class)){
100
+ $ this ->propertyManager ->setByte (self ::DATA_COLOR_2 , $ this ->namedtag ->getByte ("Color2 " ));
101
+ }else {
102
+ $ this ->propertyManager ->setByte (self ::DATA_COLOR_2 , mt_rand (0 , 14 ));
103
+ }
104
+
105
+ $ this ->setMovementSpeed (0.12 );
106
+ $ this ->swimSpeed = 0.12 ;
107
+
53
108
parent ::initEntity ();
54
109
}
55
110
@@ -69,8 +124,6 @@ public function attack(EntityDamageEvent $source) : void{
69
124
if ($ e !== null ){
70
125
$ this ->swimDirection = (new Vector3 ($ this ->x - $ e ->x , $ this ->y - $ e ->y , $ this ->z - $ e ->z ))->normalize ();
71
126
}
72
-
73
-
74
127
}
75
128
}
76
129
@@ -108,7 +161,6 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
108
161
}
109
162
}else {
110
163
$ this ->swimDirection = $ this ->generateRandomDirection ();
111
- $ this ->swimSpeed = mt_rand (50 , 100 ) / 2000 ;
112
164
}
113
165
114
166
$ f = sqrt (($ this ->motion ->x ** 2 ) + ($ this ->motion ->z ** 2 ));
0 commit comments