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

Commit f2b4769

Browse files
committed
Updates from me 2
1 parent 66a4443 commit f2b4769

15 files changed

+154
-204
lines changed

src/pocketmine/entity/hostile/Blaze.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public function getXpDropAmount() : int{
7575

7676
public function getDrops() : array{
7777
return [
78-
ItemFactory::get(Item::BLAZE_ROD, 0, rand(0, 1)), ItemFactory::get(Item::GLOWSTONE_DUST, 0, rand(0, 2))
78+
ItemFactory::get(Item::BLAZE_ROD, 0, rand(0, 1)),
79+
ItemFactory::get(Item::GLOWSTONE_DUST, 0, rand(0, 2))
7980
];
8081
}
8182

src/pocketmine/entity/hostile/Dolphin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Dolphin extends WaterAnimal{
5353

5454
public function initEntity() : void{
5555
$this->setMaxHealth(10);
56+
$this->swimSpeed = 0.12;
5657

5758
parent::initEntity();
5859
}
@@ -111,7 +112,6 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
111112
}
112113
}else{
113114
$this->swimDirection = $this->generateRandomDirection();
114-
$this->swimSpeed = mt_rand(50, 100) / 2000;
115115
}
116116

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

src/pocketmine/entity/hostile/Skeleton.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public function getName() : string{
7676

7777
public function getDrops() : array{
7878
return [
79-
ItemFactory::get(Item::BONE, 0, rand(0, 2)), ItemFactory::get(Item::ARROW, 0, rand(0, 2))
79+
ItemFactory::get(Item::BONE, 0, rand(0, 2)),
80+
ItemFactory::get(Item::ARROW, 0, rand(0, 2))
8081
];
8182
}
8283

src/pocketmine/entity/hostile/WitherSkeleton.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,19 @@ public function getDrops() : array{
7474
if(mt_rand(0, 2) < 1){
7575
$drops[] = ItemFactory::get(Item::COAL, 0, 1);
7676
}
77-
if(mt_rand(1, 40) ===1){
77+
if(mt_rand(1, 40) === 1){
7878
$drops[] = ItemFactory::get(Item::MOB_HEAD, 1, 1);
7979
}
8080
return $drops;
81-
}
81+
}
8282

8383
public function onCollideWithEntity(Entity $entity) : void{
8484
parent::onCollideWithEntity($entity);
8585

8686
if($this->getTargetEntityId() === $entity->getId() and $entity instanceof Living){
87-
$entity->addEffect(new EffectInstance(Effect::getEffect(Effect::WITHER), 200, 1));
88-
}
87+
$entity->addEffect(new EffectInstance(Effect::getEffect(Effect::WITHER), 200, 1));
8988
}
90-
91-
89+
}
9290

9391

