mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-21 19:01:37 +00:00
build 8, allow setting selected hotbar slot, auto_jump setting
This commit is contained in:
parent
84d1f4596b
commit
8caf04ade5
@ -215,6 +215,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
protected $inAirTicks = 0;
|
||||
|
||||
protected $autoJump = true;
|
||||
|
||||
|
||||
private $needACK = [];
|
||||
|
||||
@ -285,6 +287,15 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return $this->namedtag instanceof Compound;
|
||||
}
|
||||
|
||||
public function setAutoJump($value){
|
||||
$this->autoJump = $value;
|
||||
$this->sendSettings();
|
||||
}
|
||||
|
||||
public function hasAutoJump(){
|
||||
return $this->autoJump;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
*/
|
||||
@ -458,7 +469,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->perm = new PermissibleBase($this);
|
||||
$this->namedtag = new Compound();
|
||||
$this->server = Server::getInstance();
|
||||
$this->lastBreak = microtime(true);
|
||||
$this->lastBreak = PHP_INT_MAX;
|
||||
$this->ip = $ip;
|
||||
$this->port = $port;
|
||||
$this->clientID = $clientID;
|
||||
@ -907,6 +918,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
|
||||
$this->level->sleepTicks = 0;
|
||||
|
||||
$pk = new AnimatePacket();
|
||||
$pk->eid = $this->getId();
|
||||
$pk->action = 3; //Wake up
|
||||
$this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1008,22 +1024,17 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
/**
|
||||
* Sends all the option flags
|
||||
*
|
||||
* WARNING: Do not use this, it's only for internal use.
|
||||
* Changes to this function won't be recorded on the version.
|
||||
*
|
||||
* @param bool $nametags
|
||||
*/
|
||||
public function sendSettings($nametags = true){
|
||||
public function sendSettings(){
|
||||
/*
|
||||
bit mask | flag name
|
||||
0x00000001 world_inmutable
|
||||
0x00000002 -
|
||||
0x00000004 -
|
||||
0x00000008 - (autojump)
|
||||
0x00000010 -
|
||||
0x00000002 no_pvp
|
||||
0x00000004 no_pvm
|
||||
0x00000008 no_mvp
|
||||
0x00000010 static_time
|
||||
0x00000020 nametags_visible
|
||||
0x00000040 ?
|
||||
0x00000040 auto_jump
|
||||
0x00000080 ?
|
||||
0x00000100 ?
|
||||
0x00000200 ?
|
||||
@ -1055,8 +1066,12 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$flags |= 0x01; //Do not allow placing/breaking blocks, adventure mode
|
||||
}
|
||||
|
||||
if($nametags !== false){
|
||||
/*if($nametags !== false){
|
||||
$flags |= 0x20; //Show Nametags
|
||||
}*/
|
||||
|
||||
if($this->autoJump){
|
||||
$flags |= 0x40;
|
||||
}
|
||||
|
||||
$pk = new AdventureSettingsPacket();
|
||||
@ -1686,9 +1701,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}elseif($this->isCreative()){
|
||||
$this->inventory->setHeldItemIndex($packet->slot);
|
||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
||||
$this->inventory->setHeldItemSlot($slot);
|
||||
}else{
|
||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){
|
||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){
|
||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
||||
$this->inventory->setHeldItemSlot($slot);
|
||||
}else{
|
||||
@ -1728,7 +1744,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$item = $this->inventory->getItemInHand();
|
||||
$oldItem = clone $item;
|
||||
//TODO: Implement adventure mode checks
|
||||
if($this->level->useItemOn($blockVector, $item, $packet->face, $packet->fx, $packet->fy, $packet->fz, $this) === true){
|
||||
if($this->level->useItemOn($blockVector, $item, $packet->face, $packet->fx, $packet->fy, $packet->fz, $this)){
|
||||
if(!$item->equals($oldItem, true) or $item->getCount() !== $oldItem->getCount()){
|
||||
$this->inventory->setItemInHand($item, $this);
|
||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
||||
|
@ -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 7";
|
||||
const MINECRAFT_VERSION = "v0.11.0 alpha build 8";
|
||||
|
||||
/*
|
||||
* Startup code. Do not look at it, it may harm you.
|
||||
|
@ -598,6 +598,13 @@ class Block extends Position implements Metadatable{
|
||||
return 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getResistance(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
|
@ -71,15 +71,12 @@ class PlayerInventory extends BaseInventory{
|
||||
public function setHeldItemIndex($index){
|
||||
if($index >= 0 and $index < $this->getHotbarSize()){
|
||||
$this->itemInHandIndex = $index;
|
||||
$item = $this->getItemInHand();
|
||||
|
||||
$pk = new PlayerEquipmentPacket();
|
||||
$pk->eid = $this->getHolder()->getId();
|
||||
$pk->item = $item->getId();
|
||||
$pk->meta = $item->getDamage();
|
||||
$pk->slot = $this->getHeldItemIndex();
|
||||
|
||||
Server::broadcastPacket($this->getHolder()->getViewers(), $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
|
||||
if($this->getHolder() instanceof Player){
|
||||
$this->sendHeldItem($this->getHolder()->getViewers() + [$this->getHolder()]);
|
||||
}else{
|
||||
$this->sendHeldItem($this->getHolder()->getViewers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,15 +142,16 @@ class PlayerInventory extends BaseInventory{
|
||||
$pk->eid = $this->getHolder()->getId();
|
||||
$pk->item = $item->getId();
|
||||
$pk->meta = $item->getDamage();
|
||||
$pk->slot = 0;
|
||||
$pk->slot = $this->getHeldItemSlot();
|
||||
$pk->selectedSlot = $this->getHeldItemIndex();
|
||||
$pk->isEncoded = true;
|
||||
$pk->encode();
|
||||
|
||||
Server::broadcastPacket($target, $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
|
||||
|
||||
foreach($target as $player){
|
||||
if($player === $this->getHolder()){
|
||||
$this->sendSlot($this->getHeldItemSlot(), $player);
|
||||
}else{
|
||||
$player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user