mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
0.11.0 build 5, removed chat format workaround, improved gamemode switch, send allowed creative blocks (TBI as API)
This commit is contained in:
parent
7ee21f6254
commit
5b10ccf431
@ -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));
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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],
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user