From b1748b539386190164d8d2abb88c029f3f74e0fb Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 22 Nov 2013 15:28:28 +0100 Subject: [PATCH 01/26] Removed language include --- PocketMine-MP.php | 1 - 1 file changed, 1 deletion(-) diff --git a/PocketMine-MP.php b/PocketMine-MP.php index b2521b2a6..c25727944 100644 --- a/PocketMine-MP.php +++ b/PocketMine-MP.php @@ -22,7 +22,6 @@ /***REM_START***/ require_once(dirname(__FILE__)."/src/config.php"); -require_once(FILE_PATH . "/src/language/en_us.php"); require_once(FILE_PATH."/src/functions.php"); require_once(FILE_PATH."/src/dependencies.php"); From 079d24055dccfe43e2d522eaad59a985ae58b6d0 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 22 Nov 2013 23:42:48 +0100 Subject: [PATCH 02/26] Updated compile script * PHP 5.5.6 * pthreads 0.0.45 (stable!) * cURL 7.33.0 --- src/build/compile.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/build/compile.sh b/src/build/compile.sh index 69d4f2fc6..a8d3fd6ef 100755 --- a/src/build/compile.sh +++ b/src/build/compile.sh @@ -1,13 +1,13 @@ #!/bin/bash -COMPILER_VERSION="0.13" +COMPILER_VERSION="0.14" -PHP_VERSION="5.5.3" +PHP_VERSION="5.5.6" ZEND_VM="GOTO" LIBEDIT_VERSION="0.3" ZLIB_VERSION="1.2.8" -PTHREADS_VERSION="0.0.44" -CURL_VERSION="curl-7_32_0" +PTHREADS_VERSION="0.0.45" +CURL_VERSION="curl-7_33_0" echo "[PocketMine] PHP installer and compiler for Linux & Mac" DIR="$(pwd)" From c7168a6c64dbd85879e6b13c6d583f109a2c6790 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 10:11:25 +0100 Subject: [PATCH 03/26] Fixed #926 [gh#926] --- src/network/RCON.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/RCON.php b/src/network/RCON.php index 7f3c7bc2a..82190c696 100644 --- a/src/network/RCON.php +++ b/src/network/RCON.php @@ -132,7 +132,7 @@ class RCONInstance extends Thread{ public function run(){ while($this->stop !== true){ - usleep(1); + usleep(2000); $r = array($socket = $this->socket); $w = null; $e = null; From 54d37a432eb0492bf97aa5da5f96898ffca020ac Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 10:17:38 +0100 Subject: [PATCH 04/26] Check that ServerAPI::request() works, fixes #916 [gh#916] --- src/API/ServerAPI.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index cf16dd7bc..5c4de5012 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -276,6 +276,10 @@ class ServerAPI{ } public function init(){ + if(!(self::$serverRequest instanceof PocketMinecraftServer)){ + self::$serverRequest = $this->server; + } + if($this->getProperty("send-usage") !== false){ $this->server->schedule(6000, array($this, "sendUsage"), array(), true); //Send the info after 5 minutes have passed $this->sendUsage(); From c973abc36f4907918655d68e47fb19ff46371004 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 10:22:24 +0100 Subject: [PATCH 05/26] Added --disable-ansi to disable console colors #887 --- src/dependencies.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dependencies.php b/src/dependencies.php index d3fa0ac48..81dcc63a1 100644 --- a/src/dependencies.php +++ b/src/dependencies.php @@ -26,7 +26,7 @@ require_once(FILE_PATH."/src/functions.php"); /***REM_END***/ define(DATA_PATH, realpath(arg("data-path", FILE_PATH))."/"); -if(arg("enable-ansi", strpos(strtoupper(php_uname("s")), "WIN") === 0 ? false:true) === true){ +if(arg("enable-ansi", strpos(strtoupper(php_uname("s")), "WIN") === 0 ? false:true) === true and arg("disable-ansi", false) !== true){ define("ENABLE_ANSI", true); }else{ define("ENABLE_ANSI", false); From 14a40ac11e10b859693f83eba767ee3e725db89a Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 10:46:24 +0100 Subject: [PATCH 06/26] Remove keycodes from console input --- src/API/ConsoleAPI.php | 2 +- src/config.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/API/ConsoleAPI.php b/src/API/ConsoleAPI.php index 1fb87d2da..87d25de4a 100644 --- a/src/API/ConsoleAPI.php +++ b/src/API/ConsoleAPI.php @@ -273,7 +273,7 @@ class ConsoleAPI{ return; } if($this->loop->line !== false){ - $line = trim($this->loop->line); + $line = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($this->loop->line)); $this->loop->line = false; $output = $this->run($line, "console"); if($output != ""){ diff --git a/src/config.php b/src/config.php index 9afff1e91..7d56fa28b 100644 --- a/src/config.php +++ b/src/config.php @@ -60,7 +60,7 @@ ini_set("memory_limit", "128M"); //Default define("LOG", true); define("START_TIME", microtime(true)); define("MAJOR_VERSION", "Alpha_1.3.10dev"); -define("CURRENT_MINECRAFT_VERSION", "0.7.6 alpha"); +define("CURRENT_MINECRAFT_VERSION", "v0.7.6 alpha"); define("CURRENT_API_VERSION", 10); define("CURRENT_PHP_VERSION", "5.5"); $gitsha1 = false; From 719df75886c73baaefa8c318b13c4436eede2d6f Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 10:59:52 +0100 Subject: [PATCH 07/26] Water flow code reformatting --- src/material/block/liquid/Water.php | 89 ++++++++++------------------- 1 file changed, 30 insertions(+), 59 deletions(-) diff --git a/src/material/block/liquid/Water.php b/src/material/block/liquid/Water.php index 666e85156..1959fe789 100644 --- a/src/material/block/liquid/Water.php +++ b/src/material/block/liquid/Water.php @@ -31,17 +31,13 @@ class WaterBlock extends LiquidBlock{ return $ret; } - public function getSourceCount() - { + public function getSourceCount(){ $count = 0; - for($side = 2; $side <= 5; ++$side) - { - if( $this->getSide($side) instanceof WaterBlock ) - { + for($side = 2; $side <= 5; ++$side){ + if( $this->getSide($side) instanceof WaterBlock ){ $b = $this->getSide($side); $level = $b->meta & 0x07; - if($level == 0x00) - { + if($level == 0x00){ $count++; } } @@ -49,21 +45,17 @@ class WaterBlock extends LiquidBlock{ return $count; } - public function checkLava() - { - for($side = 0; $side <= 5; ++$side) - { - if($side == 1) { continue; } + public function checkLava(){ + for($side = 0; $side <= 5; ++$side){ + if($side == 1){ + continue; + } $b = $this->getSide($side); - if($b instanceof LavaBlock) - { + if($b instanceof LavaBlock){ $level = $b->meta & 0x07; - if($level == 0x00) - { + if($level == 0x00){ $this->level->setBlock($b, new ObsidianBlock(), false, false, true); - } - else - { + }else{ $this->level->setBlock($b, new CobblestoneBlock(), false, false, true); } return true; @@ -72,17 +64,13 @@ class WaterBlock extends LiquidBlock{ return false; } - public function getFrom() - { - for($side = 0; $side <= 5; ++$side) - { + public function getFrom(){ + for($side = 0; $side <= 5; ++$side){ $b = $this->getSide($side); - if($b instanceof WaterBlock) - { + if($b instanceof WaterBlock){ $tlevel = $b->meta & 0x07; $level = $this->meta & 0x07; - if( ($tlevel + 1) == $level || ($side == 0x01 && $level == 0x01 ) ) - { + if( ($tlevel + 1) == $level || ($side == 0x01 && $level == 0x01 )){ return $b; } } @@ -105,56 +93,39 @@ class WaterBlock extends LiquidBlock{ $from = $this->getFrom(); //Has Source or Its Source - if($from !== null || $level == 0x00) - { - if($level !== 0x07) - { - if($down instanceof AirBlock || $down instanceof WaterBlock) - { + if($from !== null || $level == 0x00){ + if($level !== 0x07){ + if($down instanceof AirBlock || $down instanceof WaterBlock){ $this->level->setBlock($down, new WaterBlock(0x01), false, false, true); ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL); - } - else - { - for($side = 2; $side <= 5; ++$side) - { + }else{ + for($side = 2; $side <= 5; ++$side){ $b = $this->getSide($side); - if($b instanceof WaterBlock) - { - if( $this->getSourceCount() >= 2 && $level != 0x00) - { + if($b instanceof WaterBlock){ + if( $this->getSourceCount() >= 2 && $level != 0x00){ $this->level->setBlock($this, new WaterBlock(0), false, false, true); } - } - else if($b->isFlowable === true) - { + }elseif($b->isFlowable === true){ $this->level->setBlock($b, new WaterBlock($level + 1), false, false, true); ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL); } } } } - } - else - { + }else{ //Extend Remove for Left Waters - for($side = 2; $side <= 5; ++$side) - { + for($side = 2; $side <= 5; ++$side){ $sb = $this->getSide($side); - if($sb instanceof WaterBlock) - { + if($sb instanceof WaterBlock){ $tlevel = $sb->meta & 0x07; - if($tlevel != 0x00) - { + if($tlevel != 0x00){ $this->level->setBlock($sb, new AirBlock(), false, false, true); } } $b = $this->getSide(0)->getSide($side); - if($b instanceof WaterBlock) - { + if($b instanceof WaterBlock){ $tlevel = $b->meta & 0x07; - if($tlevel != 0x00) - { + if($tlevel != 0x00){ $this->level->setBlock($b, new AirBlock(), false, false, true); } } From 809ca802b357788226f158ebb896854f2ecee520 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 11:00:22 +0100 Subject: [PATCH 08/26] PocketMine-MP Alpha_1.3.10 Stable Release --- src/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.php b/src/config.php index 7d56fa28b..4c016eb0d 100644 --- a/src/config.php +++ b/src/config.php @@ -59,7 +59,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . FILE_PATH); ini_set("memory_limit", "128M"); //Default define("LOG", true); define("START_TIME", microtime(true)); -define("MAJOR_VERSION", "Alpha_1.3.10dev"); +define("MAJOR_VERSION", "Alpha_1.3.10"); define("CURRENT_MINECRAFT_VERSION", "v0.7.6 alpha"); define("CURRENT_API_VERSION", 10); define("CURRENT_PHP_VERSION", "5.5"); From f32f379e971468d1a312217cf05f67cdc31739ff Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 11:04:36 +0100 Subject: [PATCH 09/26] Lava flow code reformatting --- src/material/block/liquid/Lava.php | 89 ++++++++++-------------------- 1 file changed, 30 insertions(+), 59 deletions(-) diff --git a/src/material/block/liquid/Lava.php b/src/material/block/liquid/Lava.php index 1dfbb7743..5eb39efa2 100644 --- a/src/material/block/liquid/Lava.php +++ b/src/material/block/liquid/Lava.php @@ -31,17 +31,13 @@ class LavaBlock extends LiquidBlock{ return $ret; } - public function getSourceCount() - { + public function getSourceCount(){ $count = 0; - for($side = 2; $side <= 5; ++$side) - { - if( $this->getSide($side) instanceof LavaBlock ) - { + for($side = 2; $side <= 5; ++$side){ + if($this->getSide($side) instanceof LavaBlock ){ $b = $this->getSide($side); $level = $b->meta & 0x07; - if($level == 0x00) - { + if($level == 0x00){ $count++; } } @@ -49,37 +45,27 @@ class LavaBlock extends LiquidBlock{ return $count; } - public function checkWater() - { - for($side = 1; $side <= 5; ++$side) - { + public function checkWater(){ + for($side = 1; $side <= 5; ++$side){ $b = $this->getSide($side); - if($b instanceof WaterBlock) - { + if($b instanceof WaterBlock){ $level = $this->meta & 0x07; - if($level == 0x00) - { + if($level == 0x00){ $this->level->setBlock($this, new ObsidianBlock(), false, false, true); - } - else - { + }else{ $this->level->setBlock($this, new CobblestoneBlock(), false, false, true); } } } } - public function getFrom() - { - for($side = 0; $side <= 5; ++$side) - { + public function getFrom(){ + for($side = 0; $side <= 5; ++$side){ $b = $this->getSide($side); - if($b instanceof LavaBlock) - { + if($b instanceof LavaBlock){ $tlevel = $b->meta & 0x07; $level = $this->meta & 0x07; - if( ($tlevel + 2) == $level || ($side == 0x01 && $level == 0x01 ) || ($tlevel == 6 && $level == 7 )) - { + if( ($tlevel + 2) == $level || ($side == 0x01 && $level == 0x01 ) || ($tlevel == 6 && $level == 7 )){ return $b; } } @@ -95,66 +81,51 @@ class LavaBlock extends LiquidBlock{ return false; } - if( $this->checkWater() ) { return; } + if( $this->checkWater()){ + return; + } $falling = $this->meta >> 3; $down = $this->getSide(0); $from = $this->getFrom(); - //출처가 있거나 이 자체가 출처이면 - if($from !== null || $level == 0x00) - { - if($level !== 0x07) - { - if($down instanceof AirBlock || $down instanceof LavaBlock) - { + if($from !== null || $level == 0x00){ + if($level !== 0x07){ + if($down instanceof AirBlock || $down instanceof LavaBlock){ $this->level->setBlock($down, new LavaBlock(0x01), false, false, true); ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($down, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL); - } - else - { - for($side = 2; $side <= 5; ++$side) - { + }else{ + for($side = 2; $side <= 5; ++$side){ $b = $this->getSide($side); - if($b instanceof LavaBlock) - { + if($b instanceof LavaBlock){ - } - else if($b->isFlowable === true) - { + }else if($b->isFlowable === true){ $this->level->setBlock($b, new LavaBlock( min($level + 2,7) ), false, false, true); ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL); } } } } - } - else - { + }else{ //Extend Remove for Left Lavas - for($side = 2; $side <= 5; ++$side) - { + for($side = 2; $side <= 5; ++$side){ $sb = $this->getSide($side); - if($sb instanceof LavaBlock) - { + if($sb instanceof LavaBlock){ $tlevel = $sb->meta & 0x07; - if($tlevel != 0x00) - { + if($tlevel != 0x00){ $this->level->setBlock($sb, new AirBlock(), false, false, true); } } $b = $this->getSide(0)->getSide($side); - if($b instanceof LavaBlock) - { + if($b instanceof LavaBlock){ $tlevel = $b->meta & 0x07; - if($tlevel != 0x00) - { + if($tlevel != 0x00){ $this->level->setBlock($b, new AirBlock(), false, false, true); } } //ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL); } - //출처가 제거된 경우 이 블록 제거 + $this->level->setBlock($this, new AirBlock(), false, false, true); } return false; From 3d53b9eb3a0904bcabdf2e372e61f0ba0df78482 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 11:06:01 +0100 Subject: [PATCH 10/26] Armor drop - tested --- src/world/Entity.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/world/Entity.php b/src/world/Entity.php index 373bbe6d1..b61328e78 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -167,9 +167,7 @@ class Entity extends Position{ $inv[] = array($slot->getID(), $slot->getMetadata(), $slot->count); } } - for($re = 0; $re < 3; $re++) - { - //TODO: Test this + for($re = 0; $re < 3; $re++){ $slot = $this->player->getArmor($re); $this->player->setArmor($re, BlockAPI::getItem(AIR, 0, 0)); if($slot->getID() !== AIR and $slot->count > 0){ From ba7c9503d888d3cf70da2b0062ded44d4811fbb5 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 13:52:13 +0100 Subject: [PATCH 11/26] 0.8.0 partial compatibility * Not compatible with Creative mode --- src/Player.php | 18 +++- src/config.php | 6 +- src/network/CustomPacketHandler.php | 17 ++- src/network/ProtocolInfo.php | 162 +++++++--------------------- src/world/Entity.php | 2 +- 5 files changed, 75 insertions(+), 130 deletions(-) diff --git a/src/Player.php b/src/Player.php index f4eb63294..b132105cf 100644 --- a/src/Player.php +++ b/src/Player.php @@ -852,8 +852,9 @@ class Player{ "x" => $pos->x, "y" => $pos->y, "z" => $pos->z, - "yaw" => $yaw, + "bodyYaw" => $yaw, "pitch" => $pitch, + "yaw" => $yaw, )); } @@ -1310,6 +1311,20 @@ class Player{ break; } break; + case MC_ROTATE_HEAD: + if($this->spawned === false){ + break; + } + if(($this->entity instanceof Entity)){ + if($this->blocked === true or $this->server->api->handle("player.move", $this->entity) === false){ + if($this->lastCorrect instanceof Vector3){ + $this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false); + } + }else{ + $this->entity->setPosition($this->entity, $data["yaw"], $data["pitch"]); + } + } + break; case MC_MOVE_PLAYER: if($this->spawned === false){ break; @@ -1340,7 +1355,6 @@ class Player{ if($this->spawned === false){ break; } - $data["eid"] = $this->eid; $data["player"] = $this; diff --git a/src/config.php b/src/config.php index 4c016eb0d..9c0b0bd2a 100644 --- a/src/config.php +++ b/src/config.php @@ -59,9 +59,9 @@ set_include_path(get_include_path() . PATH_SEPARATOR . FILE_PATH); ini_set("memory_limit", "128M"); //Default define("LOG", true); define("START_TIME", microtime(true)); -define("MAJOR_VERSION", "Alpha_1.3.10"); -define("CURRENT_MINECRAFT_VERSION", "v0.7.6 alpha"); -define("CURRENT_API_VERSION", 10); +define("MAJOR_VERSION", "Alpha_1.3.11dev"); +define("CURRENT_MINECRAFT_VERSION", "v0.8.0 alpha build 2"); +define("CURRENT_API_VERSION", 11); define("CURRENT_PHP_VERSION", "5.5"); $gitsha1 = false; if(file_exists(FILE_PATH.".git/refs/heads/master")){ //Found Git information! diff --git a/src/network/CustomPacketHandler.php b/src/network/CustomPacketHandler.php index 78206b39c..88916b415 100644 --- a/src/network/CustomPacketHandler.php +++ b/src/network/CustomPacketHandler.php @@ -367,21 +367,34 @@ class CustomPacketHandler{ $this->raw .= Utils::writeFloat($this->data["pitch"]); } break; + case MC_ROTATE_HEAD: + if($this->c === false){ + $this->data["eid"] = Utils::readInt($this->get(4)); + $this->data["yaw"] = Utils::readFloat($this->get(4)); + $this->data["pitch"] = Utils::readFloat($this->get(4)); + }else{ + $this->raw .= Utils::writeInt($this->data["eid"]); + $this->raw .= Utils::writeFloat($this->data["yaw"]); + $this->raw .= Utils::writeFloat($this->data["pitch"]); + } + break; case MC_MOVE_PLAYER: if($this->c === false){ $this->data["eid"] = Utils::readInt($this->get(4)); $this->data["x"] = Utils::readFloat($this->get(4)); $this->data["y"] = Utils::readFloat($this->get(4)); $this->data["z"] = Utils::readFloat($this->get(4)); - $this->data["yaw"] = Utils::readFloat($this->get(4)); + $this->data["bodyYaw"] = Utils::readFloat($this->get(4)); $this->data["pitch"] = Utils::readFloat($this->get(4)); + $this->data["yaw"] = Utils::readFloat($this->get(4)); }else{ $this->raw .= Utils::writeInt($this->data["eid"]); $this->raw .= Utils::writeFloat($this->data["x"]); $this->raw .= Utils::writeFloat($this->data["y"]); $this->raw .= Utils::writeFloat($this->data["z"]); - $this->raw .= Utils::writeFloat($this->data["yaw"]); + $this->raw .= Utils::writeFloat($this->data["bodyYaw"]); $this->raw .= Utils::writeFloat($this->data["pitch"]); + $this->raw .= Utils::writeFloat($this->data["yaw"]); } break; case MC_PLACE_BLOCK: diff --git a/src/network/ProtocolInfo.php b/src/network/ProtocolInfo.php index e21adde58..a0c2eb187 100644 --- a/src/network/ProtocolInfo.php +++ b/src/network/ProtocolInfo.php @@ -23,7 +23,7 @@ define("DEFLATEPACKET_LEVEL", 1); define("CURRENT_STRUCTURE", 5); -define("CURRENT_PROTOCOL", 12); +define("CURRENT_PROTOCOL", 13); define("RAKNET_MAGIC", "\x00\xff\xff\x00\xfe\xfe\xfe\xfe\xfd\xfd\xfd\xfd\x12\x34\x56\x78"); @@ -41,6 +41,7 @@ define("MC_DISCONNECT", 0x15); define("MC_BANNED", 0x17); + define("MC_LOGIN", 0x82); define("MC_LOGIN_STATUS", 0x83); define("MC_READY", 0x84); @@ -58,130 +59,47 @@ define("MC_TAKE_ITEM_ENTITY", 0x8f); define("MC_MOVE_ENTITY", 0x90); define("MC_MOVE_ENTITY_POSROT", 0x93); -define("MC_MOVE_PLAYER", 0x94); -define("MC_PLACE_BLOCK", 0x95); -define("MC_REMOVE_BLOCK", 0x96); -define("MC_UPDATE_BLOCK", 0x97); -define("MC_ADD_PAINTING", 0x98); -define("MC_EXPLOSION", 0x99); -define("MC_LEVEL_EVENT", 0x9a); -define("MC_TILE_EVENT", 0x9b); -define("MC_ENTITY_EVENT", 0x9c); -define("MC_REQUEST_CHUNK", 0x9d); -define("MC_CHUNK_DATA", 0x9e); -define("MC_PLAYER_EQUIPMENT", 0x9f); -define("MC_PLAYER_ARMOR_EQUIPMENT", 0xa0); -define("MC_INTERACT", 0xa1); -define("MC_USE_ITEM", 0xa2); -define("MC_PLAYER_ACTION", 0xa3); +define("MC_ROTATE_HEAD", 0x94); +define("MC_MOVE_PLAYER", 0x95); +define("MC_PLACE_BLOCK", 0x96); +define("MC_REMOVE_BLOCK", 0x97); +define("MC_UPDATE_BLOCK", 0x98); +define("MC_ADD_PAINTING", 0x99); +define("MC_EXPLOSION", 0x9a); +define("MC_LEVEL_EVENT", 0x9b); +define("MC_TILE_EVENT", 0x9c); +define("MC_ENTITY_EVENT", 0x9d); +define("MC_REQUEST_CHUNK", 0x9e); +define("MC_CHUNK_DATA", 0x9f); +define("MC_PLAYER_EQUIPMENT", 0xa0); +define("MC_PLAYER_ARMOR_EQUIPMENT", 0xa1); +define("MC_INTERACT", 0xa2); +define("MC_USE_ITEM", 0xa3); +define("MC_PLAYER_ACTION", 0xa4); -define("MC_HURT_ARMOR", 0xa5); -define("MC_SET_ENTITY_DATA", 0xa6); -define("MC_SET_ENTITY_MOTION", 0xa7); -//define("MC_SET_RIDING_PACKET", 0xa8); -define("MC_SET_HEALTH", 0xa9); -define("MC_SET_SPAWN_POSITION", 0xaa); -define("MC_ANIMATE", 0xab); -define("MC_RESPAWN", 0xac); -define("MC_SEND_INVENTORY", 0xad); -define("MC_DROP_ITEM", 0xae); -define("MC_CONTAINER_OPEN", 0xaf); -define("MC_CONTAINER_CLOSE", 0xb0); -define("MC_CONTAINER_SET_SLOT", 0xb1); -define("MC_CONTAINER_SET_DATA", 0xb2); -define("MC_CONTAINER_SET_CONTENT", 0xb3); -//define("MC_CONTAINER_ACK", 0xb4); -define("MC_CLIENT_MESSAGE", 0xb5); -define("MC_ADVENTURE_SETTINGS", 0xb6); -define("MC_ENTITY_DATA", 0xb7); +define("MC_HURT_ARMOR", 0xa6); +define("MC_SET_ENTITY_DATA", 0xa7); +define("MC_SET_ENTITY_MOTION", 0xa8); +//define("MC_SET_ENTITY_LINK", 0xa9); +define("MC_SET_HEALTH", 0xaa); +define("MC_SET_SPAWN_POSITION", 0xab); +define("MC_ANIMATE", 0xac); +define("MC_RESPAWN", 0xad); +define("MC_SEND_INVENTORY", 0xae); +define("MC_DROP_ITEM", 0xaf); +define("MC_CONTAINER_OPEN", 0xb0); +define("MC_CONTAINER_CLOSE", 0xb1); +define("MC_CONTAINER_SET_SLOT", 0xb2); +define("MC_CONTAINER_SET_DATA", 0xb3); +define("MC_CONTAINER_SET_CONTENT", 0xb4); +//define("MC_CONTAINER_ACK", 0xb5); +define("MC_CLIENT_MESSAGE", 0xb6); +define("MC_ADVENTURE_SETTINGS", 0xb7); +define("MC_ENTITY_DATA", 0xb8); +//define("MC_PLAYER_INPUT", 0xb9); -class Protocol{ - public static $dataName = array( - MC_PING => "Ping", - - MC_CLIENT_CONNECT => "Client Connect", - MC_SERVER_HANDSHAKE => "Server Handshake", - - MC_CLIENT_HANDSHAKE => "Client Handshake", - - //MC_SERVER_FULL => "Server Full", - MC_DISCONNECT => "Disconnect", - - 0x18 => "Unknown", - - MC_LOGIN => "Login", - MC_LOGIN_STATUS => "Login Status", - MC_READY => "Ready", - MC_CHAT => "Chat", - MC_SET_TIME => "Set Time", - MC_START_GAME => "Start Game", - - MC_ADD_MOB => "Add Mob", - MC_ADD_PLAYER => "Add Player", - - MC_ADD_ENTITY => "Add Entity", - MC_REMOVE_ENTITY => "Remove Entity", - MC_ADD_ITEM_ENTITY => "Add Item", - MC_TAKE_ITEM_ENTITY => "Take Item", - - MC_MOVE_ENTITY => "Move Entity", - - MC_MOVE_ENTITY_POSROT => "Move Entity PosRot", - MC_MOVE_PLAYER => "Move Player", - MC_PLACE_BLOCK => "Place Block", - MC_REMOVE_BLOCK => "Remove Block", - MC_UPDATE_BLOCK => "Update Block", - MC_ADD_PAINTING => "Add Painting", - MC_EXPLOSION => "Explosion", - - MC_LEVEL_EVENT => "Level Event", - - MC_ENTITY_EVENT => "Entity Event", - MC_REQUEST_CHUNK => "Chunk Request", - MC_CHUNK_DATA => "Chunk Data", - - MC_PLAYER_EQUIPMENT => "Player Equipment", - MC_PLAYER_ARMOR_EQUIPMENT => "Player Armor", - MC_INTERACT => "Interact", - MC_USE_ITEM => "Use Item", - MC_PLAYER_ACTION => "Player Action", - MC_SET_ENTITY_DATA => "Entity Data", - MC_SET_ENTITY_MOTION => "Entity Motion", - MC_HURT_ARMOR => "Hurt Armor", - MC_SET_HEALTH => "Set Health", - MC_SET_SPAWN_POSITION => "Set Spawn Position", - MC_ANIMATE => "Animate", - MC_RESPAWN => "Respawn", - MC_SEND_INVENTORY => "Send Inventory", - MC_DROP_ITEM => "Drop Item", - MC_CONTAINER_OPEN => "Open Container", - MC_CONTAINER_CLOSE => "Close Container", - MC_CONTAINER_SET_SLOT => "Set Container Slot", - - MC_CLIENT_MESSAGE => "Client Message", - MC_ADVENTURE_SETTINGS => "Adventure Settings", - MC_ENTITY_DATA => "Entity Data", - ); - - public static $packetName = array( - 0x01 => "ID_CONNECTED_PING_OPEN_CONNECTIONS", //RakNet - 0x02 => "ID_UNCONNECTED_PING_OPEN_CONNECTIONS", //RakNet - 0x05 => "ID_OPEN_CONNECTION_REQUEST_1", //RakNet - 0x06 => "ID_OPEN_CONNECTION_REPLY_1", //RakNet - 0x07 => "ID_OPEN_CONNECTION_REQUEST_2", //RakNet - 0x08 => "ID_OPEN_CONNECTION_REPLY_2", //RakNet - 0x1a => "ID_INCOMPATIBLE_PROTOCOL_VERSION", //RakNet - 0x1c => "ID_UNCONNECTED_PONG", //RakNet - 0x1d => "ID_ADVERTISE_SYSTEM", //RakNet - 0x80 => "Custom Packet", //Minecraft Implementation - 0x84 => "Custom Packet", //Minecraft Implementation - 0x88 => "Custom Packet", //Minecraft Implementation - 0x8c => "Custom Packet", //Minecraft Implementation - 0xa0 => "NACK", //Minecraft Implementation - 0xc0 => "ACK", //Minecraft Implementation - ); - +class Protocol{ public static $raknet = array( 0x01 => array( "long", //Ping ID diff --git a/src/world/Entity.php b/src/world/Entity.php index b61328e78..d94b19ed9 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -802,7 +802,7 @@ class Entity extends Position{ } public function setPosition(Vector3 $pos, $yaw = false, $pitch = false){ - if($pos instanceof Position){ + if($pos instanceof Position and $this->level !== $pos->level){ $this->level = $pos->level; $this->server->preparedSQL->entity->setLevel->reset(); $this->server->preparedSQL->entity->setLevel->clear(); From e4221b8552e3295ed89460ea2282394c3be14c66 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 13:56:47 +0100 Subject: [PATCH 12/26] Redstone Ore drops Redstone dust --- src/material/block/ore/GlowingRedstoneOre.php | 2 +- src/material/block/ore/RedstoneOre.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/material/block/ore/GlowingRedstoneOre.php b/src/material/block/ore/GlowingRedstoneOre.php index 5089e3f6f..3086c7c46 100644 --- a/src/material/block/ore/GlowingRedstoneOre.php +++ b/src/material/block/ore/GlowingRedstoneOre.php @@ -53,7 +53,7 @@ class GlowingRedstoneOreBlock extends SolidBlock{ public function getDrops(Item $item, Player $player){ if($item->isPickaxe() >= 4){ return array( - //array(331, 4, mt_rand(4, 5)), + array(331, 4, mt_rand(4, 5)), ); }else{ return array(); diff --git a/src/material/block/ore/RedstoneOre.php b/src/material/block/ore/RedstoneOre.php index ddcf135d6..9deb05e7d 100644 --- a/src/material/block/ore/RedstoneOre.php +++ b/src/material/block/ore/RedstoneOre.php @@ -37,7 +37,7 @@ class RedstoneOreBlock extends SolidBlock{ public function getDrops(Item $item, Player $player){ if($item->isPickaxe() >= 2){ return array( - //array(331, 4, mt_rand(4, 5)), + array(331, 4, mt_rand(4, 5)), ); }else{ return array(); From 1a0bccf288ac8055e296f30b2183deeb9d432564 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 15:21:48 +0100 Subject: [PATCH 13/26] Sideway logs placement & correct drop --- src/material/block/solid/Wood.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/material/block/solid/Wood.php b/src/material/block/solid/Wood.php index 1edd77254..40a71f019 100644 --- a/src/material/block/solid/Wood.php +++ b/src/material/block/solid/Wood.php @@ -29,11 +29,30 @@ class WoodBlock extends SolidBlock{ WoodBlock::OAK => "Oak Wood", WoodBlock::SPRUCE => "Spruce Wood", WoodBlock::BIRCH => "Birch Wood", - 3 => "", + 3 => "Jungle Wood", ); - $this->meta &= 0x03; - $this->name = $names[$this->meta]; + $this->name = $names[$this->meta & 0x03]; $this->hardness = 10; } + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $faces = array( + 0 => 0, + 1 => 0, + 2 => 0b1000, + 3 => 0b1000, + 4 => 0b0100, + 5 => 0b0100, + ); + + $this->meta = ($this->meta & 0x03) | $faces[$face]; + $this->level->setBlock($block, $this, true, false, true); + return true; + } + + public function getDrops(Item $item, Player $player){ + return array( + array($this->id, $this->meta & 0x03, 1), + ); + } } \ No newline at end of file From de98dd920bc9d2b71b6b089dfde59f887873e29c Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 15:34:32 +0100 Subject: [PATCH 14/26] Sponges added --- src/constants/BlockIDs.php | 2 +- src/material/Block.php | 1 + src/material/block/solid/Sponge.php | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/material/block/solid/Sponge.php diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 8246f4656..eab6e62e5 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -45,7 +45,7 @@ define("WOOD", 17); define("TRUNK", 17); define("LEAVES", 18); define("LEAVE", 18); - +define("SPONGE", 19); define("GLASS", 20); define("LAPIS_ORE", 21); define("LAPIS_BLOCK", 22); diff --git a/src/material/Block.php b/src/material/Block.php index 7bff673a1..2bd7b3f9b 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -40,6 +40,7 @@ abstract class Block extends Position{ COAL_ORE => "CoalOreBlock", WOOD => "WoodBlock", LEAVES => "LeavesBlock", + SPONGE => "SpongeBlock", GLASS => "GlassBlock", LAPIS_ORE => "LapisOreBlock", LAPIS_BLOCK => "LapisBlock", diff --git a/src/material/block/solid/Sponge.php b/src/material/block/solid/Sponge.php new file mode 100644 index 000000000..1a671d43f --- /dev/null +++ b/src/material/block/solid/Sponge.php @@ -0,0 +1,28 @@ +hardness = 3; + } + +} \ No newline at end of file From 5fa6c5962e0fbe825a7a549c4c30e9413b5751d5 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 15:51:09 +0100 Subject: [PATCH 15/26] Added more Wood stairs, and planks --- src/constants/BlockIDs.php | 7 ++++ src/material/Block.php | 4 +++ .../block/nonfull/stairs/BirchWoodStairs.php | 32 +++++++++++++++++++ .../block/nonfull/stairs/JungleWoodStairs.php | 32 +++++++++++++++++++ .../block/nonfull/stairs/SpruceWoodStairs.php | 32 +++++++++++++++++++ src/material/block/solid/Planks.php | 7 ++++ src/material/block/solid/Wood.php | 4 ++- src/recipes/CraftingRecipes.php | 15 +++++++-- src/recipes/FuelData.php | 3 ++ 9 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 src/material/block/nonfull/stairs/BirchWoodStairs.php create mode 100644 src/material/block/nonfull/stairs/JungleWoodStairs.php create mode 100644 src/material/block/nonfull/stairs/SpruceWoodStairs.php diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index eab6e62e5..0bac016c9 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -150,6 +150,13 @@ define("NETHER_BRICKS_STAIRS", 114); define("SANDSTONE_STAIRS", 128); +define("SPRUCE_WOOD_STAIRS", 134); +define("SPRUCE_WOODEN_STAIRS", 134); +define("BIRCH_WOOD_STAIRS", 135); +define("BIRCH_WOODEN_STAIRS", 135); +define("JUNGLE_WOOD_STAIRS", 136); +define("JUNGLE_WOODEN_STAIRS", 136); + define("QUARTZ_BLOCK", 155); define("QUARTZ_STAIRS", 156); diff --git a/src/material/Block.php b/src/material/Block.php index 2bd7b3f9b..1b4cf80e6 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -120,6 +120,10 @@ abstract class Block extends Position{ NETHER_BRICKS_STAIRS => "NetherBricksStairsBlock", SANDSTONE_STAIRS => "SandstoneStairsBlock", + + SPRUCE_WOOD_STAIRS => "SpruceWoodStairsBlock", + BIRCH_WOOD_STAIRS => "BirchWoodStairsBlock", + JUNGLE_WOOD_STAIRS => "JungleWoodStairsBlock", QUARTZ_BLOCK => "QuartzBlock", QUARTZ_STAIRS => "QuartzStairsBlock", diff --git a/src/material/block/nonfull/stairs/BirchWoodStairs.php b/src/material/block/nonfull/stairs/BirchWoodStairs.php new file mode 100644 index 000000000..8fc35f56a --- /dev/null +++ b/src/material/block/nonfull/stairs/BirchWoodStairs.php @@ -0,0 +1,32 @@ +id, 0, 1), + ); + } +} \ No newline at end of file diff --git a/src/material/block/nonfull/stairs/JungleWoodStairs.php b/src/material/block/nonfull/stairs/JungleWoodStairs.php new file mode 100644 index 000000000..868f51b43 --- /dev/null +++ b/src/material/block/nonfull/stairs/JungleWoodStairs.php @@ -0,0 +1,32 @@ +id, 0, 1), + ); + } +} \ No newline at end of file diff --git a/src/material/block/nonfull/stairs/SpruceWoodStairs.php b/src/material/block/nonfull/stairs/SpruceWoodStairs.php new file mode 100644 index 000000000..581620c92 --- /dev/null +++ b/src/material/block/nonfull/stairs/SpruceWoodStairs.php @@ -0,0 +1,32 @@ +id, 0, 1), + ); + } +} \ No newline at end of file diff --git a/src/material/block/solid/Planks.php b/src/material/block/solid/Planks.php index 4d00e8324..30a4cde61 100644 --- a/src/material/block/solid/Planks.php +++ b/src/material/block/solid/Planks.php @@ -22,6 +22,13 @@ class PlanksBlock extends SolidBlock{ public function __construct($meta = 0){ parent::__construct(PLANKS, $meta, "Wooden Planks"); + $names = array( + WoodBlock::OAK => "Oak Wooden Planks", + WoodBlock::SPRUCE => "Spruce Wooden Planks", + WoodBlock::BIRCH => "Birch Wooden Planks", + WoodBlock::JUNGLE => "Jungle Wooden Planks", + ); + $this->name = $names[$this->meta & 0x03]; $this->hardness = 15; } diff --git a/src/material/block/solid/Wood.php b/src/material/block/solid/Wood.php index 40a71f019..bedab61c9 100644 --- a/src/material/block/solid/Wood.php +++ b/src/material/block/solid/Wood.php @@ -23,13 +23,15 @@ class WoodBlock extends SolidBlock{ const OAK = 0; const SPRUCE = 1; const BIRCH = 2; + const JUNGLE = 3; + public function __construct($meta = 0){ parent::__construct(WOOD, $meta, "Wood"); $names = array( WoodBlock::OAK => "Oak Wood", WoodBlock::SPRUCE => "Spruce Wood", WoodBlock::BIRCH => "Birch Wood", - 3 => "Jungle Wood", + WoodBlock::JUNGLE => "Jungle Wood", ); $this->name = $names[$this->meta & 0x03]; $this->hardness = 10; diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index cfb03118b..62e7395a9 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -28,7 +28,10 @@ class CraftingRecipes{ "SNOWBALL:?x4=>SNOW_BLOCK:0x1", "WOODEN_PLANKS:?x2=>STICK:0x4", "COBBLESTONE:?x4=>STONECUTTER:0x1", - "WOOD:?x1=>WOODEN_PLANKS:0x4", + "WOOD:0x1=>WOODEN_PLANKS:0x4", + "WOOD:1x1=>WOODEN_PLANKS:1x4", + "WOOD:2x1=>WOODEN_PLANKS:2x4", + "WOOD:3x1=>WOODEN_PLANKS:3x4", "WOOL:0x1,DYE:0x1=>WOOL:15x1", "WOOL:0x1,DYE:1x1=>WOOL:14x1", "WOOL:0x1,DYE:2x1=>WOOL:13x1", @@ -90,8 +93,14 @@ class CraftingRecipes{ "DIAMOND:?x3,IRON_INGOT:?x6=>NETHER_REACTOR:0x1", "WOODEN_PLANKS:?x6=>TRAPDOOR:0x2", "WOODEN_PLANKS:?x6=>WOODEN_DOOR:0x1", - "WOODEN_PLANKS:?x6=>WOODEN_STAIRS:0x4", - "WOODEN_PLANKS:?x3=>SLAB:2x6", + "WOODEN_PLANKS:0x6=>WOODEN_STAIRS:0x4", + "WOODEN_PLANKS:0x3=>SLAB:2x6", + "WOODEN_PLANKS:1x6=>SPRUCE_WOOD_STAIRS:0x4", + //"WOODEN_PLANKS:1x3=>SPRUCE_WOOD_SLAB:2x6", + "WOODEN_PLANKS:2x6=>BIRCH_WOOD_STAIRS:0x4", + //"WOODEN_PLANKS:2x3=>BIRCH_WOOD_SLAB:2x6", + "WOODEN_PLANKS:3x6=>JUNGLE_WOOD_STAIRS:0x4", + //"WOODEN_PLANKS:3x3=>JUNGLE_WOOD_SLAB:2x6", //Tools "STICK:?x1,FEATHER:?x1,FLINT:?x1=>ARROW:0x4", diff --git a/src/recipes/FuelData.php b/src/recipes/FuelData.php index b158476c6..eaba877c2 100644 --- a/src/recipes/FuelData.php +++ b/src/recipes/FuelData.php @@ -35,6 +35,9 @@ class FuelData{ FENCE => 15, FENCE_GATE => 15, WOODEN_STAIRS => 15, + SPRUCE_WOOD_STAIRS => 15, + BIRCH_WOOD_STAIRS => 15, + JUNGLE_WOOD_STAIRS => 15, TRAPDOOR => 15, WORKBENCH => 15, BOOKSHELF => 15, From 1ad00a453bec2c781bab43379333ae3089cdd6be Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 16:36:30 +0100 Subject: [PATCH 16/26] Added Iron bars, Pumpkins, lit pumpkins and pumpkin grow, pumpkin growth, pumpkin seeds, pumpkin pie... --- src/Player.php | 1 + src/constants/BlockIDs.php | 9 ++- src/constants/ItemIDs.php | 4 +- src/material/Block.php | 6 +- src/material/Item.php | 1 + src/material/block/nonfull/IronBars.php | 27 +++++++ src/material/block/plant/PumpkinStem.php | 87 ++++++++++++++++++++++ src/material/block/solid/LitPumpkin.php | 28 +++++++ src/material/block/solid/Pumpkin.php | 28 +++++++ src/material/block/solid/Sponge.php | 2 +- src/material/item/generic/PumpkinSeeds.php | 27 +++++++ src/recipes/CraftingRecipes.php | 6 +- 12 files changed, 219 insertions(+), 7 deletions(-) create mode 100644 src/material/block/nonfull/IronBars.php create mode 100644 src/material/block/plant/PumpkinStem.php create mode 100644 src/material/block/solid/LitPumpkin.php create mode 100644 src/material/block/solid/Pumpkin.php create mode 100644 src/material/item/generic/PumpkinSeeds.php diff --git a/src/Player.php b/src/Player.php index b132105cf..82b6f54b7 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1721,6 +1721,7 @@ class Player{ RAW_CHICKEN => 2, MELON_SLICE => 2, GOLDEN_APPLE => 10, + PUMPKIN_PIE => 8, //COOKIE => 2, //COOKED_FISH => 5, //RAW_FISH => 2, diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 0bac016c9..19596520e 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -120,12 +120,15 @@ define("REEDS", 83); define("SUGARCANE_BLOCK", 83); define("FENCE", 85); - +define("PUMPKIN", 86); define("NETHERRACK", 87); define("SOUL_SAND", 88); define("GLOWSTONE", 89); define("GLOWSTONE_BLOCK", 89); + +define("LIT_PUMPKIN", 91); +define("JACK_O_LANTERN", 91); define("CAKE_BLOCK", 92); define("TRAPDOOR", 96); @@ -133,10 +136,12 @@ define("TRAPDOOR", 96); define("STONE_BRICKS", 98); define("STONE_BRICK", 98); +define("IRON_BAR", 101); +define("IRON_BARS", 101); define("GLASS_PANE", 102); define("GLASS_PANEL", 102); define("MELON_BLOCK", 103); - +define("PUMPKIN_STEM", 104); define("MELON_STEM", 105); define("FENCE_GATE", 107); diff --git a/src/constants/ItemIDs.php b/src/constants/ItemIDs.php index 276e8a4ee..372719f78 100644 --- a/src/constants/ItemIDs.php +++ b/src/constants/ItemIDs.php @@ -132,7 +132,7 @@ define("BED", 355); define("SHEARS", 359); define("MELON", 360); define("MELON_SLICE", 360); - +define("PUMPKIN_SEEDS", 361); define("MELON_SEEDS", 362); define("RAW_BEEF", 363); define("STEAK", 364); @@ -143,6 +143,8 @@ define("COOKED_CHICKEN", 366); define("SPAWN_EGG", 383); +define("PUMPKIN_PIE", 400); + define("NETHER_BRICK", 405); define("QUARTZ", 406); define("NETHER_QUARTZ", 406); diff --git a/src/material/Block.php b/src/material/Block.php index 1b4cf80e6..b340856fb 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -95,20 +95,22 @@ abstract class Block extends Position{ SUGARCANE_BLOCK => "SugarcaneBlock", FENCE => "FenceBlock", - + PUMPKIN => "PumpkinBlock", NETHERRACK => "NetherrackBlock", SOUL_SAND => "SoulSandBlock", GLOWSTONE_BLOCK => "GlowstoneBlock", + LIT_PUMPKIN => "LitPumpkinBlock", CAKE_BLOCK => "CakeBlock", TRAPDOOR => "TrapdoorBlock", STONE_BRICKS => "StoneBricksBlock", + IRON_BARS => "IronBarsBlock", GLASS_PANE => "GlassPaneBlock", MELON_BLOCK => "MelonBlock", - + PUMPKIN_STEM => "PumpkinStemBlock", MELON_STEM => "MelonStemBlock", FENCE_GATE => "FenceGateBlock", diff --git a/src/material/Item.php b/src/material/Item.php index f7e11089c..f09480f5e 100644 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -23,6 +23,7 @@ class Item{ public static $class = array( SUGARCANE => "SugarcaneItem", WHEAT_SEEDS => "WheatSeedsItem", + PUMPKIN_SEEDS => "PumpkinSeedsItem", MELON_SEEDS => "MelonSeedsItem", SIGN => "SignItem", WOODEN_DOOR => "WoodenDoorItem", diff --git a/src/material/block/nonfull/IronBars.php b/src/material/block/nonfull/IronBars.php new file mode 100644 index 000000000..11136b2d4 --- /dev/null +++ b/src/material/block/nonfull/IronBars.php @@ -0,0 +1,27 @@ +isActivable = true; + $this->hardness = 0; + } + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $down = $this->getSide(0); + if($down->getID() === FARMLAND){ + $this->level->setBlock($block, $this, true, false, true); + $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); + return true; + } + return false; + } + + public function onUpdate($type){ + if($type === BLOCK_UPDATE_NORMAL){ + if($this->getSide(0)->isTransparent === true){ //Replace with common break method + ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(PUMPKIN_SEEDS, 0, mt_rand(0, 2))); + $this->level->setBlock($this, new AirBlock(), false, false, true); + return BLOCK_UPDATE_NORMAL; + } + }elseif($type === BLOCK_UPDATE_RANDOM){ + if(mt_rand(0, 2) == 1){ + if($this->meta < 0x07){ + ++$this->meta; + $this->level->setBlock($this, $this, true, false, true); + return BLOCK_UPDATE_RANDOM; + }else{ + for($side = 2; $side <= 5; ++$side){ + $b = $this->getSide($side); + if($b->getID() === PUMPKIN){ + return BLOCK_UPDATE_RANDOM; + } + } + $side = $this->getSide(mt_rand(2,5)); + $d = $side->getSide(0); + if($side->getID() === AIR and ($d->getID() === FARMLAND or $d->getID() === GRASS or $d->getID() === DIRT)){ + $this->level->setBlock($side, new PumpkinBlock(), true, false, true); + } + } + } + return BLOCK_UPDATE_RANDOM; + } + return false; + } + + public function onActivate(Item $item, Player $player){ + if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal + $this->meta = 0x07; + $this->level->setBlock($this, $this, true, false, true); + if(($player->gamemode & 0x01) === 0){ + $item->count--; + } + return true; + } + return false; + } + + public function getDrops(Item $item, Player $player){ + return array( + array(PUMPKIN_SEEDS, 0, mt_rand(0, 2)), + ); + } +} \ No newline at end of file diff --git a/src/material/block/solid/LitPumpkin.php b/src/material/block/solid/LitPumpkin.php new file mode 100644 index 000000000..cebe24968 --- /dev/null +++ b/src/material/block/solid/LitPumpkin.php @@ -0,0 +1,28 @@ +hardness = 5; + } + +} \ No newline at end of file diff --git a/src/material/block/solid/Pumpkin.php b/src/material/block/solid/Pumpkin.php new file mode 100644 index 000000000..e69e96df8 --- /dev/null +++ b/src/material/block/solid/Pumpkin.php @@ -0,0 +1,28 @@ +hardness = 5; + } + +} \ No newline at end of file diff --git a/src/material/block/solid/Sponge.php b/src/material/block/solid/Sponge.php index 1a671d43f..9c3cdba4e 100644 --- a/src/material/block/solid/Sponge.php +++ b/src/material/block/solid/Sponge.php @@ -21,7 +21,7 @@ class SpongeBlock extends SolidBlock{ public function __construct(){ - parent::__construct(SPONGE, $meta, "Sponge"); + parent::__construct(SPONGE, "Sponge"); $this->hardness = 3; } diff --git a/src/material/item/generic/PumpkinSeeds.php b/src/material/item/generic/PumpkinSeeds.php new file mode 100644 index 000000000..b615bb5dd --- /dev/null +++ b/src/material/item/generic/PumpkinSeeds.php @@ -0,0 +1,27 @@ +block = BlockAPI::get(PUMPKIN_STEM); + parent::__construct(PUMPKIN_SEEDS, 0, $count, "Pumpkin Seeds"); + } +} \ No newline at end of file diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index 62e7395a9..df1967e90 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -25,6 +25,7 @@ class CraftingRecipes{ "CLAY:?x4=>CLAY_BLOCK:0x1", "WOODEN_PLANKS:?x4=>WORKBENCH:0x1", "GLOWSTONE_DUST:?x4=>GLOWSTONE_BLOCK:0x1", + "PUMPKIN:?x1,TORCH:?x1=>LIT_PUMPKIN:0x1", "SNOWBALL:?x4=>SNOW_BLOCK:0x1", "WOODEN_PLANKS:?x2=>STICK:0x4", "COBBLESTONE:?x4=>STONECUTTER:0x1", @@ -55,7 +56,10 @@ class CraftingRecipes{ "COAL:0x1,STICK:?x1=>TORCH:0x4", "COAL:1x1,STICK:?x1=>TORCH:0x4", - //Food & protection + //Food & protection + "MELON_SLICE:?x1=>MELON_SEEDS:0x1", + "PUMPKIN:?x1=>PUMPKIN_SEEDS:0x4", + "PUMPKIN:?x1,EGG:?x1,SUGAR:?x1=>PUMPKIN_PIE:0x1", "BROWN_MUSHROOM:?x1,RED_MUSHROOM:?x1,BOWL:?x1=>MUSHROOM_STEW:0x1", "SUGARCANE:?x1=>SUGAR:0x1", "MELON_SLICE:?x1=>MELON_SEEDS:0x1", From af66e5a444f8e1fe53f036a7261c3e3475c00699 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 17:23:03 +0100 Subject: [PATCH 17/26] iron bars crafting --- src/recipes/CraftingRecipes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index df1967e90..03a35a8d6 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -171,6 +171,7 @@ class CraftingRecipes{ "WOOL:?x1,STICK:?x8=>PAINTING:0x1", "SUGARCANE:?x3=>PAPER:0x1", "WOODEN_PLANKS:?x6,STICK:?x1=>SIGN:0x1", + "IRON_INGOT:?x6=>IRON_BARS:0x16", ); private static $stone = array( From a0ca572d1f524e2f47e12a770c6a51612d8d3e11 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 17:40:22 +0100 Subject: [PATCH 18/26] Added Cobblestone Walls, Mossy Stone Walls, crafting recipes, correct drops --- src/constants/BlockIDs.php | 4 +++ src/material/Block.php | 1 + src/material/block/nonfull/StoneWall.php | 33 ++++++++++++++++++++++++ src/recipes/CraftingRecipes.php | 2 ++ 4 files changed, 40 insertions(+) create mode 100644 src/material/block/nonfull/StoneWall.php diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 19596520e..018532c7e 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -162,6 +162,10 @@ define("BIRCH_WOODEN_STAIRS", 135); define("JUNGLE_WOOD_STAIRS", 136); define("JUNGLE_WOODEN_STAIRS", 136); +define("COBBLE_WALL", 139); +define("STONE_WALL", 139); +define("COBBLESTONE_WALL", 139); + define("QUARTZ_BLOCK", 155); define("QUARTZ_STAIRS", 156); diff --git a/src/material/Block.php b/src/material/Block.php index b340856fb..74b8bdc87 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -126,6 +126,7 @@ abstract class Block extends Position{ SPRUCE_WOOD_STAIRS => "SpruceWoodStairsBlock", BIRCH_WOOD_STAIRS => "BirchWoodStairsBlock", JUNGLE_WOOD_STAIRS => "JungleWoodStairsBlock", + STONE_WALL => "StoneWallBlock", QUARTZ_BLOCK => "QuartzBlock", QUARTZ_STAIRS => "QuartzStairsBlock", diff --git a/src/material/block/nonfull/StoneWall.php b/src/material/block/nonfull/StoneWall.php new file mode 100644 index 000000000..6f7117814 --- /dev/null +++ b/src/material/block/nonfull/StoneWall.php @@ -0,0 +1,33 @@ +name = "Mossy Cobblestone Wall"; + } + $this->isFullBlock = false; + $this->hardness = 30; + } + +} \ No newline at end of file diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index 03a35a8d6..8f6e1ea0d 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -181,6 +181,8 @@ class CraftingRecipes{ "BRICKS_BLOCK:?x3=>SLAB:4x6", "SLAB:6x2=>QUARTZ_BLOCK:1x1", "COBBLESTONE:?x3=>SLAB:3x6", + "COBBLESTONE:0x6=>STONE_WALL:0x6", + "MOSSY_STONE:0x6=>STONE_WALL:1x6", "NETHER_BRICK:?x4=>NETHER_BRICKS:0x1", "NETHER_BRICKS:?x6=>NETHER_BRICKS_STAIRS:0x4", "QUARTZ_BLOCK:0x2=>QUARTZ_BLOCK:2x2", From 78f9e407308df4d8d7cacdb8c181eda566b7e302 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 17:54:19 +0100 Subject: [PATCH 19/26] Added Compass and Clock --- src/constants/ItemIDs.php | 3 ++- src/material/block/ore/GlowingRedstoneOre.php | 2 +- src/material/block/ore/RedstoneOre.php | 2 +- src/recipes/CraftingRecipes.php | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/constants/ItemIDs.php b/src/constants/ItemIDs.php index 372719f78..e9f7f3abb 100644 --- a/src/constants/ItemIDs.php +++ b/src/constants/ItemIDs.php @@ -100,7 +100,7 @@ define("BUCKET", 325); define("IRON_DOOR", 330); - +define("REDSTONE_DUST", 331); define("SNOWBALL", 332); define("LEATHER", 334); @@ -116,6 +116,7 @@ define("SLIMEBALL", 341); define("EGG", 344); define("COMPASS", 345); +define("CLOCK", 347); define("GLOWSTONE_DUST", 348); //define("RAW_FISH", 349); //define("COOKED_FISH", 350); diff --git a/src/material/block/ore/GlowingRedstoneOre.php b/src/material/block/ore/GlowingRedstoneOre.php index 3086c7c46..37d0cab94 100644 --- a/src/material/block/ore/GlowingRedstoneOre.php +++ b/src/material/block/ore/GlowingRedstoneOre.php @@ -53,7 +53,7 @@ class GlowingRedstoneOreBlock extends SolidBlock{ public function getDrops(Item $item, Player $player){ if($item->isPickaxe() >= 4){ return array( - array(331, 4, mt_rand(4, 5)), + array(REDSTONE_DUST, 0, mt_rand(4, 5)), ); }else{ return array(); diff --git a/src/material/block/ore/RedstoneOre.php b/src/material/block/ore/RedstoneOre.php index 9deb05e7d..67e058e85 100644 --- a/src/material/block/ore/RedstoneOre.php +++ b/src/material/block/ore/RedstoneOre.php @@ -37,7 +37,7 @@ class RedstoneOreBlock extends SolidBlock{ public function getDrops(Item $item, Player $player){ if($item->isPickaxe() >= 2){ return array( - array(331, 4, mt_rand(4, 5)), + array(REDSTONE_DUST, 0, mt_rand(4, 5)), ); }else{ return array(); diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index 8f6e1ea0d..a3c4a2cee 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -110,6 +110,8 @@ class CraftingRecipes{ "STICK:?x1,FEATHER:?x1,FLINT:?x1=>ARROW:0x4", "STICK:?x3,STRING:?x3=>BOW:0x1", "IRON_INGOT:?x3=>BUCKET:0x1", + "GOLD_INGOT:?x4,REDSTONE_DUST:?x1=>CLOCK:0x1", + "IRON_INGOT:?x4,REDSTONE_DUST:?x1=>COMPASS:0x1", "DIAMOND:?x3,STICK:?x2=>DIAMOND_AXE:0x1", "DIAMOND:?x2,STICK:?x2=>DIAMOND_HOE:0x1", "DIAMOND:?x3,STICK:?x2=>DIAMOND_PICKAXE:0x1", From 78f7964d57dc6e3a919e47fa0115ef60189a2997 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 18:09:04 +0100 Subject: [PATCH 20/26] Fixed bread crafting & added Hay Bales --- src/constants/BlockIDs.php | 2 ++ src/material/Block.php | 2 ++ src/material/block/solid/HayBale.php | 28 ++++++++++++++++++++++++++++ src/recipes/CraftingRecipes.php | 4 +++- 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/material/block/solid/HayBale.php diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 018532c7e..24fac5209 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -169,6 +169,8 @@ define("COBBLESTONE_WALL", 139); define("QUARTZ_BLOCK", 155); define("QUARTZ_STAIRS", 156); +define("HAY_BALE", 170); + define("STONECUTTER", 245); define("GLOWING_OBSIDIAN", 246); define("NETHER_REACTOR", 247); diff --git a/src/material/Block.php b/src/material/Block.php index 74b8bdc87..e14676310 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -130,6 +130,8 @@ abstract class Block extends Position{ QUARTZ_BLOCK => "QuartzBlock", QUARTZ_STAIRS => "QuartzStairsBlock", + + HAY_BALE => "HayBaleBlock", STONECUTTER => "StonecutterBlock", GLOWING_OBSIDIAN => "GlowingObsidianBlock", diff --git a/src/material/block/solid/HayBale.php b/src/material/block/solid/HayBale.php new file mode 100644 index 000000000..472060301 --- /dev/null +++ b/src/material/block/solid/HayBale.php @@ -0,0 +1,28 @@ +hardness = 10; + } + +} \ No newline at end of file diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index a3c4a2cee..a0de438e1 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -63,6 +63,7 @@ class CraftingRecipes{ "BROWN_MUSHROOM:?x1,RED_MUSHROOM:?x1,BOWL:?x1=>MUSHROOM_STEW:0x1", "SUGARCANE:?x1=>SUGAR:0x1", "MELON_SLICE:?x1=>MELON_SEEDS:0x1", + "HAY_BALE:?x1=>WHEATH:0x9", //Items "DIAMOND_BLOCK:?x1=>DIAMOND:0x9", @@ -140,7 +141,7 @@ class CraftingRecipes{ "WOODEN_PLANKS:?x2,STICK:?x1=>WOODEN_SWORD:0x1", //Food & protection - "WHEAT:?x3=>BREAD:0x1", + "WHEATH:?x3=>BREAD:0x1", "WHEATH:?x3,BUCKET:1x3,EGG:?x1,SUGAR:?x2=>CAKE:0x1", "DIAMOND:?x4=>DIAMOND_BOOTS:0x1", "DIAMOND:?x8=>DIAMOND_CHESTPLATE:0x1", @@ -167,6 +168,7 @@ class CraftingRecipes{ "DIAMOND:?x9=>DIAMOND_BLOCK:0x1", "GOLD_INGOT:?x9=>GOLD_BLOCK:0x1", "IRON_INGOT:?x9=>IRON_BLOCK:0x1", + "WHEATH:?x9=>HAY_BALE:0x1", "PAPER:?x3=>BOOK:0x1", "WOODEN_PLANKS:?x6,BOOK:?x3=>BOOKSHELF:0x1", "DYE:4x9=>LAPIS_BLOCK:0x1", From 5803a4e64958877d82832d64952cc698c562765b Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 18:18:02 +0100 Subject: [PATCH 21/26] Added Coal Blocks, crafting, fuel information --- src/constants/BlockIDs.php | 2 ++ src/material/Block.php | 2 ++ src/material/block/solid/Coal.php | 57 +++++++++++++++++++++++++++++++ src/recipes/CraftingRecipes.php | 2 ++ src/recipes/FuelData.php | 1 + 5 files changed, 64 insertions(+) create mode 100644 src/material/block/solid/Coal.php diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 24fac5209..321084154 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -171,6 +171,8 @@ define("QUARTZ_STAIRS", 156); define("HAY_BALE", 170); +define("COAL_BLOCK", 170); + define("STONECUTTER", 245); define("GLOWING_OBSIDIAN", 246); define("NETHER_REACTOR", 247); diff --git a/src/material/Block.php b/src/material/Block.php index e14676310..957ab3eb5 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -132,6 +132,8 @@ abstract class Block extends Position{ QUARTZ_STAIRS => "QuartzStairsBlock", HAY_BALE => "HayBaleBlock", + + COAL_BLOCK => "CoalBlock", STONECUTTER => "StonecutterBlock", GLOWING_OBSIDIAN => "GlowingObsidianBlock", diff --git a/src/material/block/solid/Coal.php b/src/material/block/solid/Coal.php new file mode 100644 index 000000000..249d8b593 --- /dev/null +++ b/src/material/block/solid/Coal.php @@ -0,0 +1,57 @@ +hardness = 30; + } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.95; + case 4: + return 1.25; + case 3: + return 1.9; + case 2: + return 0.65; + case 1: + return 3.75; + default: + return 25; + } + } + + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 1){ + return array( + array(COAL_BLOCK, 0, 1), + ); + }else{ + return array(); + } + } +} \ No newline at end of file diff --git a/src/recipes/CraftingRecipes.php b/src/recipes/CraftingRecipes.php index a0de438e1..362af2a1c 100644 --- a/src/recipes/CraftingRecipes.php +++ b/src/recipes/CraftingRecipes.php @@ -176,6 +176,8 @@ class CraftingRecipes{ "SUGARCANE:?x3=>PAPER:0x1", "WOODEN_PLANKS:?x6,STICK:?x1=>SIGN:0x1", "IRON_INGOT:?x6=>IRON_BARS:0x16", + "COAL:0x9=>COAL_BLOCK:0x1", + "COAL_BLOCK:?x1=>COAL:0x9", ); private static $stone = array( diff --git a/src/recipes/FuelData.php b/src/recipes/FuelData.php index eaba877c2..c7778d24b 100644 --- a/src/recipes/FuelData.php +++ b/src/recipes/FuelData.php @@ -23,6 +23,7 @@ class FuelData{ public static $duration = array( COAL => 80, + COAL_BLOCK => 800, TRUNK => 15, WOODEN_PLANKS => 15, SAPLING => 5, From ae8c934b5fb7b5b95d922bc582b43ff9d6d2f00a Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Nov 2013 19:14:45 +0100 Subject: [PATCH 22/26] Allow accessing Config data keys directly --- src/utils/Config.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/utils/Config.php b/src/utils/Config.php index 31babceb8..9291e2789 100644 --- a/src/utils/Config.php +++ b/src/utils/Config.php @@ -150,6 +150,22 @@ class Config{ } } + public function __get($k){ + return $this->get($k); + } + + public function __set($k, $v){ + return $this->set($k, $v); + } + + public function __isset($k){ + return $this->exists($k); + } + + public function __unset($k){ + return $this->remove($k); + } + public function get($k){ if($this->correct === false or !isset($this->config[$k])){ return false; From 3ff4b9eae05c5d49c6597070eeb06621edb25684 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 24 Nov 2013 00:51:04 +0100 Subject: [PATCH 23/26] Achievements API --- src/API/AchievementAPI.php | 141 +++++++++++++++++++++++++++++++++++++ src/API/PlayerAPI.php | 1 + src/API/ServerAPI.php | 1 + src/Player.php | 39 ++++++++-- src/utils/Config.php | 6 +- 5 files changed, 180 insertions(+), 8 deletions(-) create mode 100644 src/API/AchievementAPI.php diff --git a/src/API/AchievementAPI.php b/src/API/AchievementAPI.php new file mode 100644 index 000000000..8052f5b13 --- /dev/null +++ b/src/API/AchievementAPI.php @@ -0,0 +1,141 @@ + array( + "name" => "Taking Inventory", + "requires" => array(), + ),*/ + "mineWood" => array( + "name" => "Getting Wood", + "requires" => array( + //"openInventory", + ), + ), + "buildWorkBench" => array( + "name" => "Benchmarking", + "requires" => array( + "mineWood", + ), + ), + "buildPickaxe" => array( + "name" => "Time to Mine!", + "requires" => array( + "buildWorkBench", + ), + ), + "buildFurnace" => array( + "name" => "Hot Topic", + "requires" => array( + "buildPickaxe", + ), + ), + "acquireIron" => array( + "name" => "Acquire hardware", + "requires" => array( + "buildFurnace", + ), + ), + "buildHoe" => array( + "name" => "Time to Farm!", + "requires" => array( + "buildWorkBench", + ), + ), + "makeBread" => array( + "name" => "Bake Bread", + "requires" => array( + "buildHoe", + ), + ), + "bakeCake" => array( + "name" => "The Lie", + "requires" => array( + "buildHoe", + ), + ), + "buildBetterPickaxe" => array( + "name" => "Getting an Upgrade", + "requires" => array( + "buildWorkBench", + ), + ), + + ); + + function __construct(){ + } + + public static function broadcastAchievement(Player $player, $achievementId){ + if(ServerAPI::request()->api->getProperty("announce-player-achievements") == true){ + ServerAPI::request()->api->chat->broadcast($player->username." has just earned the achievement ".self::$achievements[$achievementId]["name"]); + }else{ + $player->sendChat("You have just earned the achievement ".self::$achievements[$achievementId]["name"]); + } + } + + public static function addAchievement($achievementId, $achievementName, array $requires = array()){ + if(!isset(self::$achievements[$achievementId])){ + self::$achievements[$achievementId] = array( + "name" => $achievementName, + "requires" => $requires, + ); + return true; + } + return false; + } + + public static function hasAchievement(Player $player, $achievementId){ + if(!isset(self::$achievements[$achievementId]) or !isset($player->achievements)){ + $player->achievements = array(); + return false; + } + + if(!isset($player->achievements[$achievementId]) or $player->achievements[$achievementId] == false){ + return false; + } + return true; + } + + public static function grantAchievement(Player $player, $achievementId){ + if(isset(self::$achievements[$achievementId]) and !self::hasAchievement($player, $achievementId)){ + foreach(self::$achievements[$achievementId]["requires"] as $requerimentId){ + if(!self::hasAchievement($player, $requerimentId)){ + return false; + } + } + $player->achievements[$achievementId] = true; + self::broadcastAchievement($player, $achievementId); + return true; + } + return false; + } + + public static function removeAchievement(Player $player, $achievementId){ + if(self::hasAchievement($player, $achievementId)){ + $player->achievements[$achievementId] = false; + } + } + + public function init(){ + } +} diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index e3d80dacd..a18f08160 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -449,6 +449,7 @@ class PlayerAPI{ "health" => 20, "lastIP" => "", "lastID" => 0, + "achievements" => array(), ); if(!file_exists(DATA_PATH."players/".$iname.".yml")){ diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 5c4de5012..809d7952c 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -61,6 +61,7 @@ class ServerAPI{ "memory-limit" => "128M", "last-update" => false, "white-list" => false, + "announce-player-achievements" => true, "spawn-protection" => 16, "view-distance" => 10, "max-players" => 20, diff --git a/src/Player.php b/src/Player.php index 82b6f54b7..1bc43a455 100644 --- a/src/Player.php +++ b/src/Player.php @@ -58,6 +58,7 @@ class Player{ public $windowCnt = 2; public $windows = array(); public $blocked = true; + public $achievements = array(); public $chunksLoaded = array(); private $chunksOrder = array(); private $lastMeasure = 0; @@ -78,9 +79,9 @@ class Player{ private $received = array(); public $realmsData = array(); - public function __get($name){ + public function &__get($name){ if(isset($this->{$name})){ - return ($this->{$name}); + return $this->{$name}; } return null; } @@ -216,6 +217,7 @@ class Player{ public function save(){ if($this->entity instanceof Entity){ + $this->data->set("achievements", $this->achievements); $this->data->set("position", array( "level" => $this->entity->level->getName(), "x" => $this->entity->x, @@ -534,6 +536,11 @@ class Player{ if(($this->gamemode & 0x01) === 0x00){ $this->addItem($data["entity"]->type, $data["entity"]->meta, $data["entity"]->stack, false); } + switch($data["entity"]->type){ + case WOOD: + AchievementAPI::grantAchievement($this, "mineWood"); + break; + } }elseif($data["entity"]->level === $this->level){ $this->dataPacket(MC_TAKE_ITEM_ENTITY, $data); } @@ -740,6 +747,19 @@ class Player{ }else{ $this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $s->count + $item->count), false); } + + switch($item->getID()){ + case WORKBENCH: + AchievementAPI::grantAchievement($this, "buildWorkBench"); + break; + case WOODEN_PICKAXE: + AchievementAPI::grantAchievement($this, "buildPickaxe"); + break; + case FURNACE: + AchievementAPI::grantAchievement($this, "buildFurnace"); + break; + + } } } return $res; @@ -1200,6 +1220,7 @@ class Player{ } $this->data->set("inventory", $inv); } + $this->achievements = $this->data->get("achievements"); $this->data->set("caseusername", $this->username); $this->inventory = array(); foreach($this->data->get("inventory") as $slot => $item){ @@ -1217,9 +1238,8 @@ class Player{ $this->data->set("lastIP", $this->ip); $this->data->set("lastID", $this->clientID); - if($this->data instanceof Config){ - $this->server->api->player->saveOffline($this->data); - } + $this->server->api->player->saveOffline($this->data); + $this->dataPacket(MC_LOGIN_STATUS, array( "status" => 0, )); @@ -1940,6 +1960,15 @@ class Player{ )); break; } + + if($tile->class === TILE_FURNACE and $data["slot"] == 2){ + switch($slot->getID()){ + case IRON_INGOT: + AchievementAPI::grantAchievement($this, "acquireIron"); + break; + } + } + if($item->getID() !== AIR and $slot->getID() == $item->getID()){ if($slot->count < $item->count){ if($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false){ diff --git a/src/utils/Config.php b/src/utils/Config.php index 9291e2789..ef8ba9090 100644 --- a/src/utils/Config.php +++ b/src/utils/Config.php @@ -150,7 +150,7 @@ class Config{ } } - public function __get($k){ + public function &__get($k){ return $this->get($k); } @@ -166,11 +166,11 @@ class Config{ return $this->remove($k); } - public function get($k){ + public function &get($k){ if($this->correct === false or !isset($this->config[$k])){ return false; } - return ($this->config[$k]); + return $this->config[$k]; } public function set($k, $v = true){ From 6de602a1741e6d8200d44b86dfbce1314047c4e6 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 24 Nov 2013 00:52:21 +0100 Subject: [PATCH 24/26] Fixed Coal Block ID --- src/constants/BlockIDs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 321084154..32a4bf3c9 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -171,7 +171,7 @@ define("QUARTZ_STAIRS", 156); define("HAY_BALE", 170); -define("COAL_BLOCK", 170); +define("COAL_BLOCK", 173); define("STONECUTTER", 245); define("GLOWING_OBSIDIAN", 246); From 6ff6a5fc91f88f5ae42ea4d96acf03e711273703 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 24 Nov 2013 01:10:05 +0100 Subject: [PATCH 25/26] More achievements --- src/API/AchievementAPI.php | 12 ++++++++++++ src/Player.php | 26 +++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/API/AchievementAPI.php b/src/API/AchievementAPI.php index 8052f5b13..65b6a2e7a 100644 --- a/src/API/AchievementAPI.php +++ b/src/API/AchievementAPI.php @@ -79,6 +79,18 @@ class AchievementAPI{ "buildWorkBench", ), ), + "buildSword" => array( + "name" => "Time to Strike!", + "requires" => array( + "buildWorkBench", + ), + ), + "diamonds" => array( + "name" => "DIAMONDS!", + "requires" => array( + "acquireIron", + ), + ), ); diff --git a/src/Player.php b/src/Player.php index 1bc43a455..f3d14a493 100644 --- a/src/Player.php +++ b/src/Player.php @@ -540,6 +540,9 @@ class Player{ case WOOD: AchievementAPI::grantAchievement($this, "mineWood"); break; + case DIAMOND: + AchievementAPI::grantAchievement($this, "diamond"); + break; } }elseif($data["entity"]->level === $this->level){ $this->dataPacket(MC_TAKE_ITEM_ENTITY, $data); @@ -758,6 +761,27 @@ class Player{ case FURNACE: AchievementAPI::grantAchievement($this, "buildFurnace"); break; + case WOODEN_HOE: + AchievementAPI::grantAchievement($this, "buildHoe"); + break; + case BREAD: + AchievementAPI::grantAchievement($this, "makeBread"); + break; + case CAKE: + AchievementAPI::grantAchievement($this, "bakeCake"); + break; + case STONE_PICKAXE: + case GOLD_PICKAXE: + case IRON_PICKAXE: + case DIAMOND_PICKAXE: + AchievementAPI::grantAchievement($this, "buildBetterPickaxe"); + break; + case WOODEN_SWORD: + AchievementAPI::grantAchievement($this, "buildSword"); + break; + case DIAMOND: + AchievementAPI::grantAchievement($this, "diamond"); + break; } } @@ -1960,7 +1984,7 @@ class Player{ )); break; } - + if($tile->class === TILE_FURNACE and $data["slot"] == 2){ switch($slot->getID()){ case IRON_INGOT: From 5a71043ab0d38ff5c9e241d7a7d21adc75db7025 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 24 Nov 2013 01:52:23 +0100 Subject: [PATCH 26/26] Fix --- src/Player.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Player.php b/src/Player.php index f3d14a493..d5a6a6c65 100644 --- a/src/Player.php +++ b/src/Player.php @@ -79,9 +79,9 @@ class Player{ private $received = array(); public $realmsData = array(); - public function &__get($name){ + public function __get($name){ if(isset($this->{$name})){ - return $this->{$name}; + return ($this->{$name}); } return null; }