diff --git a/plugin.yml b/plugin.yml index 83e7b25..3ec8230 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,10 +1,10 @@ name: VanillaEntityAI main: jasonwynn10\VanillaEntityAI\EntityAI -version: 0.0.1 +version: 1.0.0 api: - 3.0.0 description: "A plugin for vanilla-like mob AI" author: "jasonwynn10" load: STARTUP softdepend: - - PureEntitiesX \ No newline at end of file +- PureEntitiesX \ No newline at end of file diff --git a/src/jasonwynn10/VanillaEntityAI/EntityAI.php b/src/jasonwynn10/VanillaEntityAI/EntityAI.php index 756defa..6109b4f 100644 --- a/src/jasonwynn10/VanillaEntityAI/EntityAI.php +++ b/src/jasonwynn10/VanillaEntityAI/EntityAI.php @@ -350,7 +350,7 @@ public function getRegionalDifficulty(Level $level, Chunk $chunk): float { } $phaseTime = $level->getTime() / Level::TIME_FULL; while($phaseTime > 5) - $phaseTime -= 5; // TODO: better method + $phaseTime -= 5; // TODO: find better method $moonPhase = 1.0; switch($phaseTime) { case 1: diff --git a/src/jasonwynn10/VanillaEntityAI/entity/CollisionCheckingTrait.php b/src/jasonwynn10/VanillaEntityAI/entity/CollisionCheckingTrait.php index e15ce31..385ce6c 100644 --- a/src/jasonwynn10/VanillaEntityAI/entity/CollisionCheckingTrait.php +++ b/src/jasonwynn10/VanillaEntityAI/entity/CollisionCheckingTrait.php @@ -20,11 +20,12 @@ protected function checkNearEntities() { continue; } $entity->scheduleUpdate(); - if($entity instanceof Collidable) { + if($entity instanceof Collidable and $this instanceof Collidable) { if($this->getBoundingBox()->intersectsWith($entity->getBoundingBox())) { $entity->push($this->getBoundingBox()); } $entity->onCollideWithEntity($this); + $this->onCollideWithEntity($entity); } } } diff --git a/src/jasonwynn10/VanillaEntityAI/entity/hostile/Skeleton.php b/src/jasonwynn10/VanillaEntityAI/entity/hostile/Skeleton.php index 23bcd65..b04b38d 100644 --- a/src/jasonwynn10/VanillaEntityAI/entity/hostile/Skeleton.php +++ b/src/jasonwynn10/VanillaEntityAI/entity/hostile/Skeleton.php @@ -207,7 +207,6 @@ public static function spawnFromSpawner(Position $spawnPos, ?CompoundTag $spawnD } public function onCollideWithEntity(Entity $entity) : void { - // TODO: Implement onCollideWithEntity() method. if($entity instanceof \jasonwynn10\VanillaEntityAI\entity\neutral\Item) { if($entity->getPickupDelay() > 0 or !$this instanceof InventoryHolder or $this->level->getDifficulty() <= Level::DIFFICULTY_EASY) { return; @@ -222,7 +221,7 @@ public function onCollideWithEntity(Entity $entity) : void { } $pk = new TakeItemEntityPacket(); $pk->eid = $this->getId(); - $pk->target = $this->getId(); + $pk->target = $entity->getId(); $this->server->broadcastPacket($this->getViewers(), $pk); $this->setDropAll(); $this->setPersistence(true); diff --git a/src/jasonwynn10/VanillaEntityAI/entity/hostile/Zombie.php b/src/jasonwynn10/VanillaEntityAI/entity/hostile/Zombie.php index 8643828..b7b6d7c 100644 --- a/src/jasonwynn10/VanillaEntityAI/entity/hostile/Zombie.php +++ b/src/jasonwynn10/VanillaEntityAI/entity/hostile/Zombie.php @@ -294,7 +294,7 @@ public function onCollideWithEntity(Entity $entity) : void { } $pk = new TakeItemEntityPacket(); $pk->eid = $this->getId(); - $pk->target = $this->getId(); + $pk->target = $entity->getId(); $this->server->broadcastPacket($this->getViewers(), $pk); $this->setDropAll(); $this->setPersistence(true); diff --git a/src/jasonwynn10/VanillaEntityAI/entity/neutral/Item.php b/src/jasonwynn10/VanillaEntityAI/entity/neutral/Item.php index 10fc1cc..93d1c70 100644 --- a/src/jasonwynn10/VanillaEntityAI/entity/neutral/Item.php +++ b/src/jasonwynn10/VanillaEntityAI/entity/neutral/Item.php @@ -13,9 +13,9 @@ class Item extends ItemEntity implements Collidable { use CollisionCheckingTrait; public function entityBaseTick(int $tickDiff = 1) : bool { - foreach($this->level->getNearbyEntities($this->boundingBox->expandedCopy(1.5,1.5,1.5), $this) as $entity) { - if($this->pickupDelay === 0 and $entity instanceof Item and $entity->onGround and $this->motion->equals($entity->getMotion()) and $this->item->equals($entity->getItem())) { - $this->item->setCount($this->item->getCount() + $entity->getItem()->getCount()); + foreach($this->level->getNearbyEntities($this->boundingBox->expandedCopy(0.5,0.5,0.5), $this) as $entity) { + if($this->pickupDelay === 0 and $entity instanceof Item and $entity->onGround and $this->motion->equals($entity->getMotion()) and $this->item->equals($entity->getItem()) and ($count = $this->item->getCount() + $entity->getItem()->getCount()) <= $this->item->getMaxStackSize()) { + $this->item->setCount($count); $entity->flagForDespawn(); foreach($this->getViewers() as $player) $this->sendSpawnPacket($player);