mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-27 13:49:55 +00:00
A few fixes!
This commit is contained in:
parent
652987110a
commit
add380c7ed
@ -1802,6 +1802,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
case 0: //Start break
|
case 0: //Start break
|
||||||
$target = $this->level->getBlock(new Vector3($packet->x, $packet->y, $packet->z));
|
$target = $this->level->getBlock(new Vector3($packet->x, $packet->y, $packet->z));
|
||||||
$ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $target, $packet->face, $target->getId() === 0 ? PlayerInteractEvent::LEFT_CLICK_AIR : PlayerInteractEvent::LEFT_CLICK_BLOCK);
|
$ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $target, $packet->face, $target->getId() === 0 ? PlayerInteractEvent::LEFT_CLICK_AIR : PlayerInteractEvent::LEFT_CLICK_BLOCK);
|
||||||
|
$this->getServer()->getPluginManager()->callEvent($ev);
|
||||||
|
if($ev->isCancelled()){
|
||||||
|
$this->inventory->sendHeldItem($this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
$this->lastBreak = microtime(true);
|
$this->lastBreak = microtime(true);
|
||||||
break;
|
break;
|
||||||
case 5: //Shot arrow
|
case 5: //Shot arrow
|
||||||
@ -2066,7 +2071,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
|
|
||||||
$this->teleport($ev->getRespawnPosition());
|
$this->teleport($ev->getRespawnPosition());
|
||||||
|
|
||||||
$this->fireTicks = 0;
|
$this->extinguish();
|
||||||
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
|
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
|
||||||
$this->deadTicks = 0;
|
$this->deadTicks = 0;
|
||||||
$this->noDamageTicks = 60;
|
$this->noDamageTicks = 60;
|
||||||
|
@ -315,7 +315,7 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function getServerName(){
|
public function getServerName(){
|
||||||
return $this->getConfigString("motd", "Minecraft: PE Server");
|
return $this->getConfigString("motd", "Minecraft: PE Server");
|
||||||
@ -2211,14 +2211,36 @@ class Server{
|
|||||||
" | Load " . $this->getTickUsage() . "%\x07";
|
" | Load " . $this->getTickUsage() . "%\x07";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMemoryUsage(){
|
public function getMemoryUsage($advanced = false){
|
||||||
|
$VmSize = null;
|
||||||
|
$VmHWM = null;
|
||||||
if(Utils::getOS() === "linux" or Utils::getOS() === "bsd"){
|
if(Utils::getOS() === "linux" or Utils::getOS() === "bsd"){
|
||||||
if(preg_match("/VmSize:[ \t]+([0-9]+) kB/", file_get_contents("/proc/self/status"), $matches) > 0){
|
$status = file_get_contents("/proc/self/status");
|
||||||
return $matches[1] * 1024;
|
if(preg_match("/VmHWM:[ \t]+([0-9]+) kB/", $status, $matches) > 0){
|
||||||
|
$VmHWM = $matches[1] * 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(preg_match("/VmData:[ \t]+([0-9]+) kB/", $status, $matches) > 0){
|
||||||
|
$VmData = $matches[1] * 1024;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return memory_get_usage(true);
|
if($VmHWM === null){
|
||||||
|
$VmHWM = memory_get_usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$advanced){
|
||||||
|
return $VmHWM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($VmSize === null){
|
||||||
|
$VmSize = memory_get_usage(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
"hardware" => $VmHWM,
|
||||||
|
"virtual" => $VmSize,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getThreadCount(){
|
public function getThreadCount(){
|
||||||
|
@ -736,6 +736,7 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
if($this->fireTicks <= 0){
|
if($this->fireTicks <= 0){
|
||||||
$this->extinguish();
|
$this->extinguish();
|
||||||
}else{
|
}else{
|
||||||
|
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ONFIRE, true);
|
||||||
$hasUpdate = true;
|
$hasUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -844,11 +845,6 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
if($ticks > $this->fireTicks){
|
if($ticks > $this->fireTicks){
|
||||||
$this->fireTicks = $ticks;
|
$this->fireTicks = $ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sendMetadata($this->hasSpawned);
|
|
||||||
if($this instanceof Player){
|
|
||||||
$this->sendMetadata($this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDirection(){
|
public function getDirection(){
|
||||||
@ -871,10 +867,7 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
|
|
||||||
public function extinguish(){
|
public function extinguish(){
|
||||||
$this->fireTicks = 0;
|
$this->fireTicks = 0;
|
||||||
$this->sendMetadata($this->hasSpawned);
|
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ONFIRE, false);
|
||||||
if($this instanceof Player){
|
|
||||||
$this->sendMetadata($this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canTriggerWalking(){
|
public function canTriggerWalking(){
|
||||||
|
@ -146,7 +146,7 @@ class PlayerInventory extends BaseInventory{
|
|||||||
|
|
||||||
foreach($target as $player){
|
foreach($target as $player){
|
||||||
if($player === $this->getHolder()){
|
if($player === $this->getHolder()){
|
||||||
$this->sendSlot($this->getHeldItemSlot());
|
$this->sendSlot($this->getHeldItemSlot(), $player);
|
||||||
}else{
|
}else{
|
||||||
$player->dataPacket($pk);
|
$player->dataPacket($pk);
|
||||||
}
|
}
|
||||||
|
@ -1404,6 +1404,8 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}elseif($target->canBeActivated() === true and $target->onActivate($item, $player) === true){
|
}elseif($target->canBeActivated() === true and $target->onActivate($item, $player) === true){
|
||||||
return true;
|
return true;
|
||||||
|
@ -88,12 +88,12 @@ class Flat extends Generator{
|
|||||||
$blocks = isset($preset[1]) ? $preset[1] : "";
|
$blocks = isset($preset[1]) ? $preset[1] : "";
|
||||||
$biome = isset($preset[2]) ? $preset[2] : 1;
|
$biome = isset($preset[2]) ? $preset[2] : 1;
|
||||||
$options = isset($preset[3]) ? $preset[3] : "";
|
$options = isset($preset[3]) ? $preset[3] : "";
|
||||||
preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches);
|
preg_match_all('#^(([0-9]*x|)([0-9]{1,3})(|:[0-9]{0,2}))$#m', str_replace(",", "\n", $blocks), $matches);
|
||||||
$y = 0;
|
$y = 0;
|
||||||
$this->structure = [];
|
$this->structure = [];
|
||||||
$this->chunks = [];
|
$this->chunks = [];
|
||||||
foreach($matches[3] as $i => $b){
|
foreach($matches[3] as $i => $b){
|
||||||
$b = Item::fromString($b);
|
$b = Item::fromString($b . $matches[4][$i]);
|
||||||
$cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]);
|
$cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]);
|
||||||
for($cY = $y, $y += $cnt; $cY < $y; ++$cY){
|
for($cY = $y, $y += $cnt; $cY < $y; ++$cY){
|
||||||
$this->structure[$cY] = [$b->getId(), $b->getDamage()];
|
$this->structure[$cY] = [$b->getId(), $b->getDamage()];
|
||||||
@ -107,11 +107,16 @@ class Flat extends Generator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->chunk = $this->level->getChunk(0, 0);
|
$chunk = $this->level->getChunk(0, 0);
|
||||||
|
if($chunk === null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->chunk = clone $chunk;
|
||||||
$this->chunk->setGenerated();
|
$this->chunk->setGenerated();
|
||||||
|
|
||||||
for($Z = 0; $Z < 16; ++$Z){
|
for($Z = 0; $Z < 16; ++$Z){
|
||||||
for($X = 0; $X < 16; ++$X){
|
for($X = 0; $X < 16; ++$X){
|
||||||
|
$this->chunk->setBiomeId($X, $Z, $biome);
|
||||||
for($y = 0; $y < 128; ++$y){
|
for($y = 0; $y < 128; ++$y){
|
||||||
$this->chunk->setBlock($X, $y, $Z, ...$this->structure[$y]);
|
$this->chunk->setBlock($X, $y, $Z, ...$this->structure[$y]);
|
||||||
}
|
}
|
||||||
|
@ -79,10 +79,10 @@ class FloatingTextParticle extends Particle{
|
|||||||
|
|
||||||
$pk = new AddPlayerPacket();
|
$pk = new AddPlayerPacket();
|
||||||
$pk->eid = $this->entityId;
|
$pk->eid = $this->entityId;
|
||||||
$pk->username = $this->title . "\n" . $this->text;
|
$pk->username = $this->title . ($this->text !== "" ? "\n" . $this->text : "");
|
||||||
$pk->clientID = $this->entityId;
|
$pk->clientID = $this->entityId;
|
||||||
$pk->x = $this->x;
|
$pk->x = $this->x;
|
||||||
$pk->y = $this->y - 2;
|
$pk->y = $this->y - 2.5;
|
||||||
$pk->z = $this->z;
|
$pk->z = $this->z;
|
||||||
$pk->yaw = 0;
|
$pk->yaw = 0;
|
||||||
$pk->pitch = 0;
|
$pk->pitch = 0;
|
||||||
|
@ -26,6 +26,6 @@ use pocketmine\math\Vector3;
|
|||||||
|
|
||||||
class TerrainParticle extends GenericParticle{
|
class TerrainParticle extends GenericParticle{
|
||||||
public function __construct(Vector3 $pos, Block $b){
|
public function __construct(Vector3 $pos, Block $b){
|
||||||
parent::__construct($pos, 15, ($b->getId() << 8) | $b->getDamage());
|
parent::__construct($pos, 15, ($b->getDamage() << 8) | $b->getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ class Vector3{
|
|||||||
public function floor(){
|
public function floor(){
|
||||||
$x = (int) $this->x;
|
$x = (int) $this->x;
|
||||||
$z = (int) $this->z;
|
$z = (int) $this->z;
|
||||||
return new Vector3($this->x >= $x ? $x : $x - 1, round($this->y), $this->z >= $z ? $z : $z - 1);
|
return new Vector3($this->x >= $x ? $x : $x - 1, (int) round($this->y), $this->z >= $z ? $z : $z - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function round(){
|
public function round(){
|
||||||
@ -228,6 +228,10 @@ class Vector3{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function equals(Vector3 $v){
|
||||||
|
return $this->x == $v->x and $this->y == $v->y and $this->z == $v->z;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new vector with x value equal to the second parameter, along the line between this vector and the
|
* Returns a new vector with x value equal to the second parameter, along the line between this vector and the
|
||||||
* passed in vector, or null if not possible.
|
* passed in vector, or null if not possible.
|
||||||
|
@ -83,7 +83,6 @@ class Config{
|
|||||||
public function reload(){
|
public function reload(){
|
||||||
$this->config = [];
|
$this->config = [];
|
||||||
$this->correct = false;
|
$this->correct = false;
|
||||||
unset($this->type);
|
|
||||||
$this->load($this->file);
|
$this->load($this->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user