diff --git a/src/API/EntityAPI.php b/src/API/EntityAPI.php index 9acb925a..2579490e 100644 --- a/src/API/EntityAPI.php +++ b/src/API/EntityAPI.php @@ -158,7 +158,7 @@ class EntityAPI{ $efl = EntityRegistry::$entityList->getEntityFromTypeAndClass($type, $class); if($efl instanceof PropertyEntity){ $class = $efl->getEntityName(); - $this->entities[$eid] = new $class($level, $eid, $efl->getEntityClass(), $efl->getEntityClass() === ENTITY_ITEM ? $type : $efl->getEntityType(), $data); + $this->entities[$eid] = new $class($level, $eid, $efl->getEntityClass(), $efl->getEntityType(), $data); }else{ $this->entities[$eid] = new Entity($level, $eid, $class, $type, $data); } @@ -261,12 +261,14 @@ class EntityAPI{ "speedY" => $speedY, "speedZ" => $speedZ, "item" => $item, + "itemID" => $item->getID() ]; + if($this->server->api->handle("item.drop", $data) !== false){ for($count = $item->count; $count > 0;){ $item->count = min($item->getMaxStackSize(), $count); $count -= $item->count; - $e = $this->add($pos->level, ENTITY_ITEM, $item->getID(), $data); + $e = $this->add($pos->level, ENTITY_ITEM, ENTITY_ITEM_TYPE, $data); $this->spawnToAll($e); $this->server->api->handle("entity.motion", $e); } @@ -286,12 +288,13 @@ class EntityAPI{ "speedY" => 0.2, "speedZ" => lcg_value() * 0.2 - 0.1, "item" => $item, + "itemID" => $item->getID() ]; if($this->server->api->handle("item.drop", $data) !== false){ for($count = $item->count; $count > 0;){ $item->count = min($item->getMaxStackSize(), $count); $count -= $item->count; - $e = $this->add($pos->level, ENTITY_ITEM, $item->getID(), $data); + $e = $this->add($pos->level, ENTITY_ITEM, ENTITY_ITEM_TYPE, $data); $this->spawnToAll($e); $this->server->api->handle("entity.motion", $e); } diff --git a/src/API/LevelAPI.php b/src/API/LevelAPI.php index dac35c6c..dc65c6a8 100644 --- a/src/API/LevelAPI.php +++ b/src/API/LevelAPI.php @@ -65,9 +65,10 @@ class LevelAPI{ $entity["pitch"] = $entity["Rotation"][1]; if($entity["id"] === 64){ //Item Drop - $e = $this->server->api->entity->add($this->levels[$name], ENTITY_ITEM, $entity["Item"]["id"], [ + $e = $this->server->api->entity->add($this->levels[$name], ENTITY_ITEM, ENTITY_ITEM_TYPE, [ "meta" => $entity["Item"]["Damage"], "stack" => $entity["Item"]["Count"], + "itemID" => $entity["Item"]["id"], "x" => $entity["Pos"][0], "y" => $entity["Pos"][1], "z" => $entity["Pos"][2], diff --git a/src/Player.php b/src/Player.php index 2b4524e2..b90006d3 100755 --- a/src/Player.php +++ b/src/Player.php @@ -760,9 +760,9 @@ class Player{ $pk->target = $data["entity"]->eid; $this->dataPacket($pk); if(($this->gamemode & 0x01) === 0x00){ - $this->addItem($data["entity"]->type, $data["entity"]->meta, $data["entity"]->stack, false); + $this->addItem($data["entity"]->itemID, $data["entity"]->meta, $data["entity"]->stack, false); } - switch($data["entity"]->type){ + switch($data["entity"]->itemID){ case WOOD: AchievementAPI::grantAchievement($this, "mineWood"); break; @@ -2074,7 +2074,6 @@ class Player{ $sX += cos($f3) * $f1; $sY += ($this->entity->random->nextFloat() - $this->entity->random->nextFloat()) * 0.1; $sZ += sin($f3) * $f1; - $this->server->api->entity->dropRawPos(new Position($this->entity->x, $this->entity->y - 0.3 + $this->entity->height - 0.12, $this->entity->z, $this->level), $packet->item, $sX, $sY, $sZ); $this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), false); } diff --git a/src/constants/EntityIDs.php b/src/constants/EntityIDs.php index dacf8e95..4e6b0293 100644 --- a/src/constants/EntityIDs.php +++ b/src/constants/EntityIDs.php @@ -25,7 +25,8 @@ define("ENTITY_OBJECT", 3); define("OBJECT_MINECART", 84); define("ENTITY_ITEM", 4); - + define("ENTITY_ITEM_TYPE", 64); + define("ENTITY_FALLING", 5); define("FALLING_SAND", 66); diff --git a/src/entity/ai/tasks/TaskFollowParent.php b/src/entity/ai/tasks/TaskFollowParent.php index 3c71c031..f1addfbc 100644 --- a/src/entity/ai/tasks/TaskFollowParent.php +++ b/src/entity/ai/tasks/TaskFollowParent.php @@ -32,7 +32,7 @@ class TaskFollowParent extends TaskBase } $parent = $ai->entity->parent; - $ai->mobController->setLookPosition($parent->x, $parent->y + $parent->getEyeHeight(), $parent->z, 30, $ai->entity->getVerticalFaceSpeed()); + $ai->mobController->setLookPosition($parent->x, $parent->y + $parent->getEyeHeight(), $parent->z, 10, $ai->entity->getVerticalFaceSpeed()); $ai->mobController->setMovingTarget($parent->x, $parent->y, $parent->z, $this->speedMultiplier); } diff --git a/src/entity/object/ItemEntity.php b/src/entity/object/ItemEntity.php index 62961400..a006735e 100644 --- a/src/entity/object/ItemEntity.php +++ b/src/entity/object/ItemEntity.php @@ -1,11 +1,11 @@ setSize(0.25, 0.25); $this->yOffset = $this->height / 2; if(isset($data["item"]) and ($data["item"] instanceof Item)){ - $this->meta = $this->data["item"]->getMetadata(); - $this->stack = $this->data["item"]->count; + $this->meta = $data["item"]->getMetadata(); + $this->stack = $data["item"]->count; + $this->itemID = $data["item"]->getID(); } else{ - $this->meta = (int) $this->data["meta"]; - $this->stack = (int) $this->data["stack"]; + $this->meta = (int) $data["meta"]; + $this->stack = (int) $data["stack"]; + $this->itemID = (int) $data["itemID"]; } $this->hasGravity = true; $this->setHealth(5, "generic"); @@ -50,7 +52,7 @@ class ItemEntity extends Entity{ $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->roll = 0; - $pk->item = BlockAPI::getItem($this->type, $this->meta, $this->stack); + $pk->item = BlockAPI::getItem($this->itemID, $this->meta, $this->stack); $pk->metadata = $this->getMetadata(); $player->dataPacket($pk); @@ -68,7 +70,7 @@ class ItemEntity extends Entity{ if($another->eid == $this->eid) return false; if(!$another->closed && !$this->closed){ - if($another->type == $this->type && $another->meta == $this->meta){ + if($another->itemID == $this->itemID && $another->meta == $this->meta){ if(($another->stack + $this->stack) > 64) return false; //TODO dynamic stack size $another->stack += $this->stack; diff --git a/src/entity/registry/EntityList.php b/src/entity/registry/EntityList.php index 7d31cfdb..615c5820 100644 --- a/src/entity/registry/EntityList.php +++ b/src/entity/registry/EntityList.php @@ -8,7 +8,6 @@ class EntityList{ $this->entities[$property->getEntityType()] = $property; } public function getEntityFromTypeAndClass($type, $class){ - if($class === ENTITY_ITEM) return $this->entities["itemSpecial"]; return isset($this->entities[$type]) && $this->entities[$type]->getEntityClass() === $class ? $this->entities[$type] : 0; } private $entities = []; diff --git a/src/world/Level.php b/src/world/Level.php index 96a54cd4..f2870ffd 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -562,7 +562,7 @@ class Level{ $this->checkSleep(); - if($server->ticks % 10 === 0){ //10 ticks delay + if($server->ticks % 10 === 0){ $this->mobSpawner->handle(); }