diff --git a/src/Player.php b/src/Player.php index 24acc74c..cff267f4 100755 --- a/src/Player.php +++ b/src/Player.php @@ -1432,9 +1432,9 @@ class Player{ $this->entity->z = $this->data->get("position")["z"]; $pk = new StartGamePacket; $pk->seed = $this->level->getSeed(); - $pk->spawnX = (int) $spawnPos->x; - $pk->spawnY = (int) $spawnPos->y; - $pk->spawnZ = (int) $spawnPos->z; + $pk->spawnX = (int) $this->spawnPosition->x; + $pk->spawnY = (int) $this->spawnPosition->y; + $pk->spawnZ = (int) $this->spawnPosition->z; $pk->x = (int) $this->entity->x; $pk->y = (int) $this->entity->y; $pk->z = (int) $this->entity->z; diff --git a/src/constants/EntityIDs.php b/src/constants/EntityIDs.php index 46293f3c..faab8439 100644 --- a/src/constants/EntityIDs.php +++ b/src/constants/EntityIDs.php @@ -33,11 +33,4 @@ define("ENTITY_OBJECT", 3); define("ENTITY_ITEM", 4); define("ENTITY_FALLING", 5); - define("FALLING_SAND", 66); - -//TileEntities -define("TILE_SIGN", "Sign"); -define("TILE_CHEST", "Chest"); - define("CHEST_SLOTS", 27); -define("TILE_FURNACE", "Furnace"); - define("FURNACE_SLOTS", 3); \ No newline at end of file + define("FALLING_SAND", 66); \ No newline at end of file diff --git a/src/material/Block.php b/src/material/Block.php index e9a7b3bc..441550aa 100755 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -145,7 +145,7 @@ abstract class Block extends Position{ COCOA => "CocoaBlock", RED_MUSHROOM_BLOCK => "RedMushroomSolidBlock", BROWN_MUSHROOM_BLOCK => "BrownMushroomSolidBlock", - MONSTER_SPAWNER => "MonsterSpawnerBlock", + MONSTER_SPAWNER => "MobSpawnerBlock", VINES => "VinesBlock", MYCELIUM => "MyceliumBlock", ); diff --git a/src/world/Tile.php b/src/world/Tile.php index 64c8fbfe..a1ced35b 100644 --- a/src/world/Tile.php +++ b/src/world/Tile.php @@ -36,6 +36,7 @@ class Tile extends Position{ switch($this->class){ case TILE_CHEST: case TILE_SIGN: + case TILE_MOB_SPAWNER: $this->server->query("UPDATE tiles SET spawnable = 1 WHERE ID = " . $this->id . ";"); break; case TILE_FURNACE: @@ -336,6 +337,67 @@ class Tile extends Position{ $player = $this->server->api->player->get($player); } switch($this->class){ + case TILE_MOB_SPAWNER: + $nbt = new NBT(); //TODO fix + $nbt->write(chr(NBT::TAG_COMPOUND) . "\x00\x00"); + + $nbt->write(chr(NBT::TAG_STRING)); + $nbt->writeTAG_String("id"); + $nbt->writeTAG_String($this->class); + + $nbt->write(chr(NBT::TAG_INT)); + $nbt->writeTAG_String("x"); + $nbt->writeTAG_Int((int) $this->x); + + $nbt->write(chr(NBT::TAG_INT)); + $nbt->writeTAG_String("y"); + $nbt->writeTAG_Int((int) $this->y); + + $nbt->write(chr(NBT::TAG_INT)); + $nbt->writeTAG_String("z"); + $nbt->writeTAG_Int((int) $this->z); + + $nbt->write(chr(NBT::TAG_INT)); + $nbt->writeTAG_String("EntityId"); + $nbt->writeTAG_Int((int) $this->data["EntityId"]); + + $nbt->write(chr(NBT::TAG_SHORT)); + $nbt->writeTAG_String("Delay"); + $nbt->writeTAG_SHORT((int) $this->data["Delay"]); + + $nbt->write(chr(NBT::TAG_SHORT)); + $nbt->writeTAG_String("MinSpawnDelay"); + $nbt->writeTAG_SHORT((int) $this->data["MinSpawnDelay"]); + + $nbt->write(chr(NBT::TAG_SHORT)); + $nbt->writeTAG_String("MaxSpawnDelay"); + $nbt->writeTAG_SHORT((int) $this->data["MaxSpawnDelay"]); + + $nbt->write(chr(NBT::TAG_SHORT)); + $nbt->writeTAG_String("SpawnCount"); + $nbt->writeTAG_SHORT((int) $this->data["SpawnCount"]); + + $nbt->write(chr(NBT::TAG_SHORT)); + $nbt->writeTAG_String("MaxNearbyEntities"); + $nbt->writeTAG_SHORT((int) $this->data["MaxNearbyEntities"]); + + $nbt->write(chr(NBT::TAG_SHORT)); + $nbt->writeTAG_String("RequiredPlayerRange"); + $nbt->writeTAG_SHORT((int) $this->data["RequiredPlayerRange"]); + + $nbt->write(chr(NBT::TAG_SHORT)); + $nbt->writeTAG_String("SpawnRange"); + $nbt->writeTAG_SHORT((int) $this->data["SpawnRange"]); + + //console(bin2hex($nbt->binary)); + + $pk = new EntityDataPacket; + $pk->x = $this->x; + $pk->y = $this->y; + $pk->z = $this->z; + $pk->namedtag = $nbt->binary; + $player->dataPacket($pk); + break; case TILE_CHEST: $nbt = new NBT(); $nbt->write(chr(NBT::TAG_COMPOUND) . "\x00\x00");