mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
Fixed spawning of Tile entities via chunk packets
This commit is contained in:
parent
0d5eb149ab
commit
279a438ae6
@ -525,21 +525,15 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
unset($this->chunkACK[$identifier]);
|
unset($this->chunkACK[$identifier]);
|
||||||
if(isset($this->usedChunks[$index])){
|
if(isset($this->usedChunks[$index])){
|
||||||
$this->usedChunks[$index][0] = true;
|
$this->usedChunks[$index][0] = true;
|
||||||
if($this->spawned === true){
|
|
||||||
$X = null;
|
$X = null;
|
||||||
$Z = null;
|
$Z = null;
|
||||||
Level::getXZ($index, $X, $Z);
|
Level::getXZ($index, $X, $Z);
|
||||||
|
|
||||||
foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){
|
foreach($this->getLevel()->getChunkEntities($X, $Z) as $entity){
|
||||||
if($entity !== $this){
|
if($entity !== $this){
|
||||||
$entity->spawnTo($this);
|
$entity->spawnTo($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach($this->getLevel()->getChunkTiles($X, $Z) as $tile){
|
|
||||||
if($tile instanceof Spawnable){
|
|
||||||
$tile->spawnTo($this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ namespace pocketmine\command\defaults;
|
|||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class BanCommand extends VanillaCommand{
|
class BanCommand extends VanillaCommand{
|
||||||
|
@ -24,7 +24,6 @@ namespace pocketmine\command\defaults;
|
|||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class BanIpCommand extends VanillaCommand{
|
class BanIpCommand extends VanillaCommand{
|
||||||
|
@ -24,7 +24,6 @@ namespace pocketmine\command\defaults;
|
|||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class DeopCommand extends VanillaCommand{
|
class DeopCommand extends VanillaCommand{
|
||||||
|
@ -25,7 +25,6 @@ use pocketmine\command\Command;
|
|||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class GiveCommand extends VanillaCommand{
|
class GiveCommand extends VanillaCommand{
|
||||||
|
@ -24,7 +24,6 @@ namespace pocketmine\command\defaults;
|
|||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\command\ConsoleCommandSender;
|
use pocketmine\command\ConsoleCommandSender;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class HelpCommand extends VanillaCommand{
|
class HelpCommand extends VanillaCommand{
|
||||||
|
@ -24,7 +24,6 @@ namespace pocketmine\command\defaults;
|
|||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class KickCommand extends VanillaCommand{
|
class KickCommand extends VanillaCommand{
|
||||||
|
@ -23,7 +23,6 @@ namespace pocketmine\command\defaults;
|
|||||||
|
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class MeCommand extends VanillaCommand{
|
class MeCommand extends VanillaCommand{
|
||||||
|
@ -24,7 +24,6 @@ namespace pocketmine\command\defaults;
|
|||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class OpCommand extends VanillaCommand{
|
class OpCommand extends VanillaCommand{
|
||||||
|
@ -23,7 +23,6 @@ namespace pocketmine\command\defaults;
|
|||||||
|
|
||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class PardonCommand extends VanillaCommand{
|
class PardonCommand extends VanillaCommand{
|
||||||
|
@ -23,7 +23,6 @@ namespace pocketmine\command\defaults;
|
|||||||
|
|
||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class PardonIpCommand extends VanillaCommand{
|
class PardonIpCommand extends VanillaCommand{
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
namespace pocketmine\command\defaults;
|
namespace pocketmine\command\defaults;
|
||||||
|
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class PluginsCommand extends VanillaCommand{
|
class PluginsCommand extends VanillaCommand{
|
||||||
|
@ -23,7 +23,6 @@ namespace pocketmine\command\defaults;
|
|||||||
|
|
||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class ReloadCommand extends VanillaCommand{
|
class ReloadCommand extends VanillaCommand{
|
||||||
|
@ -24,7 +24,6 @@ namespace pocketmine\command\defaults;
|
|||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\command\ConsoleCommandSender;
|
use pocketmine\command\ConsoleCommandSender;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class SayCommand extends VanillaCommand{
|
class SayCommand extends VanillaCommand{
|
||||||
|
@ -25,7 +25,6 @@ use pocketmine\command\Command;
|
|||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class SetWorldSpawnCommand extends VanillaCommand{
|
class SetWorldSpawnCommand extends VanillaCommand{
|
||||||
|
@ -25,7 +25,6 @@ use pocketmine\command\Command;
|
|||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\level\Position;
|
use pocketmine\level\Position;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class SpawnpointCommand extends VanillaCommand{
|
class SpawnpointCommand extends VanillaCommand{
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
namespace pocketmine\command\defaults;
|
namespace pocketmine\command\defaults;
|
||||||
|
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class StatusCommand extends VanillaCommand{
|
class StatusCommand extends VanillaCommand{
|
||||||
|
@ -26,7 +26,6 @@ use pocketmine\command\CommandSender;
|
|||||||
use pocketmine\level\Position;
|
use pocketmine\level\Position;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class TeleportCommand extends VanillaCommand{
|
class TeleportCommand extends VanillaCommand{
|
||||||
|
@ -23,7 +23,6 @@ namespace pocketmine\command\defaults;
|
|||||||
|
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class TellCommand extends VanillaCommand{
|
class TellCommand extends VanillaCommand{
|
||||||
|
@ -24,7 +24,6 @@ namespace pocketmine\command\defaults;
|
|||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\network\protocol\Info;
|
use pocketmine\network\protocol\Info;
|
||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class VersionCommand extends VanillaCommand{
|
class VersionCommand extends VanillaCommand{
|
||||||
|
@ -23,7 +23,6 @@ namespace pocketmine\command\defaults;
|
|||||||
|
|
||||||
use pocketmine\command\Command;
|
use pocketmine\command\Command;
|
||||||
use pocketmine\command\CommandSender;
|
use pocketmine\command\CommandSender;
|
||||||
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
class WhitelistCommand extends VanillaCommand{
|
class WhitelistCommand extends VanillaCommand{
|
||||||
|
@ -32,7 +32,6 @@ use pocketmine\event\entity\EntityMoveEvent;
|
|||||||
use pocketmine\event\entity\EntitySpawnEvent;
|
use pocketmine\event\entity\EntitySpawnEvent;
|
||||||
use pocketmine\event\entity\EntityTeleportEvent;
|
use pocketmine\event\entity\EntityTeleportEvent;
|
||||||
use pocketmine\level\format\Chunk;
|
use pocketmine\level\format\Chunk;
|
||||||
|
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\level\Position;
|
use pocketmine\level\Position;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
@ -43,13 +42,13 @@ use pocketmine\nbt\tag\Byte;
|
|||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\Compound;
|
||||||
use pocketmine\nbt\tag\Float;
|
use pocketmine\nbt\tag\Float;
|
||||||
use pocketmine\nbt\tag\Short;
|
use pocketmine\nbt\tag\Short;
|
||||||
use pocketmine\Network;
|
|
||||||
use pocketmine\network\protocol\MoveEntityPacket_PosRot;
|
use pocketmine\network\protocol\MoveEntityPacket_PosRot;
|
||||||
use pocketmine\network\protocol\MovePlayerPacket;
|
use pocketmine\network\protocol\MovePlayerPacket;
|
||||||
use pocketmine\network\protocol\RemoveEntityPacket;
|
use pocketmine\network\protocol\RemoveEntityPacket;
|
||||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||||
use pocketmine\network\protocol\SetTimePacket;
|
use pocketmine\network\protocol\SetTimePacket;
|
||||||
use pocketmine\network\protocol\UnloadChunkPacket;
|
use pocketmine\network\protocol\UnloadChunkPacket;
|
||||||
|
use pocketmine\Network;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
@ -29,10 +29,10 @@ use pocketmine\nbt\tag\Byte;
|
|||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\Compound;
|
||||||
use pocketmine\nbt\tag\Enum;
|
use pocketmine\nbt\tag\Enum;
|
||||||
use pocketmine\nbt\tag\Short;
|
use pocketmine\nbt\tag\Short;
|
||||||
use pocketmine\Network;
|
|
||||||
use pocketmine\network\protocol\AddPlayerPacket;
|
use pocketmine\network\protocol\AddPlayerPacket;
|
||||||
use pocketmine\network\protocol\RemovePlayerPacket;
|
use pocketmine\network\protocol\RemovePlayerPacket;
|
||||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||||
|
use pocketmine\Network;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
namespace pocketmine\event\player;
|
namespace pocketmine\event\player;
|
||||||
|
|
||||||
use pocketmine\Event;
|
|
||||||
use pocketmine\event\Cancellable;
|
use pocketmine\event\Cancellable;
|
||||||
|
use pocketmine\Event;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
namespace pocketmine\event\server;
|
namespace pocketmine\event\server;
|
||||||
|
|
||||||
use pocketmine\event\Cancellable;
|
|
||||||
use pocketmine\event;
|
use pocketmine\event;
|
||||||
|
use pocketmine\event\Cancellable;
|
||||||
use pocketmine\network\protocol\DataPacket;
|
use pocketmine\network\protocol\DataPacket;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
namespace pocketmine\event\server;
|
namespace pocketmine\event\server;
|
||||||
|
|
||||||
use pocketmine\event\Cancellable;
|
|
||||||
use pocketmine\event;
|
use pocketmine\event;
|
||||||
|
use pocketmine\event\Cancellable;
|
||||||
use pocketmine\network\protocol\DataPacket;
|
use pocketmine\network\protocol\DataPacket;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
use pocketmine\entity\Entity;
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
|
use pocketmine\entity\Entity;
|
||||||
|
|
||||||
abstract class Tool extends Item{
|
abstract class Tool extends Item{
|
||||||
|
|
||||||
|
@ -37,13 +37,13 @@ use pocketmine\level\format\Chunk;
|
|||||||
use pocketmine\level\format\LevelProvider;
|
use pocketmine\level\format\LevelProvider;
|
||||||
use pocketmine\level\format\SimpleChunk;
|
use pocketmine\level\format\SimpleChunk;
|
||||||
use pocketmine\level\generator\Generator;
|
use pocketmine\level\generator\Generator;
|
||||||
|
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Vector2;
|
use pocketmine\math\Vector2;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\metadata\BlockMetadataStore;
|
use pocketmine\metadata\BlockMetadataStore;
|
||||||
use pocketmine\metadata\Metadatable;
|
use pocketmine\metadata\Metadatable;
|
||||||
use pocketmine\metadata\MetadataValue;
|
use pocketmine\metadata\MetadataValue;
|
||||||
|
use pocketmine\nbt\NBT;
|
||||||
use pocketmine\nbt\tag\Byte;
|
use pocketmine\nbt\tag\Byte;
|
||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\Compound;
|
||||||
use pocketmine\nbt\tag\Double;
|
use pocketmine\nbt\tag\Double;
|
||||||
@ -58,6 +58,7 @@ use pocketmine\Player;
|
|||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
use pocketmine\tile\Sign;
|
use pocketmine\tile\Sign;
|
||||||
|
use pocketmine\tile\Spawnable;
|
||||||
use pocketmine\tile\Tile;
|
use pocketmine\tile\Tile;
|
||||||
use pocketmine\utils\Cache;
|
use pocketmine\utils\Cache;
|
||||||
use pocketmine\utils\ReversePriorityQueue;
|
use pocketmine\utils\ReversePriorityQueue;
|
||||||
@ -1266,7 +1267,16 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ordered = zlib_encode(Binary::writeLInt($X) . Binary::writeLInt($Z) . $orderedIds . $orderedData . $orderedSkyLight . $orderedLight . $biomeIds . $biomeColors, ZLIB_ENCODING_DEFLATE, self::$COMPRESSION_LEVEL);
|
$tiles = "";
|
||||||
|
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
||||||
|
foreach($chunk->getTiles() as $tile){
|
||||||
|
if($tile instanceof Spawnable){
|
||||||
|
$nbt->setData($tile->getSpawnCompound());
|
||||||
|
$tiles .= $nbt->write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ordered = zlib_encode(Binary::writeLInt($X) . Binary::writeLInt($Z) . $orderedIds . $orderedData . $orderedSkyLight . $orderedLight . $biomeIds . $biomeColors . $tiles, ZLIB_ENCODING_DEFLATE, self::$COMPRESSION_LEVEL);
|
||||||
|
|
||||||
if(ADVANCED_CACHE == true and $Yndex === 0xff){
|
if(ADVANCED_CACHE == true and $Yndex === 0xff){
|
||||||
Cache::add($identifier, $ordered, 60);
|
Cache::add($identifier, $ordered, 60);
|
||||||
|
@ -29,7 +29,6 @@ use pocketmine\nbt\tag\Byte;
|
|||||||
use pocketmine\nbt\tag\ByteArray;
|
use pocketmine\nbt\tag\ByteArray;
|
||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\Compound;
|
||||||
use pocketmine\nbt\tag\Enum;
|
use pocketmine\nbt\tag\Enum;
|
||||||
|
|
||||||
use pocketmine\nbt\tag\IntArray;
|
use pocketmine\nbt\tag\IntArray;
|
||||||
use pocketmine\utils\Binary;
|
use pocketmine\utils\Binary;
|
||||||
|
|
||||||
@ -74,7 +73,7 @@ class Chunk extends BaseChunk{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArray)){
|
if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArray)){
|
||||||
$this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 156, Binary::readInt("\x01\x85\xb2\x4a")));
|
$this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 156, Binary::readInt("\x00\x85\xb2\x4a")));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sections = [];
|
$sections = [];
|
||||||
|
@ -206,7 +206,7 @@ abstract class BaseChunk implements Chunk{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setBiomeColor($x, $z, $R, $G, $B){
|
public function setBiomeColor($x, $z, $R, $G, $B){
|
||||||
$this->biomeColors[($z << 4) + $x] = 0x01000000 | (($R & 0xFF) << 16) | (($G & 0xFF) << 8) | ($B & 0xFF);
|
$this->biomeColors[($z << 4) + $x] = 0 | (($R & 0xFF) << 16) | (($G & 0xFF) << 8) | ($B & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHighestBlockAt($x, $z){
|
public function getHighestBlockAt($x, $z){
|
||||||
|
@ -34,8 +34,6 @@ use pocketmine\nbt\tag\Enum;
|
|||||||
use pocketmine\nbt\tag\Int;
|
use pocketmine\nbt\tag\Int;
|
||||||
use pocketmine\nbt\tag\Short;
|
use pocketmine\nbt\tag\Short;
|
||||||
use pocketmine\nbt\tag\String;
|
use pocketmine\nbt\tag\String;
|
||||||
use pocketmine\network\protocol\EntityDataPacket;
|
|
||||||
use pocketmine\Player;
|
|
||||||
|
|
||||||
class Chest extends Spawnable implements InventoryHolder, Container{
|
class Chest extends Spawnable implements InventoryHolder, Container{
|
||||||
|
|
||||||
@ -220,37 +218,23 @@ class Chest extends Spawnable implements InventoryHolder, Container{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function spawnTo(Player $player){
|
public function getSpawnCompound(){
|
||||||
if($this->closed){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
|
||||||
if($this->isPaired()){
|
if($this->isPaired()){
|
||||||
$nbt->setData(new Compound("", array(
|
return new Compound("", array(
|
||||||
new String("id", Tile::CHEST),
|
new String("id", Tile::CHEST),
|
||||||
new Int("x", (int) $this->x),
|
new Int("x", (int) $this->x),
|
||||||
new Int("y", (int) $this->y),
|
new Int("y", (int) $this->y),
|
||||||
new Int("z", (int) $this->z),
|
new Int("z", (int) $this->z),
|
||||||
new Int("pairx", (int) $this->namedtag->pairx),
|
new Int("pairx", (int) $this->namedtag->pairx),
|
||||||
new Int("pairz", (int) $this->namedtag->pairz)
|
new Int("pairz", (int) $this->namedtag->pairz)
|
||||||
)));
|
));
|
||||||
}else{
|
}else{
|
||||||
$nbt->setData(new Compound("", array(
|
return new Compound("", array(
|
||||||
new String("id", Tile::CHEST),
|
new String("id", Tile::CHEST),
|
||||||
new Int("x", (int) $this->x),
|
new Int("x", (int) $this->x),
|
||||||
new Int("y", (int) $this->y),
|
new Int("y", (int) $this->y),
|
||||||
new Int("z", (int) $this->z)
|
new Int("z", (int) $this->z)
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$pk = new EntityDataPacket;
|
|
||||||
$pk->x = $this->x;
|
|
||||||
$pk->y = $this->y;
|
|
||||||
$pk->z = $this->z;
|
|
||||||
$pk->namedtag = $nbt->write();
|
|
||||||
$player->dataPacket($pk);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,12 +22,9 @@
|
|||||||
namespace pocketmine\tile;
|
namespace pocketmine\tile;
|
||||||
|
|
||||||
use pocketmine\level\format\Chunk;
|
use pocketmine\level\format\Chunk;
|
||||||
use pocketmine\nbt\NBT;
|
|
||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\Compound;
|
||||||
use pocketmine\nbt\tag\Int;
|
use pocketmine\nbt\tag\Int;
|
||||||
use pocketmine\nbt\tag\String;
|
use pocketmine\nbt\tag\String;
|
||||||
use pocketmine\network\protocol\EntityDataPacket;
|
|
||||||
use pocketmine\Player;
|
|
||||||
|
|
||||||
class Sign extends Spawnable{
|
class Sign extends Spawnable{
|
||||||
|
|
||||||
@ -45,6 +42,7 @@ class Sign extends Spawnable{
|
|||||||
if(!isset($nbt->Text4)){
|
if(!isset($nbt->Text4)){
|
||||||
$nbt->Text4 = new String("Text4", "");
|
$nbt->Text4 = new String("Text4", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct($chunk, $nbt);
|
parent::__construct($chunk, $nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,30 +65,17 @@ class Sign extends Spawnable{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function spawnTo(Player $player){
|
public function getSpawnCompound(){
|
||||||
if($this->closed){
|
return new Compound("", array(
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
|
||||||
$nbt->setData(new Compound("", array(
|
|
||||||
new String("Text1", $this->namedtag["Text1"]),
|
new String("Text1", $this->namedtag["Text1"]),
|
||||||
new String("Text2", $this->namedtag["Text2"]),
|
new String("Text2", $this->namedtag["Text2"]),
|
||||||
new String("Text3", $this->namedtag["Text4"]),
|
new String("Text3", $this->namedtag["Text3"]),
|
||||||
new String("Text4", $this->namedtag["Text4"]),
|
new String("Text4", $this->namedtag["Text4"]),
|
||||||
new String("id", Tile::SIGN),
|
new String("id", Tile::SIGN),
|
||||||
new Int("x", (int) $this->x),
|
new Int("x", (int) $this->x),
|
||||||
new Int("y", (int) $this->y),
|
new Int("y", (int) $this->y),
|
||||||
new Int("z", (int) $this->z)
|
new Int("z", (int) $this->z)
|
||||||
)));
|
));
|
||||||
$pk = new EntityDataPacket;
|
|
||||||
$pk->x = $this->x;
|
|
||||||
$pk->y = $this->y;
|
|
||||||
$pk->z = $this->z;
|
|
||||||
$pk->namedtag = $nbt->write();
|
|
||||||
$player->dataPacket($pk);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,31 @@
|
|||||||
namespace pocketmine\tile;
|
namespace pocketmine\tile;
|
||||||
|
|
||||||
use pocketmine\level\format\Chunk;
|
use pocketmine\level\format\Chunk;
|
||||||
|
use pocketmine\nbt\NBT;
|
||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\Compound;
|
||||||
|
use pocketmine\network\protocol\EntityDataPacket;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
abstract class Spawnable extends Tile{
|
abstract class Spawnable extends Tile{
|
||||||
public abstract function spawnTo(Player $player);
|
|
||||||
|
public function spawnTo(Player $player){
|
||||||
|
if($this->closed){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
||||||
|
$nbt->setData($this->getSpawnCompound());
|
||||||
|
$pk = new EntityDataPacket;
|
||||||
|
$pk->x = $this->x;
|
||||||
|
$pk->y = $this->y;
|
||||||
|
$pk->z = $this->z;
|
||||||
|
$pk->namedtag = $nbt->write();
|
||||||
|
$player->dataPacket($pk);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract function getSpawnCompound();
|
||||||
|
|
||||||
public function __construct(Chunk $chunk, Compound $nbt){
|
public function __construct(Chunk $chunk, Compound $nbt){
|
||||||
parent::__construct($chunk, $nbt);
|
parent::__construct($chunk, $nbt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user