@@ -14,8 +14,9 @@ trait PanicableTrait {
* @return bool
*/
public function entityBaseTick(int $tickDiff = 1) : bool {
if($this->panicTime -= $tickDiff <= 0)
if($this->panicTime -= $tickDiff <= 0) {
$this->setPanic(false);
}
return parent::entityBaseTick($tickDiff);
}

@@ -25,14 +26,15 @@ public function entityBaseTick(int $tickDiff = 1) : bool {
public function setPanic(bool $panic = true) : void {
$this->setSprinting($panic);
$this->inPanic = $panic;
if($panic)
if($panic) {
$this->moveTime = 0;
}
}

/**
* @return bool
*/
public function isInPanic(): bool {
public function isInPanic() : bool {
return $this->inPanic;
}
}
@@ -26,7 +26,7 @@ public static function spawnFromSpawner(Position $spawnPos, ?CompoundTag $spawnD
if(!$spawnPos->isValid() or count($entity->getBlocksAround()) > 1 or (($entity instanceof MonsterBase and $entity->level->getFullLight($entity) > $entity->spawnLight) or ($entity instanceof AnimalBase and $entity->level->getFullLight($entity) < $entity->spawnLight))) {
$entity->flagForDespawn();
return null;
}else{
}else {
$entity->spawnToAll();
return $entity;
}
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\hostile;

class CaveSpider extends Spider {
public const NETWORK_ID = self::CAVE_SPIDER;
public $width = 1.438;
@@ -41,7 +41,7 @@ public function onUpdate(int $currentTick) : bool {
}
if($this->attackTime > 0) {
return parent::onUpdate($currentTick);
}else{
}else {
if($this->moveTime <= 0 and !$this->target instanceof Entity and $this->isTargetValid($this->target)) {
$x = $this->target->x - $this->x;
$y = $this->target->y - $this->y;
@@ -55,8 +55,9 @@ public function onUpdate(int $currentTick) : bool {
$this->yaw = rad2deg(-atan2($x / $diff, $z / $diff)); // TODO: desync head with body when AI improves
}
$this->pitch = $y == 0 ? 0 : rad2deg(-atan2($y, sqrt($x * $x + $z * $z)));
if($this->distance($this->target) <= 0)
if($this->distance($this->target) <= 0) {
$this->target = null;
}
}elseif($this->target instanceof Entity and $this->isTargetValid($this->target)) {
$this->moveTime = 0;
if($this->target->distance($this) <= 3) {
@@ -92,7 +93,7 @@ public function onUpdate(int $currentTick) : bool {
$this->explode();
return false;
}
}else{
}else {
$this->bombTime += $tickDiff;
$this->setGenericFlag(self::DATA_FLAG_IGNITED, false);
if($this->bombTime >= 30) {
@@ -135,7 +136,7 @@ public function entityBaseTick(int $tickDiff = 1) : bool {
}
if(isset($this->target)) {
$this->speed = 1.2;
}else{
}else {
$this->speed = 0.9;
}
$hasUpdate = parent::entityBaseTick($tickDiff);
@@ -148,7 +149,7 @@ public function entityBaseTick(int $tickDiff = 1) : bool {
/**
* @param Player $player
*/
public function onPlayerLook(Player $player): void {
public function onPlayerLook(Player $player) : void {
if($player->canInteract($this, $player->isCreative() ? 13 : 7) and $player->getInventory()->getItemInHand() instanceof FlintSteel) {
$player->getDataPropertyManager()->setString(self::DATA_INTERACTIVE_TAG, "Ignite");
}
@@ -221,6 +222,12 @@ public static function spawnFromSpawner(Position $spawnPos, ?CompoundTag $spawnD
return parent::spawnFromSpawner($spawnPos, $$spawnData); // TODO: Implement spawnFromSpawner() method.
}

public function onCollideWithEntity(Entity $entity) : void {
if($entity instanceof Lightning) {
$this->setCharged();
}
}

public function ignite() : void {
$this->ignited = true;
$this->scheduleUpdate();
@@ -244,11 +251,6 @@ public function setCharged(bool $charged = true) : self {
return $this;
}

public function onCollideWithEntity(Entity $entity) : void {
if($entity instanceof Lightning)
$this->setCharged();
}

/**
* @param Player $player
*/
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\hostile;

class ElderGuardian extends Guardian {
public const NETWORK_ID = self::ELDER_GUARDIAN;
public $width = 1.9975;
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\hostile;

class Husk extends Zombie {
public const NETWORK_ID = self::HUSK;
public $width = 1.031;
@@ -3,8 +3,6 @@
namespace jasonwynn10\VanillaEntityAI\entity\hostile;

use jasonwynn10\VanillaEntityAI\entity\ClimbingTrait;
use jasonwynn10\VanillaEntityAI\entity\Collidable;
use jasonwynn10\VanillaEntityAI\entity\CollisionCheckingTrait;
use jasonwynn10\VanillaEntityAI\entity\CreatureBase;
use jasonwynn10\VanillaEntityAI\entity\InventoryHolder;
use jasonwynn10\VanillaEntityAI\entity\ItemHolderTrait;
@@ -45,13 +43,13 @@ public function initEntity() : void {
parent::initEntity();
}

public function onUpdate(int $currentTick): bool {
public function onUpdate(int $currentTick) : bool {
if($this->isFlaggedForDespawn() or $this->closed) {
return false;
}
if($this->attackTime > 0) {
return parent::onUpdate($currentTick);
}else{
}else {
if($this->moveTime <= 0 and $this->isTargetValid($this->target) and !$this->target instanceof Entity) {
$x = $this->target->x - $this->x;
$y = $this->target->y - $this->y;
@@ -63,8 +61,9 @@ public function onUpdate(int $currentTick): bool {
$this->yaw = rad2deg(-atan2($x / $diff, $z / $diff)); // TODO: desync head with body when AI improves
}
$this->pitch = $y == 0 ? 0 : rad2deg(-atan2($y, sqrt($x * $x + $z * $z)));
if($this->distance($this->target) <= 0)
if($this->distance($this->target) <= 0) {
$this->target = null;
}
}elseif($this->target instanceof Entity and $this->isTargetValid($this->target)) {
$this->moveTime = 0;
if($this->distance($this->target) <= 16) {
@@ -73,28 +72,18 @@ public function onUpdate(int $currentTick): bool {
$force = 1.2; // TODO: correct speed?
$yaw = $this->yaw + mt_rand(-220, 220) / 10;
$pitch = $this->pitch + mt_rand(-120, 120) / 10;
$nbt = Arrow::createBaseNBT(
new Vector3(
$this->x + (-sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 0.5),
$this->y + $this->eyeHeight,
$this->z + (cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 0.5)),
new Vector3(),
$yaw,
$pitch
);
$nbt = Arrow::createBaseNBT(new Vector3($this->x + (-sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 0.5), $this->y + $this->eyeHeight, $this->z + (cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 0.5)), new Vector3(), $yaw, $pitch);
/** @var Arrow $arrow */
$arrow = Arrow::createEntity("Arrow", $this->level, $nbt, $this);

$this->server->getPluginManager()->callEvent($ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $arrow, $force));

$projectile = $ev->getProjectile();
if($ev->isCancelled()){
if($ev->isCancelled()) {
$projectile->flagForDespawn();
}elseif($projectile instanceof Projectile) {
$this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
if($launch->isCancelled()){
if($launch->isCancelled()) {
$projectile->flagForDespawn();
}else{
}else {
$projectile->setMotion(new Vector3(-sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * $ev->getForce(), -sin($pitch / 180 * M_PI) * $ev->getForce(), cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * $ev->getForce()));
$projectile->spawnToAll();
$this->level->addSound(new LaunchSound($this), $projectile->getViewers());
@@ -110,7 +99,7 @@ public function onUpdate(int $currentTick): bool {
$this->motion->z = $this->speed * 0.15 * ($z / $diff);
}
$this->lookAt($this->target->add(0, $this->target->eyeHeight));
}else{
}else {
$x = $this->target->x - $this->x;
$y = $this->target->y - $this->y;
$z = $this->target->z - $this->z;
@@ -215,13 +204,6 @@ public static function spawnFromSpawner(Position $spawnPos, ?CompoundTag $spawnD
// TODO: Implement spawnFromSpawner() method.
}

public function equipRandomItems() : void {
}

public function equipRandomArmour() : void {
// TODO: random armour chance by difficulty
}

public function onCollideWithEntity(Entity $entity) : void {
// TODO: Implement onCollideWithEntity() method.
if($entity instanceof \jasonwynn10\VanillaEntityAI\entity\neutral\Item) {
@@ -233,18 +215,20 @@ public function onCollideWithEntity(Entity $entity) : void {
return;
}
$item = $entity->getItem();
if(!$this->checkItemValueToMainHand($item) and !$this->checkItemValueToOffHand($item))
if(!$this->checkItemValueToMainHand($item) and !$this->checkItemValueToOffHand($item)) {
return;
}
$pk = new TakeItemEntityPacket();
$pk->eid = $this->getId();
$pk->target = $this->getId();
$this->server->broadcastPacket($this->getViewers(), $pk);
$this->setDropAll();
$this->setPersistence(true);
if($this->checkItemValueToMainHand($item))
if($this->checkItemValueToMainHand($item)) {
$this->mainHand = clone $item;
elseif($this->checkItemValueToOffHand($item))
}elseif($this->checkItemValueToOffHand($item)) {
$this->offHand = clone $item;
}
}
}

@@ -253,7 +237,7 @@ public function onCollideWithEntity(Entity $entity) : void {
*
* @return bool
*/
public function checkItemValueToMainHand(Item $item): bool {
public function checkItemValueToMainHand(Item $item) : bool {
return $this->mainHand === null;
}

@@ -262,7 +246,14 @@ public function checkItemValueToMainHand(Item $item): bool {
*
* @return bool
*/
public function checkItemValueToOffHand(Item $item): bool {
public function checkItemValueToOffHand(Item $item) : bool {
return false;
}

public function equipRandomItems() : void {
}

public function equipRandomArmour() : void {
// TODO: random armour chance by difficulty
}
}
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\hostile;

class Stray extends Skeleton {
public const NETWORK_ID = self::STRAY;

@@ -43,7 +43,7 @@ public function initEntity() : void {
}
}
if(mt_rand(1, 100) >= 80) {
if((bool)mt_rand(0, 1)) {
if((bool) mt_rand(0, 1)) {

This comment has been minimized.

Copy link
@jasonwynn10

jasonwynn10 Oct 14, 2018

Author Owner

... because it doesn't return a boolean

This comment has been minimized.

Copy link
@jasonwynn10

jasonwynn10 Oct 17, 2018

Author Owner

0 = integer value, 1 = integer value
false = boolean value, true = boolean value
(bool) 0 = false, (int) false = 0

It doesn't matter in this situation, so don't make a fuss about it

$this->equipRandomItems();
}else {
$this->equipRandomArmour();
@@ -66,8 +66,8 @@ public function onUpdate(int $currentTick) : bool {
}
if($this->attackTime > 0) {
return parent::onUpdate($currentTick);
}else{
if($this->moveTime <= 0 and $this->isTargetValid($this->target) and !$this->target instanceof Entity) {
}else {
if($this->moveTime <= 0 and $this->isTargetValid($this->target) and !$this->target instanceof Entity) {
$x = $this->target->x - $this->x;
$y = $this->target->y - $this->y;
$z = $this->target->z - $this->z;
@@ -78,8 +78,9 @@ public function onUpdate(int $currentTick) : bool {
$this->yaw = rad2deg(-atan2($x / $diff, $z / $diff)); // TODO: desync head with body when AI improves
}
$this->pitch = $y == 0 ? 0 : rad2deg(-atan2($y, sqrt($x * $x + $z * $z)));
if($this->distance($this->target) <= 0)
if($this->distance($this->target) <= 0) {
$this->target = null;
}
}elseif($this->target instanceof Entity and $this->isTargetValid($this->target)) {
$this->moveTime = 0;
$x = $this->target->x - $this->x;
@@ -156,13 +157,13 @@ public function getDrops() : array {
switch(mt_rand(0, 2)) {
case 0:
$drops[] = ItemFactory::get(Item::IRON_INGOT, 0, 1);
break;
break;
case 1:
$drops[] = ItemFactory::get(Item::CARROT, 0, 1);
break;
break;
case 2:
$drops[] = ItemFactory::get(Item::POTATO, 0, 1);
break;
break;
}
}
if($this->dropAll) {
@@ -206,15 +207,16 @@ public function onCollideWithPlayer(Player $player) : void {
switch($this->getLevel()->getDifficulty()) {
case Level::DIFFICULTY_EASY:
$damage = 2;
break;
break;
case Level::DIFFICULTY_NORMAL:
$damage = 3;
break;
break;
case Level::DIFFICULTY_HARD:
$damage = 4;
}
if($this->mainHand !== null)
if($this->mainHand !== null) {
$damage = $this->mainHand->getAttackPoints();
}
$pk = new EntityEventPacket();
$pk->entityRuntimeId = $this->id;
$pk->event = EntityEventPacket::ARM_SWING;
@@ -246,7 +248,7 @@ public static function spawnMob(Position $spawnPos, ?CompoundTag $spawnData = nu
if(!$spawnPos->isValid() or count($entity->getBlocksAround()) > 1 or $spawnPos->level->getFullLight($spawnPos) > $entity->spawnLight) {
$entity->flagForDespawn();
return null;
}else{
}else {
$entity->spawnToAll();
return $entity;
}
@@ -262,15 +264,16 @@ public function onCollideWithEntity(Entity $entity) : void {
switch($this->getLevel()->getDifficulty()) {
case Level::DIFFICULTY_EASY:
$damage = 2;
break;
break;
case Level::DIFFICULTY_NORMAL:
$damage = 3;
break;
break;
case Level::DIFFICULTY_HARD:
$damage = 4;
}
if($this->mainHand !== null)
if($this->mainHand !== null) {
$damage = $this->mainHand->getAttackPoints();
}
$pk = new EntityEventPacket();
$pk->entityRuntimeId = $this->id;
$pk->event = EntityEventPacket::ARM_SWING;
@@ -286,18 +289,20 @@ public function onCollideWithEntity(Entity $entity) : void {
return;
}
$item = $entity->getItem();
if(!$this->checkItemValueToMainHand($item) and !$this->checkItemValueToOffHand($item))
if(!$this->checkItemValueToMainHand($item) and !$this->checkItemValueToOffHand($item)) {
return;
}
$pk = new TakeItemEntityPacket();
$pk->eid = $this->getId();
$pk->target = $this->getId();
$this->server->broadcastPacket($this->getViewers(), $pk);
$this->setDropAll();
$this->setPersistence(true);
if($this->checkItemValueToMainHand($item))
if($this->checkItemValueToMainHand($item)) {
$this->mainHand = clone $item;
elseif($this->checkItemValueToOffHand($item))
}elseif($this->checkItemValueToOffHand($item)) {
$this->offHand = clone $item;
}
}
}

@@ -306,7 +311,7 @@ public function onCollideWithEntity(Entity $entity) : void {
*
* @return bool
*/
public function checkItemValueToMainHand(Item $item): bool {
public function checkItemValueToMainHand(Item $item) : bool {
// TODO: Implement checkItemValueToMainHand() method.
return true;
}
@@ -316,7 +321,7 @@ public function checkItemValueToMainHand(Item $item): bool {
*
* @return bool
*/
public function checkItemValueToOffHand(Item $item): bool {
public function checkItemValueToOffHand(Item $item) : bool {
// TODO: Implement checkItemValueToOffHand() method.
return true;
}
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\hostile;

class ZombieVillager extends Zombie {
public const NETWORK_ID = self::ZOMBIE_VILLAGER;
public $width = 1.031;
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class Arrow extends \pocketmine\entity\projectile\Arrow {
}
@@ -25,4 +25,18 @@ public function entityBaseTick(int $tickDiff = 1) : bool {
public function getName() : string {
return "Boat";
}

/**
* @return Linkable|null
*/
public function getLink() : ?Linkable {
// TODO: Implement getLink() method.
}

/**
* @param Linkable $entity
*/
public function setLink(Linkable $entity) {
// TODO: Implement setLink() method.
}
}
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class ChestMinecart extends Minecart {
public function initEntity() : void {
parent::initEntity(); // TODO: Change the autogenerated stub
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class CommandBlockMinecart extends Minecart {
public function initEntity() : void {
parent::initEntity(); // TODO: Change the autogenerated stub
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class DangerousWitherSkull extends WitherSkull {
}
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class Egg extends \pocketmine\entity\projectile\Egg {
}
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class EnderPearl extends \pocketmine\entity\projectile\EnderPearl {
}
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class ExperienceBottle extends \pocketmine\entity\projectile\ExperienceBottle {
}
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class ExperienceOrb extends \pocketmine\entity\object\ExperienceOrb {
}
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class FallingBlock extends \pocketmine\entity\object\FallingBlock {
}
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class HopperMinecart extends Minecart {
public function initEntity() : void {
parent::initEntity(); // TODO: Change the autogenerated stub
@@ -4,15 +4,10 @@

use jasonwynn10\VanillaEntityAI\entity\Collidable;
use jasonwynn10\VanillaEntityAI\entity\CollisionCheckingTrait;
use jasonwynn10\VanillaEntityAI\entity\InventoryHolder;
use jasonwynn10\VanillaEntityAI\EntityAI;
use pocketmine\block\Block;
use pocketmine\entity\Entity;
use pocketmine\entity\object\ItemEntity;
use pocketmine\event\inventory\InventoryPickupItemEvent;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;

class Item extends ItemEntity implements Collidable {
use CollisionCheckingTrait;
@@ -29,12 +24,12 @@ public function onCollideWithEntity(Entity $entity) : void {
}
}

public function onCollideWithBlock(Block $block): void {
public function onCollideWithBlock(Block $block) : void {
}

/**
* @param AxisAlignedBB $source
*/
public function push(AxisAlignedBB $source): void { // cannot be pushed
public function push(AxisAlignedBB $source) : void { // cannot be pushed
}
}
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class LargeFireball extends Fireball {
}
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class LingeringPotion extends SplashPotion {
}
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class Painting extends \pocketmine\entity\object\Painting {
}
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class Snowball extends \pocketmine\entity\projectile\Snowball {
}
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class SplashPotion extends \pocketmine\entity\projectile\SplashPotion {
}
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\neutral;

class TNTMinecart extends Minecart {
public function initEntity() : void {
parent::initEntity(); // TODO: Change the autogenerated stub
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace jasonwynn10\VanillaEntityAI\entity\passive;

class Squid extends \pocketmine\entity\Squid {
}
@@ -25,14 +25,14 @@ public function onCollideWithBlock(Block $block) : void {
// TODO: Implement onCollideWithBlock() method.
}

public function onPlayerInteract(Player $player) : void {
// TODO: Implement onPlayerInteract() method.
}

/**
* @param AxisAlignedBB $source
*/
public function push(AxisAlignedBB $source): void {
public function push(AxisAlignedBB $source) : void {
// TODO: Implement push() method.
}

public function onPlayerInteract(Player $player) : void {
// TODO: Implement onPlayerInteract() method.
}
}
@@ -3,8 +3,6 @@
namespace jasonwynn10\VanillaEntityAI\entity\passiveaggressive;

use jasonwynn10\VanillaEntityAI\entity\CreatureBase;
use jasonwynn10\VanillaEntityAI\entity\hostile\Creeper;
use jasonwynn10\VanillaEntityAI\entity\hostile\Enderman;
use jasonwynn10\VanillaEntityAI\entity\Interactable;
use jasonwynn10\VanillaEntityAI\network\PlayerNetworkSessionAdapter;
use pocketmine\entity\Entity;
@@ -33,12 +31,14 @@ public function __construct(SourceInterface $interface, string $ip, int $port) {
*/
public function handleEntityPickRequest(EntityPickRequestPacket $packet) : bool {
$target = $this->level->getEntity($packet->entityUniqueId);
if($target === null)
if($target === null) {
return false;
}
if($this->isCreative()) {
$item = Item::get(Item::MONSTER_EGG, $target::NETWORK_ID, 64);
if(!empty($target->getNameTag()))
if(!empty($target->getNameTag())) {
$item->setCustomName($target->getNameTag());
}
$this->getInventory()->setItem($packet->hotbarSlot, $item);
}
return true;
@@ -63,17 +63,18 @@ public function handleInteract(InteractPacket $packet) : bool {
switch($packet->action) {
case InteractPacket::ACTION_LEAVE_VEHICLE:
// TODO: entity linking
break;
break;

This comment has been minimized.

Copy link
@jasonwynn10

jasonwynn10 Oct 14, 2018

Author Owner

because I like this better

case InteractPacket::ACTION_MOUSEOVER:
$target = $this->level->getEntity($packet->target);
$this->setTargetEntity($target);
if($target instanceof CreatureBase){
if($target instanceof CreatureBase) {
// TODO: check player looking at head and if wearing jack 'o lantern
$target->onPlayerLook($this);
}elseif($target === null)
}elseif($target === null) {
$this->getDataPropertyManager()->setString(Entity::DATA_INTERACTIVE_TAG, ""); // Don't show button anymore
}
$return = true;
break;
break;
default:
$this->server->getLogger()->debug("Unhandled/unknown interaction type " . $packet->action . "received from " . $this->getName());
$return = false;
@@ -100,7 +101,7 @@ public function handleInventoryTransaction(InventoryTransactionPacket $packet) :
return true;
break;
}
break;
break;
}
}
return $return;
@@ -45,7 +45,10 @@ public function onRun(int $currentTick) {
foreach($chunks as $chunk) {
$packCenter = new Vector3(mt_rand($chunk->getX() << 4, (($chunk->getX() << 4) + 15)), mt_rand(0, $level->getWorldHeight() - 1), mt_rand($chunk->getZ() << 4, (($chunk->getZ() << 4) + 15)));
$biomeId = $level->getBiomeId($packCenter->x, $packCenter->z);
$entityId = BiomeEntityList::BIOME_HOSTILE_MOBS[$biomeId][array_rand(BiomeEntityList::BIOME_HOSTILE_MOBS[$biomeId])];
$entityList = BiomeEntityList::BIOME_HOSTILE_MOBS[$biomeId];
if(empty($entityList))
continue;
$entityId = $entityList[array_rand(BiomeEntityList::BIOME_HOSTILE_MOBS[$biomeId])];
if(!$level->getBlockAt($packCenter->x, $packCenter->y, $packCenter->z)->isSolid()) {
for($attempts = 0, $currentPackSize = 0; $attempts <= 12 and $currentPackSize < 4; $attempts++) {
$x = mt_rand(-20, 20) + $packCenter->x;
@@ -42,7 +42,10 @@ public function onRun(int $currentTick) {
foreach($chunks as $chunk) {
$packCenter = new Vector3(mt_rand($chunk->getX() << 4, (($chunk->getX() << 4) + 15)), mt_rand(0, $level->getWorldHeight() - 1), mt_rand($chunk->getZ() << 4, (($chunk->getZ() << 4) + 15)));
$biomeId = $level->getBiomeId($packCenter->x, $packCenter->z);
$entityId = BiomeEntityList::BIOME_ANIMALS[$biomeId][array_rand(BiomeEntityList::BIOME_ANIMALS[$biomeId])];
$entityList = BiomeEntityList::BIOME_ANIMALS[$biomeId];
if(empty($entityList))
continue;
$entityId = $entityList[array_rand(BiomeEntityList::BIOME_ANIMALS[$biomeId])];
if(!$level->getBlockAt($packCenter->x, $packCenter->y, $packCenter->z)->isSolid()) {
for($attempts = 0, $currentPackSize = 0; $attempts <= 12 and $currentPackSize < 4; $attempts++) {
$x = mt_rand(-20, 20) + $packCenter->x;