9492
public function getXpDropAmount() : int{

src/pocketmine/entity/hostile/ZombiePigman.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class ZombiePigman extends Monster implements Ageable{
4545
public $width = 0.6;
4646
public $height = 1.95;
4747

48-
/** @var AltayEntityEquipment */
49-
protected $equipment;
48+
/** @var AltayEntityEquipment */
49+
protected $equipment;
5050

5151
protected function initEntity() : void{
5252
$this->setMovementSpeed($this->isBaby() ? 0.35 : 0.23);
@@ -55,9 +55,9 @@ protected function initEntity() : void{
5555

5656
parent::initEntity();
5757

58-
$this->equipment = new AltayEntityEquipment($this);
58+
$this->equipment = new AltayEntityEquipment($this);
5959

60-
$this->equipment->setItemInHand(ItemFactory::get(Item::GOLDEN_SWORD));
60+
$this->equipment->setItemInHand(ItemFactory::get(Item::GOLDEN_SWORD));
6161
}
6262

6363
public function getName() : string{
@@ -103,9 +103,9 @@ protected function addBehaviors() : void{
103103
}
104104

105105

106-
public function sendSpawnPacket(Player $player) : void{
107-
parent::sendSpawnPacket($player);
106+
public function sendSpawnPacket(Player $player) : void{
107+
parent::sendSpawnPacket($player);
108108

109-
$this->equipment->sendContents([$player]);
110-
}
109+
$this->equipment->sendContents([$player]);
110+
}
111111
}

src/pocketmine/entity/passive/Chicken.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ protected function addBehaviors() : void{
6868
$this->behaviorPool->setBehavior(0, new FloatBehavior($this));
6969
$this->behaviorPool->setBehavior(1, new PanicBehavior($this, 1.4));
7070
$this->behaviorPool->setBehavior(2, new MateBehavior($this, 1.0));
71-
$this->behaviorPool->setBehavior(3, new TemptBehavior($this, [Item::WHEAT_SEEDS, Item::PUMPKIN_SEEDS, Item::MELON_SEEDS, Item::BEETROOT_SEEDS], 1.0));
71+
$this->behaviorPool->setBehavior(3, new TemptBehavior($this, [
72+
Item::WHEAT_SEEDS,
73+
Item::PUMPKIN_SEEDS,
74+
Item::MELON_SEEDS,
75+
Item::BEETROOT_SEEDS
76+
], 1.0));
7277
$this->behaviorPool->setBehavior(4, new FollowParentBehavior($this, 1.1));
7378
$this->behaviorPool->setBehavior(5, new RandomStrollBehavior($this, 1.0));
7479
$this->behaviorPool->setBehavior(6, new LookAtPlayerBehavior($this, 6.0));

src/pocketmine/entity/passive/Cod.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ public function attack(EntityDamageEvent $source) : void{
6969
if($e !== null){
7070
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
7171
}
72-
73-
7472
}
7573
}
7674

@@ -94,7 +92,6 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
9492
$hasUpdate = parent::entityBaseTick($tickDiff);
9593

9694
if($this->isAlive()){
97-
9895
if($this->y > 62 and $this->swimDirection !== null){
9996
$this->swimDirection->y = -0.5;
10097
}
@@ -108,7 +105,7 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
108105
}
109106
}else{
110107
$this->swimDirection = $this->generateRandomDirection();
111-
$this->swimSpeed = mt_rand(50, 100) / 2000;
108+
$this->swimSpeed = 0.05;
112109
}
113110

114111
$f = sqrt(($this->motion->x ** 2) + ($this->motion->z ** 2));
@@ -123,7 +120,7 @@ public function getDrops() : array{
123120
$drops = [
124121
ItemFactory::get(Item::RAW_FISH, 0, 1),
125122
];
126-
if(mt_rand(1, 4) ===1){
123+
if(mt_rand(1, 4) === 1){
127124
$drops[] = ItemFactory::get(Item::BONE, 1, mt_rand(1, 2));
128125
}
129126
return $drops;

src/pocketmine/entity/passive/Horse.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,15 @@ protected function addBehaviors() : void{
8282
$this->behaviorPool->setBehavior(1, new FloatBehavior($this));
8383
$this->behaviorPool->setBehavior(2, new PanicBehavior($this, 1.25));
8484
$this->behaviorPool->setBehavior(3, new MateBehavior($this, 1.0));
85-
$this->behaviorPool->setBehavior(4, new TemptBehavior($this, [Item::WHEAT, Item::APPLE, Item::WHEAT_BLOCK, Item::GOLDEN_APPLE, Item::ENCHANTED_GOLDEN_APPLE, Item::GOLDEN_CARROT, Item::SUGAR], 1.2));
85+
$this->behaviorPool->setBehavior(4, new TemptBehavior($this, [
86+
Item::WHEAT,
87+
Item::APPLE,
88+
Item::WHEAT_BLOCK,
89+
Item::GOLDEN_APPLE,
90+
Item::ENCHANTED_GOLDEN_APPLE,
91+
Item::GOLDEN_CARROT,
92+
Item::SUGAR
93+
], 1.2));
8694
$this->behaviorPool->setBehavior(5, new FollowParentBehavior($this, 1.1));
8795
$this->behaviorPool->setBehavior(6, new RandomStrollBehavior($this, 1.0));
8896
$this->behaviorPool->setBehavior(7, new LookAtPlayerBehavior($this, 6.0));

src/pocketmine/entity/passive/PolarBear.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function initEntity() : void{
6363
parent::initEntity();
6464
}
6565

66-
//TODO: atack foxes
66+
//TODO: attack fixes
6767
public function getName() : string{
6868
return "Polar Bear";
6969
}
@@ -83,10 +83,6 @@ public function setAngry(bool $angry = true) : void{
8383
$this->setGenericFlag(self::DATA_FLAG_ANGRY, $angry);
8484
}
8585

86-
private function generateRandomDirection() : Vector3{
87-
return new Vector3(mt_rand(-1000, 1000) / 1000, mt_rand(-500, 500) / 1000, mt_rand(-1000, 1000) / 1000);
88-
}
89-
9086
public function getXpDropAmount() : int{
9187
return rand(1, 3);
9288
}

src/pocketmine/entity/passive/Pufferfish.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use pocketmine\item\ItemFactory;
3434
use pocketmine\math\Vector3;
3535
use pocketmine\network\mcpe\protocol\ActorEventPacket;
36+
use pocketmine\Player;
3637
use function atan2;
3738
use function mt_rand;
3839
use function sqrt;
@@ -72,15 +73,13 @@ public function attack(EntityDamageEvent $source) : void{
7273
if($e !== null){
7374
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
7475
}
75-
7676
}
7777
}
7878

7979
private function generateRandomDirection() : Vector3{
8080
return new Vector3(mt_rand(-1000, 1000) / 1000, mt_rand(-500, 500) / 1000, mt_rand(-1000, 1000) / 1000);
8181
}
8282

83-
8483
public function entityBaseTick(int $tickDiff = 1) : bool{
8584
if($this->closed){
8685
return false;
@@ -110,7 +109,7 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
110109
}
111110
}else{
112111
$this->swimDirection = $this->generateRandomDirection();
113-
$this->swimSpeed = mt_rand(50, 100) / 2000;
112+
$this->swimSpeed = 0.05;
114113
}
115114

116115
$f = sqrt(($this->motion->x ** 2) + ($this->motion->z ** 2));
@@ -132,13 +131,11 @@ public function onCollideWithEntity(Entity $entity) : void{
132131
}
133132

134133

135-
136-
137134
public function getDrops() : array{
138135
$drops = [
139136
ItemFactory::get(Item::PUFFERFISH, 0, 1),
140137
];
141-
if(mt_rand(1, 4) ===1){
138+
if(mt_rand(1, 4) === 1){
142139
$drops[] = ItemFactory::get(Item::BONE, 1, mt_rand(1, 2));
143140
}
144141
return $drops;

src/pocketmine/entity/passive/Rabbit.php

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public function getName() : string{
6666
return "Rabbit";
6767
}
6868

69-
7069
public function getXpDropAmount() : int{
7170
return rand(1, 3);
7271
}

src/pocketmine/entity/passive/Salmon.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,13 @@ public function attack(EntityDamageEvent $source) : void{
6969
if($e !== null){
7070
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
7171
}
72-
73-
7472
}
7573
}
7674

7775
private function generateRandomDirection() : Vector3{
7876
return new Vector3(mt_rand(-1000, 1000) / 1000, mt_rand(-500, 500) / 1000, mt_rand(-1000, 1000) / 1000);
7977
}
8078

81-
8279
public function entityBaseTick(int $tickDiff = 1) : bool{
8380
if($this->closed){
8481
return false;
@@ -108,7 +105,7 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
108105
}
109106
}else{
110107
$this->swimDirection = $this->generateRandomDirection();
111-
$this->swimSpeed = mt_rand(50, 100) / 2000;
108+
$this->swimSpeed = 0.05;
112109
}
113110

114111
$f = sqrt(($this->motion->x ** 2) + ($this->motion->z ** 2));
@@ -123,7 +120,7 @@ public function getDrops() : array{
123120
$drops = [
124121
ItemFactory::get(Item::RAW_SALMON, 0, 1),
125122
];
126-
if(mt_rand(1, 4) ===1){
123+
if(mt_rand(1, 4) === 1){
127124
$drops[] = ItemFactory::get(Item::BONE, 1, mt_rand(1, 2));
128125
}
129126
return $drops;

src/pocketmine/entity/passive/SkeletonHorse.php

+8-30
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,6 @@ class SkeletonHorse extends AbstractHorse implements InventoryHolder{
4646

4747
public const NETWORK_ID = self::SKELETON_HORSE;
4848

49-
public const HORSE_VARIANT_WHITE = 0;
50-
public const HORSE_VARIANT_CREAMY = 1;
51-
public const HORSE_VARIANT_CHESTNUT = 2;
52-
public const HORSE_VARIANT_BROWN = 3;
53-
public const HORSE_VARIANT_BLACK = 4;
54-
public const HORSE_VARIANT_GRAY = 5;
55-
public const HORSE_VARIANT_DARK_BROWN = 6;
56-
57-
public const HORSE_MARK_VARIANT_NONE = 0;
58-
public const HORSE_MARK_VARIANT_WHITE = 1;
59-
public const HORSE_MARK_VARIANT_WHITE_FIELD = 2;
60-
public const HORSE_MARK_VARIANT_WHITE_DOTS = 3;
61-
public const HORSE_MARK_VARIANT_BLACK_DOTS = 4;
62-
6349
public $width = 1.4;
6450
public $height = 1.6;
6551

@@ -89,18 +75,11 @@ protected function addBehaviors() : void{
8975
}
9076

9177
protected function initEntity() : void{
92-
$this->setMaxHealth(15);
78+
$this->setMaxHealth(15);
9379
$this->setMovementSpeed($this->getModifiedMovementSpeed());
9480
$this->setJumpStrength($this->getModifiedJumpStrength());
9581
$this->setFollowRange(35);
9682

97-
if($this->namedtag->hasTag("Variant", IntTag::class) and $this->namedtag->hasTag("MarkVariant", IntTag::class)){
98-
$this->setVariant($this->namedtag->getInt("Variant"));
99-
$this->setMarkVariant($this->namedtag->getInt("MarkVariant"));
100-
}else{
101-
$this->setVariant($this->random->nextBoundedInt(7));
102-
$this->setMarkVariant($this->random->nextBoundedInt(5));
103-
}
10483
$this->inventory = new HorseInventory($this);
10584

10685
if($this->namedtag->hasTag("ArmorItem", CompoundTag::class)){
@@ -169,12 +148,11 @@ public function saveNBT() : void{
169148
$this->namedtag->setTag($this->inventory->getArmor()->nbtSerialize(-1, "ArmorItem"));
170149
}
171150
}
172-
public
173-
function getDrops(): array
174-
{
175-
return [
176-
ItemFactory::get(Item::BONE, 0, mt_rand(0, 2))
177-
];
178-
}
179-
//TODO: add changing normal horse to skeleton by lightning
151+
152+
public function getDrops() : array{
153+
return [
154+
ItemFactory::get(Item::BONE, 0, mt_rand(0, 2))
155+
];
156+
}
157+
//TODO: add changing normal horse to skeleton by lightning
180158
}

src/pocketmine/entity/passive/TropicalFish.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public function initEntity() : void{
103103
}
104104

105105
$this->setMovementSpeed(0.12);
106-
$this->swimSpeed = 0.12;
107106

108107
parent::initEntity();
109108
}
@@ -161,6 +160,7 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
161160
}
162161
}else{
163162
$this->swimDirection = $this->generateRandomDirection();
163+
$this->swimSpeed = 0.05;
164164
}
165165

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

0 commit comments

Comments
 (0)