mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-19 04:15:04 +00:00
Implemented new Inventory windows on Player, Chest and Furnace
This commit is contained in:
@@ -31,6 +31,7 @@ use pocketmine\event\block\BlockBreakEvent;
|
||||
use pocketmine\event\block\BlockPlaceEvent;
|
||||
use pocketmine\event\player\PlayerInteractEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\pmf\LevelFormat;
|
||||
use pocketmine\level\generator\Generator;
|
||||
use pocketmine\math\Vector2;
|
||||
use pocketmine\math\Vector3 as Vector3;
|
||||
@@ -42,7 +43,6 @@ use pocketmine\nbt\tag\String;
|
||||
use pocketmine\network\protocol\SetTimePacket;
|
||||
use pocketmine\network\protocol\UpdateBlockPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\level\format\pmf\LevelFormat;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\tile\Chest;
|
||||
use pocketmine\tile\Furnace;
|
||||
|
@@ -21,9 +21,9 @@
|
||||
|
||||
namespace pocketmine\level;
|
||||
|
||||
use pocketmine\level\format\pmf\LevelFormat;
|
||||
use pocketmine\level\format\PocketChunkParser;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\level\format\pmf\LevelFormat;
|
||||
use pocketmine\utils\Config;
|
||||
|
||||
class LevelImport{
|
||||
|
@@ -106,6 +106,7 @@ class Position extends Vector3{
|
||||
if(!$this->isValid()){
|
||||
throw new \RuntimeException("Undefined Level reference");
|
||||
}
|
||||
|
||||
return Position::fromObject(parent::getSide($side, $step), $this->getLevel());
|
||||
}
|
||||
|
||||
|
@@ -21,8 +21,8 @@
|
||||
|
||||
namespace pocketmine\level;
|
||||
|
||||
use pocketmine\level\generator\Generator;
|
||||
use pocketmine\level\format\pmf\LevelFormat;
|
||||
use pocketmine\level\generator\Generator;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Random;
|
||||
|
@@ -52,11 +52,11 @@ interface Chunk{
|
||||
public function getBlock($x, $y, $z, &$blockId, &$meta = null);
|
||||
|
||||
/**
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-127
|
||||
* @param int $z 0-15
|
||||
* @param int $blockId, if null, do not change
|
||||
* @param int $meta 0-15, if null, do not change
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-127
|
||||
* @param int $z 0-15
|
||||
* @param int $blockId , if null, do not change
|
||||
* @param int $meta 0-15, if null, do not change
|
||||
*/
|
||||
public function setBlock($x, $y, $z, $blockId = null, $meta = null);
|
||||
|
||||
@@ -70,9 +70,9 @@ interface Chunk{
|
||||
public function getBlockId($x, $y, $z);
|
||||
|
||||
/**
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-127
|
||||
* @param int $z 0-15
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-127
|
||||
* @param int $z 0-15
|
||||
* @param int $id 0-255
|
||||
*/
|
||||
public function setBlockId($x, $y, $z, $id);
|
||||
@@ -87,9 +87,9 @@ interface Chunk{
|
||||
public function getBlockData($x, $y, $z);
|
||||
|
||||
/**
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-127
|
||||
* @param int $z 0-15
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-127
|
||||
* @param int $z 0-15
|
||||
* @param int $data 0-15
|
||||
*/
|
||||
public function setBlockData($x, $y, $z, $data);
|
||||
@@ -104,9 +104,9 @@ interface Chunk{
|
||||
public function getBlockSkyLight($x, $y, $z);
|
||||
|
||||
/**
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-127
|
||||
* @param int $z 0-15
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-127
|
||||
* @param int $z 0-15
|
||||
* @param int $level 0-15
|
||||
*/
|
||||
public function setBlockSkyLight($x, $y, $z, $level);
|
||||
@@ -121,9 +121,9 @@ interface Chunk{
|
||||
public function getBlockLight($x, $y, $z);
|
||||
|
||||
/**
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-127
|
||||
* @param int $z 0-15
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-127
|
||||
* @param int $z 0-15
|
||||
* @param int $level 0-15
|
||||
*/
|
||||
public function setBlockLight($x, $y, $z, $level);
|
||||
|
@@ -33,9 +33,9 @@ interface ChunkSection{
|
||||
public function getBlockId($x, $y, $z);
|
||||
|
||||
/**
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $id 0-255
|
||||
*/
|
||||
public function setBlockId($x, $y, $z, $id);
|
||||
@@ -50,9 +50,9 @@ interface ChunkSection{
|
||||
public function getBlockData($x, $y, $z);
|
||||
|
||||
/**
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $data 0-15
|
||||
*/
|
||||
public function setBlockData($x, $y, $z, $data);
|
||||
@@ -69,11 +69,11 @@ interface ChunkSection{
|
||||
public function getBlock($x, $y, $z, &$blockId, &$meta = null);
|
||||
|
||||
/**
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $blockId, if null, do not change
|
||||
* @param int $meta 0-15, if null, do not change
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $blockId , if null, do not change
|
||||
* @param int $meta 0-15, if null, do not change
|
||||
*/
|
||||
public function setBlock($x, $y, $z, $blockId = null, $meta = null);
|
||||
|
||||
@@ -87,9 +87,9 @@ interface ChunkSection{
|
||||
public function getBlockSkyLight($x, $y, $z);
|
||||
|
||||
/**
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $level 0-15
|
||||
*/
|
||||
public function setBlockSkyLight($x, $y, $z, $level);
|
||||
@@ -104,9 +104,9 @@ interface ChunkSection{
|
||||
public function getBlockLight($x, $y, $z);
|
||||
|
||||
/**
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $x 0-15
|
||||
* @param int $y 0-15
|
||||
* @param int $z 0-15
|
||||
* @param int $level 0-15
|
||||
*/
|
||||
public function setBlockLight($x, $y, $z, $level);
|
||||
|
@@ -20,8 +20,9 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\level\format;
|
||||
use pocketmine\Server;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Server;
|
||||
|
||||
/**
|
||||
* All Level formats must implement this interface
|
||||
@@ -48,8 +49,8 @@ interface LevelFormat{
|
||||
* Gets the Chunk object
|
||||
* This method must be implemented by all the level formats.
|
||||
*
|
||||
* @param int $X absolute Chunk X value
|
||||
* @param int $Z absolute Chunk Z value
|
||||
* @param int $X absolute Chunk X value
|
||||
* @param int $Z absolute Chunk Z value
|
||||
* @param bool $create Whether to generate the chunk if it does not exist
|
||||
*
|
||||
* @return ChunkSnapshot
|
||||
|
@@ -22,7 +22,6 @@
|
||||
namespace pocketmine\level\format;
|
||||
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
/**
|
||||
* WARNING: This code is old, and only supports the file format partially (reverse engineering)
|
||||
|
@@ -138,6 +138,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
for($y = 15; $y >= 0; --$y){
|
||||
$column{15 - $y} = $this->blocks{($y << 8) + $i};
|
||||
}
|
||||
|
||||
return $column;
|
||||
}
|
||||
|
||||
@@ -147,6 +148,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
for($y = 7; $y >= 0; --$y){
|
||||
$column{7 - $y} = $this->data{($y << 7) + $i};
|
||||
}
|
||||
|
||||
return $column;
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,6 @@
|
||||
|
||||
namespace pocketmine\level\format\anvil;
|
||||
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\ByteArray;
|
||||
@@ -45,10 +44,12 @@ class RegionLoader{
|
||||
protected $lastSector;
|
||||
protected $locationTable = [];
|
||||
|
||||
public function __construct($path,/*Level $level, */$regionX, $regionZ){
|
||||
public function __construct($path, /*Level $level, */
|
||||
$regionX, $regionZ){
|
||||
$this->x = $regionX;
|
||||
$this->z = $regionZ;
|
||||
$this->filePath = /*$level->getPath()*/$path . "region/r.$regionX.$regionZ.mca";
|
||||
$this->filePath = /*$level->getPath()*/
|
||||
$path . "region/r.$regionX.$regionZ.mca";
|
||||
touch($this->filePath);
|
||||
$this->filePointer = fopen($this->filePath, "r+b");
|
||||
flock($this->filePointer, LOCK_EX);
|
||||
@@ -103,6 +104,7 @@ class RegionLoader{
|
||||
$this->writeLocationIndex($index);
|
||||
}elseif($compression !== self::COMPRESSION_ZLIB and $compression !== self::COMPRESSION_GZIP){
|
||||
trigger_error("Invalid compression type", E_USER_WARNING);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -113,6 +115,7 @@ class RegionLoader{
|
||||
if(!$chunk instanceof Compound){
|
||||
return false;
|
||||
}
|
||||
|
||||
return $chunk;
|
||||
//$chunk = new Chunk($level, $chunk);
|
||||
}
|
||||
@@ -183,6 +186,7 @@ class RegionLoader{
|
||||
$this->writeLocationTable();
|
||||
$n = $this->cleanGarbage();
|
||||
$this->writeLocationTable();
|
||||
|
||||
return $n;
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\level\format\generic;
|
||||
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\ChunkSection;
|
||||
use pocketmine\level\Level;
|
||||
@@ -34,9 +35,9 @@ abstract class BaseChunk implements Chunk{
|
||||
protected $z;
|
||||
|
||||
/**
|
||||
* @param Level $level
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
* @param Level $level
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
* @param ChunkSection[] $sections
|
||||
*/
|
||||
public function __construct(Level $level, $x, $z, array $sections){
|
||||
@@ -48,11 +49,13 @@ abstract class BaseChunk implements Chunk{
|
||||
$this->sections[$Y] = $section;
|
||||
}else{
|
||||
trigger_error("Received invalid ChunkSection instance", E_USER_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if($section >= self::SECTION_COUNT){
|
||||
trigger_error("Invalid amount of chunks", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\level\format\generic;
|
||||
|
||||
use pocketmine\level\format\ChunkSection;
|
||||
|
||||
/**
|
||||
|
@@ -32,6 +32,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
if($section !== null){
|
||||
if(strlen($section) !== 8192){
|
||||
trigger_error("Invalid ChunkSection generated", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
$this->section = $section;
|
||||
|
@@ -26,7 +26,6 @@ use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Enum;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
class LevelFormat extends PMF{
|
||||
const VERSION = 2;
|
||||
|
Reference in New Issue
Block a user