Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit 66a4443

Browse files
committed
Updates from me
1 parent 4156897 commit 66a4443

File tree

2 files changed

+58
-7
lines changed

2 files changed

+58
-7
lines changed

src/pocketmine/entity/passive/Cat.php

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ protected function addBehaviors() : void{
6464
$this->behaviorPool->setBehavior(7, new RandomStrollBehavior($this, 1));
6565
$this->behaviorPool->setBehavior(8, new RandomLookAroundBehavior($this));
6666

67-
6867
// TODO: attack turtle and rabbit
6968
}
7069

src/pocketmine/entity/passive/TropicalFish.php

+58-6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
use pocketmine\item\Item;
3030
use pocketmine\item\ItemFactory;
3131
use pocketmine\math\Vector3;
32+
use pocketmine\nbt\tag\ByteTag;
33+
use pocketmine\nbt\tag\IntTag;
3234
use pocketmine\network\mcpe\protocol\ActorEventPacket;
3335
use function atan2;
3436
use function mt_rand;
@@ -38,7 +40,33 @@
3840
class TropicalFish extends WaterAnimal{
3941
public const NETWORK_ID = self::TROPICAL_FISH;
4042

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;
4270
public $height = 0.4;
4371

4472
/** @var Vector3 */
@@ -48,8 +76,35 @@ class TropicalFish extends WaterAnimal{
4876
private $switchDirectionTicker = 0;
4977

5078
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+
53108
parent::initEntity();
54109
}
55110

@@ -69,8 +124,6 @@ public function attack(EntityDamageEvent $source) : void{
69124
if($e !== null){
70125
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
71126
}
72-
73-
74127
}
75128
}
76129

@@ -108,7 +161,6 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
108161
}
109162
}else{
110163
$this->swimDirection = $this->generateRandomDirection();
111-
$this->swimSpeed = mt_rand(50, 100) / 2000;
112164
}
113165

114166
$f = sqrt(($this->motion->x ** 2) + ($this->motion->z ** 2));

0 commit comments

Comments
 (0)