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

Commit

Permalink
Updates from me 2
Browse files Browse the repository at this point in the history
  • Loading branch information
phoshp committed Oct 21, 2019
1 parent 66a4443 commit f2b4769
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 204 deletions.
3 changes: 2 additions & 1 deletion src/pocketmine/entity/hostile/Blaze.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public function getXpDropAmount() : int{

public function getDrops() : array{
return [
ItemFactory::get(Item::BLAZE_ROD, 0, rand(0, 1)), ItemFactory::get(Item::GLOWSTONE_DUST, 0, rand(0, 2))
ItemFactory::get(Item::BLAZE_ROD, 0, rand(0, 1)),
ItemFactory::get(Item::GLOWSTONE_DUST, 0, rand(0, 2))
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/entity/hostile/Dolphin.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Dolphin extends WaterAnimal{

public function initEntity() : void{
$this->setMaxHealth(10);
$this->swimSpeed = 0.12;

parent::initEntity();
}
Expand Down Expand Up @@ -111,7 +112,6 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
}
}else{
$this->swimDirection = $this->generateRandomDirection();
$this->swimSpeed = mt_rand(50, 100) / 2000;
}

$f = sqrt(($this->motion->x ** 2) + ($this->motion->z ** 2));
Expand Down
3 changes: 2 additions & 1 deletion src/pocketmine/entity/hostile/Skeleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public function getName() : string{

public function getDrops() : array{
return [
ItemFactory::get(Item::BONE, 0, rand(0, 2)), ItemFactory::get(Item::ARROW, 0, rand(0, 2))
ItemFactory::get(Item::BONE, 0, rand(0, 2)),
ItemFactory::get(Item::ARROW, 0, rand(0, 2))
];
}

Expand Down
10 changes: 4 additions & 6 deletions src/pocketmine/entity/hostile/WitherSkeleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,19 @@ public function getDrops() : array{
if(mt_rand(0, 2) < 1){
$drops[] = ItemFactory::get(Item::COAL, 0, 1);
}
if(mt_rand(1, 40) ===1){
if(mt_rand(1, 40) === 1){
$drops[] = ItemFactory::get(Item::MOB_HEAD, 1, 1);
}
return $drops;
}
}

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

if($this->getTargetEntityId() === $entity->getId() and $entity instanceof Living){
$entity->addEffect(new EffectInstance(Effect::getEffect(Effect::WITHER), 200, 1));
}
$entity->addEffect(new EffectInstance(Effect::getEffect(Effect::WITHER), 200, 1));
}


}


public function getXpDropAmount() : int{
Expand Down
16 changes: 8 additions & 8 deletions src/pocketmine/entity/hostile/ZombiePigman.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class ZombiePigman extends Monster implements Ageable{
public $width = 0.6;
public $height = 1.95;

/** @var AltayEntityEquipment */
protected $equipment;
/** @var AltayEntityEquipment */
protected $equipment;

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

parent::initEntity();

$this->equipment = new AltayEntityEquipment($this);
$this->equipment = new AltayEntityEquipment($this);

$this->equipment->setItemInHand(ItemFactory::get(Item::GOLDEN_SWORD));
$this->equipment->setItemInHand(ItemFactory::get(Item::GOLDEN_SWORD));
}

public function getName() : string{
Expand Down Expand Up @@ -103,9 +103,9 @@ protected function addBehaviors() : void{
}


public function sendSpawnPacket(Player $player) : void{
parent::sendSpawnPacket($player);
public function sendSpawnPacket(Player $player) : void{
parent::sendSpawnPacket($player);

$this->equipment->sendContents([$player]);
}
$this->equipment->sendContents([$player]);
}
}
7 changes: 6 additions & 1 deletion src/pocketmine/entity/passive/Chicken.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ protected function addBehaviors() : void{
$this->behaviorPool->setBehavior(0, new FloatBehavior($this));
$this->behaviorPool->setBehavior(1, new PanicBehavior($this, 1.4));
$this->behaviorPool->setBehavior(2, new MateBehavior($this, 1.0));
$this->behaviorPool->setBehavior(3, new TemptBehavior($this, [Item::WHEAT_SEEDS, Item::PUMPKIN_SEEDS, Item::MELON_SEEDS, Item::BEETROOT_SEEDS], 1.0));
$this->behaviorPool->setBehavior(3, new TemptBehavior($this, [
Item::WHEAT_SEEDS,
Item::PUMPKIN_SEEDS,
Item::MELON_SEEDS,
Item::BEETROOT_SEEDS
], 1.0));
$this->behaviorPool->setBehavior(4, new FollowParentBehavior($this, 1.1));
$this->behaviorPool->setBehavior(5, new RandomStrollBehavior($this, 1.0));
$this->behaviorPool->setBehavior(6, new LookAtPlayerBehavior($this, 6.0));
Expand Down
7 changes: 2 additions & 5 deletions src/pocketmine/entity/passive/Cod.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public function attack(EntityDamageEvent $source) : void{
if($e !== null){
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
}


}
}

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

if($this->isAlive()){

if($this->y > 62 and $this->swimDirection !== null){
$this->swimDirection->y = -0.5;
}
Expand All @@ -108,7 +105,7 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
}
}else{
$this->swimDirection = $this->generateRandomDirection();
$this->swimSpeed = mt_rand(50, 100) / 2000;
$this->swimSpeed = 0.05;
}

$f = sqrt(($this->motion->x ** 2) + ($this->motion->z ** 2));
Expand All @@ -123,7 +120,7 @@ public function getDrops() : array{
$drops = [
ItemFactory::get(Item::RAW_FISH, 0, 1),
];
if(mt_rand(1, 4) ===1){
if(mt_rand(1, 4) === 1){
$drops[] = ItemFactory::get(Item::BONE, 1, mt_rand(1, 2));
}
return $drops;
Expand Down
10 changes: 9 additions & 1 deletion src/pocketmine/entity/passive/Horse.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ protected function addBehaviors() : void{
$this->behaviorPool->setBehavior(1, new FloatBehavior($this));
$this->behaviorPool->setBehavior(2, new PanicBehavior($this, 1.25));
$this->behaviorPool->setBehavior(3, new MateBehavior($this, 1.0));
$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));
$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));
$this->behaviorPool->setBehavior(5, new FollowParentBehavior($this, 1.1));
$this->behaviorPool->setBehavior(6, new RandomStrollBehavior($this, 1.0));
$this->behaviorPool->setBehavior(7, new LookAtPlayerBehavior($this, 6.0));
Expand Down
6 changes: 1 addition & 5 deletions src/pocketmine/entity/passive/PolarBear.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function initEntity() : void{
parent::initEntity();
}

