diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 773513bd1..9978858e7 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -94,6 +94,7 @@ use pocketmine\network\Network; use pocketmine\network\protocol\AdventureSettingsPacket; use pocketmine\network\protocol\AnimatePacket; use pocketmine\network\protocol\BatchPacket; +use pocketmine\network\protocol\ContainerSetContentPacket; use pocketmine\network\protocol\DataPacket; use pocketmine\network\protocol\DisconnectPacket; use pocketmine\network\protocol\EntityEventPacket; @@ -995,6 +996,19 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); $this->sendSettings(); + if($this->gamemode === Player::SPECTATOR){ + $pk = new ContainerSetContentPacket(); + $pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE; + $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + }else{ + $pk = new ContainerSetContentPacket(); + $pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE; + foreach(Block::$creative as $item){ + $pk->slots[] = Item::get($item[0], $item[1]); //TODO: change this for plugins + } + $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + } + return true; } @@ -1592,6 +1606,19 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->setRemoveFormat(false); } + if($this->gamemode === Player::SPECTATOR){ + $pk = new ContainerSetContentPacket(); + $pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE; + $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + }else{ + $pk = new ContainerSetContentPacket(); + $pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE; + foreach(Block::$creative as $item){ + $pk->slots[] = Item::get($item[0], $item[1]); //TODO: change this for plugins + } + $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + } + $this->orderChunks(); $this->sendNextChunk(); break; @@ -1711,7 +1738,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false); - if($blockVector->distance($this) > 10){ + if($blockVector->distance($this) > 10 or ($this->isCreative() and $this->isAdventure())){ }elseif($this->isCreative()){ $item = $this->inventory->getItemInHand(); @@ -2329,7 +2356,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ } } $transaction = new BaseTransaction($this->inventory, $packet->slot, $this->inventory->getItem($packet->slot), $packet->item); - }elseif($packet->windowid === 0x78){ //Our armor + }elseif($packet->windowid === ContainerSetContentPacket::SPECIAL_ARMOR){ //Our armor if($packet->slot >= 4){ break; } @@ -2527,7 +2554,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk = new TextPacket(); $pk->type = TextPacket::TYPE_RAW; $pk->message = $m; - $pk->message .= str_repeat(" ", substr_count($pk->message, "§")); $this->dataPacket($pk->setChannel(Network::CHANNEL_TEXT)); } } @@ -2545,7 +2571,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ }else{ $pk->type = TextPacket::TYPE_RAW; $pk->message = $this->server->getLanguage()->translateString($message, $parameters); - $pk->message .= str_repeat(" ", substr_count($pk->message, "§")); } $this->dataPacket($pk->setChannel(Network::CHANNEL_TEXT)); } diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index a438320c3..14b3602ab 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -74,7 +74,7 @@ namespace pocketmine { const VERSION = "1.5dev"; const API_VERSION = "1.12.0"; const CODENAME = "活発(Kappatsu)フグ(Fugu)"; - const MINECRAFT_VERSION = "v0.11.0 alpha build 4"; + const MINECRAFT_VERSION = "v0.11.0 alpha build 5"; /* * Startup code. Do not look at it, it may harm you. diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 77aa2c9e0..d53156ff4 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -247,7 +247,7 @@ class Block extends Position implements Metadatable{ const GLOWING_OBSIDIAN = 246; const NETHER_REACTOR = 247; - public static $creative = [ + public static $creative = [ //TODO: make this available to plugins //Building [Item::COBBLESTONE, 0], [Item::STONE_BRICKS, 0], diff --git a/src/pocketmine/inventory/PlayerInventory.php b/src/pocketmine/inventory/PlayerInventory.php index 7ac5fb395..67eb04938 100644 --- a/src/pocketmine/inventory/PlayerInventory.php +++ b/src/pocketmine/inventory/PlayerInventory.php @@ -340,7 +340,7 @@ class PlayerInventory extends BaseInventory{ //$pk2->eid = 0; $pk2 = new ContainerSetContentPacket(); - $pk2->windowid = 0x78; //Armor window id constant + $pk2->windowid = ContainerSetContentPacket::SPECIAL_ARMOR; $pk2->slots = $armor; $player->dataPacket($pk2); }else{ @@ -397,7 +397,7 @@ class PlayerInventory extends BaseInventory{ if($player === $this->getHolder()){ /** @var Player $player */ $pk2 = new ContainerSetSlotPacket(); - $pk2->windowid = 0x78; //Armor window id constant + $pk2->windowid = ContainerSetContentPacket::SPECIAL_ARMOR; $pk2->slot = $index; $pk2->item = $this->getItem($index); $player->dataPacket($pk2); diff --git a/src/pocketmine/network/protocol/ContainerSetContentPacket.php b/src/pocketmine/network/protocol/ContainerSetContentPacket.php index ca8f438c0..b0b996fce 100644 --- a/src/pocketmine/network/protocol/ContainerSetContentPacket.php +++ b/src/pocketmine/network/protocol/ContainerSetContentPacket.php @@ -28,6 +28,10 @@ class ContainerSetContentPacket extends DataPacket{ public static $pool = []; public static $next = 0; + const SPECIAL_INVENTORY = 0; + const SPECIAL_ARMOR = 0x78; + const SPECIAL_CREATIVE = 0x79; + public $windowid; public $slots = []; public $hotbar = []; @@ -48,7 +52,7 @@ class ContainerSetContentPacket extends DataPacket{ for($s = 0; $s < $count and !$this->feof(); ++$s){ $this->slots[$s] = $this->getSlot(); } - if($this->windowid === 0){ + if($this->windowid === self::SPECIAL_INVENTORY){ $count = $this->getShort(); for($s = 0; $s < $count and !$this->feof(); ++$s){ $this->hotbar[$s] = $this->getInt(); @@ -63,7 +67,7 @@ class ContainerSetContentPacket extends DataPacket{ foreach($this->slots as $slot){ $this->putSlot($slot); } - if($this->windowid === 0 and count($this->hotbar) > 0){ + if($this->windowid === self::SPECIAL_INVENTORY and count($this->hotbar) > 0){ $this->putShort(count($this->hotbar)); foreach($this->hotbar as $slot){ $this->putInt($slot); diff --git a/src/pocketmine/network/protocol/Info.php b/src/pocketmine/network/protocol/Info.php index 7018573b1..986da6997 100644 --- a/src/pocketmine/network/protocol/Info.php +++ b/src/pocketmine/network/protocol/Info.php @@ -30,7 +30,7 @@ interface Info{ /** * Actual Minecraft: PE protocol version */ - const CURRENT_PROTOCOL = 22; + const CURRENT_PROTOCOL = 23; const LOGIN_PACKET = 0x82; const PLAY_STATUS_PACKET = 0x83;