//TODO: atack foxes
//TODO: attack fixes

This comment has been minimized.

Copy link
@dearminder

dearminder Oct 22, 2019

it meant that we have to add foxes to attack ;)

This comment has been minimized.

Copy link
@phoshp

phoshp Oct 23, 2019

Author Member

oh

public function getName() : string{
return "Polar Bear";
}
Expand All @@ -83,10 +83,6 @@ public function setAngry(bool $angry = true) : void{
$this->setGenericFlag(self::DATA_FLAG_ANGRY, $angry);
}

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

public function getXpDropAmount() : int{
return rand(1, 3);
}
Expand Down
9 changes: 3 additions & 6 deletions src/pocketmine/entity/passive/Pufferfish.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use pocketmine\item\ItemFactory;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\ActorEventPacket;
use pocketmine\Player;
use function atan2;
use function mt_rand;
use function sqrt;
Expand Down Expand Up @@ -72,15 +73,13 @@ public function attack(EntityDamageEvent $source) : void{
if($e !== null){
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
}

}
}

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


public function entityBaseTick(int $tickDiff = 1) : bool{
if($this->closed){
return false;
Expand Down Expand Up @@ -110,7 +109,7 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
}
}else{
$this->swimDirection = $this->generateRandomDirection();
$this->swimSpeed = mt_rand(50, 100) / 2000;
$this->swimSpeed = 0.05;
}

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




public function getDrops() : array{
$drops = [
ItemFactory::get(Item::PUFFERFISH, 0, 1),
];
if(mt_rand(1, 4) ===1){
if(mt_rand(1, 4) === 1){
$drops[] = ItemFactory::get(Item::BONE, 1, mt_rand(1, 2));
}
return $drops;
Expand Down
1 change: 0 additions & 1 deletion src/pocketmine/entity/passive/Rabbit.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public function getName() : string{
return "Rabbit";
}


public function getXpDropAmount() : int{
return rand(1, 3);
}
Expand Down
7 changes: 2 additions & 5 deletions src/pocketmine/entity/passive/Salmon.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,13 @@ public function attack(EntityDamageEvent $source) : void{
if($e !== null){
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
}


}
}

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


public function entityBaseTick(int $tickDiff = 1) : bool{
if($this->closed){
return false;
Expand Down Expand Up @@ -108,7 +105,7 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
}
}else{
$this->swimDirection = $this->generateRandomDirection();
$this->swimSpeed = mt_rand(50, 100) / 2000;
$this->swimSpeed = 0.05;
}

$f = sqrt(($this->motion->x ** 2) + ($this->motion->z ** 2));
Expand All @@ -123,7 +120,7 @@ public function getDrops() : array{
$drops = [
ItemFactory::get(Item::RAW_SALMON, 0, 1),
];
if(mt_rand(1, 4) ===1){
if(mt_rand(1, 4) === 1){
$drops[] = ItemFactory::get(Item::BONE, 1, mt_rand(1, 2));
}
return $drops;
Expand Down
38 changes: 8 additions & 30 deletions src/pocketmine/entity/passive/SkeletonHorse.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ class SkeletonHorse extends AbstractHorse implements InventoryHolder{

public const NETWORK_ID = self::SKELETON_HORSE;

public const HORSE_VARIANT_WHITE = 0;
public const HORSE_VARIANT_CREAMY = 1;
public const HORSE_VARIANT_CHESTNUT = 2;
public const HORSE_VARIANT_BROWN = 3;
public const HORSE_VARIANT_BLACK = 4;
public const HORSE_VARIANT_GRAY = 5;
public const HORSE_VARIANT_DARK_BROWN = 6;

public const HORSE_MARK_VARIANT_NONE = 0;
public const HORSE_MARK_VARIANT_WHITE = 1;
public const HORSE_MARK_VARIANT_WHITE_FIELD = 2;
public const HORSE_MARK_VARIANT_WHITE_DOTS = 3;
public const HORSE_MARK_VARIANT_BLACK_DOTS = 4;

public $width = 1.4;
public $height = 1.6;

Expand Down Expand Up @@ -89,18 +75,11 @@ protected function addBehaviors() : void{
}

protected function initEntity() : void{
$this->setMaxHealth(15);
$this->setMaxHealth(15);
$this->setMovementSpeed($this->getModifiedMovementSpeed());
$this->setJumpStrength($this->getModifiedJumpStrength());
$this->setFollowRange(35);

if($this->namedtag->hasTag("Variant", IntTag::class) and $this->namedtag->hasTag("MarkVariant", IntTag::class)){
$this->setVariant($this->namedtag->getInt("Variant"));
$this->setMarkVariant($this->namedtag->getInt("MarkVariant"));
}else{
$this->setVariant($this->random->nextBoundedInt(7));
$this->setMarkVariant($this->random->nextBoundedInt(5));
}
$this->inventory = new HorseInventory($this);

if($this->namedtag->hasTag("ArmorItem", CompoundTag::class)){
Expand Down Expand Up @@ -169,12 +148,11 @@ public function saveNBT() : void{
$this->namedtag->setTag($this->inventory->getArmor()->nbtSerialize(-1, "ArmorItem"));
}
}
public
function getDrops(): array
{
return [
ItemFactory::get(Item::BONE, 0, mt_rand(0, 2))
];
}
//TODO: add changing normal horse to skeleton by lightning

public function getDrops() : array{
return [
ItemFactory::get(Item::BONE, 0, mt_rand(0, 2))
];
}
//TODO: add changing normal horse to skeleton by lightning
}
2 changes: 1 addition & 1 deletion src/pocketmine/entity/passive/TropicalFish.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public function initEntity() : void{
}

$this->setMovementSpeed(0.12);
$this->swimSpeed = 0.12;

parent::initEntity();
}
Expand Down Expand Up @@ -161,6 +160,7 @@ public function entityBaseTick(int $tickDiff = 1) : bool{
}
}else{
$this->swimDirection = $this->generateRandomDirection();
$this->swimSpeed = 0.05;
}

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

0 comments on commit f2b4769

Please sign in to comment.