mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
Merge branch 'master' into mcpe-1.0
This commit is contained in:
commit
2930cf80b4
@ -1185,28 +1185,58 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: This method does NOT return literal gamemode is survival, it will also return true for adventure mode players.
|
||||
* NOTE: Because Survival and Adventure Mode share some similar behaviour, this method will also return true if the player is
|
||||
* in Adventure Mode. Supply the $literal parameter as true to force a literal Survival Mode check.
|
||||
*
|
||||
* @param bool $literal whether a literal check should be performed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSurvival() : bool{
|
||||
return ($this->gamemode & 0x01) === 0;
|
||||
public function isSurvival(bool $literal = false) : bool{
|
||||
if($literal){
|
||||
return $this->gamemode === Player::SURVIVAL;
|
||||
}else{
|
||||
return ($this->gamemode & 0x01) === 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: This method does NOT return literal gamemode is creative, it will also return true for spectator mode players.
|
||||
* NOTE: Because Creative and Spectator Mode share some similar behaviour, this method will also return true if the player is
|
||||
* in Spectator Mode. Supply the $literal parameter as true to force a literal Creative Mode check.
|
||||
*
|
||||
* @param bool $literal whether a literal check should be performed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCreative() : bool{
|
||||
return ($this->gamemode & 0x01) === 1;
|
||||
public function isCreative(bool $literal = false) : bool{
|
||||
if($literal){
|
||||
return $this->gamemode === Player::CREATIVE;
|
||||
}else{
|
||||
return ($this->gamemode & 0x01) === 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: This method does NOT return literal gamemode is adventure, it will also return true for spectator mode players.
|
||||
* NOTE: Because Adventure and Spectator Mode share some similar behaviour, this method will also return true if the player is
|
||||
* in Spectator Mode. Supply the $literal parameter as true to force a literal Adventure Mode check.
|
||||
*
|
||||
* @param bool $literal whether a literal check should be performed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAdventure() : bool{
|
||||
return ($this->gamemode & 0x02) > 0;
|
||||
public function isAdventure(bool $literal = false) : bool{
|
||||
if($literal){
|
||||
return $this->gamemode === Player::ADVENTURE;
|
||||
}else{
|
||||
return ($this->gamemode & 0x02) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSpectator() : bool{
|
||||
return $this->gamemode === 3;
|
||||
return $this->gamemode === Player::SPECTATOR;
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
@ -2622,6 +2652,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var int $i
|
||||
* @var Item $item
|
||||
*/
|
||||
foreach($packet->input as $i => $item){
|
||||
if($item->getDamage() === -1 or $item->getDamage() === 0xffff){
|
||||
$item->setDamage(null);
|
||||
@ -2694,8 +2728,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
foreach($ingredients as $ingredient){
|
||||
$slot = -1;
|
||||
foreach($this->inventory->getContents() as $index => $i){
|
||||
if($ingredient->getId() !== 0 and $ingredient->deepEquals($i, $ingredient->getDamage() !== null) and ($i->getCount() - $used[$index]) >= 1){
|
||||
foreach($this->inventory->getContents() as $index => $item){
|
||||
if($ingredient->getId() !== 0 and $ingredient->deepEquals($item, $ingredient->getDamage() !== null) and ($item->getCount() - $used[$index]) >= 1){
|
||||
$slot = $index;
|
||||
$used[$index]++;
|
||||
break;
|
||||
@ -3115,6 +3149,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
/**
|
||||
* Handles player data saving
|
||||
*
|
||||
* @param bool $async
|
||||
*/
|
||||
public function save($async = false){
|
||||
if($this->closed){
|
||||
|
@ -185,7 +185,6 @@ class Server{
|
||||
|
||||
/** @var CommandReader */
|
||||
private $console = null;
|
||||
private $consoleThreaded;
|
||||
|
||||
/** @var SimpleCommandMap */
|
||||
private $commandMap = null;
|
||||
|
@ -59,7 +59,7 @@ class Ladder extends Transparent{
|
||||
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$f = 0.125;
|
||||
$f = 0.1875;
|
||||
|
||||
if($this->meta === 2){
|
||||
return new AxisAlignedBB(
|
||||
|
@ -21,10 +21,19 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\level\Level;
|
||||
|
||||
class StillLava extends Lava{
|
||||
|
||||
protected $id = self::STILL_LAVA;
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type !== Level::BLOCK_UPDATE_SCHEDULED){
|
||||
return parent::onUpdate($type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Still Lava";
|
||||
}
|
||||
|
@ -21,10 +21,19 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\level\Level;
|
||||
|
||||
class StillWater extends Water{
|
||||
|
||||
protected $id = self::STILL_WATER;
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type !== Level::BLOCK_UPDATE_SCHEDULED){
|
||||
return parent::onUpdate($type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return "Still Water";
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class BanListCommand extends VanillaCommand{
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
$list = $sender->getServer()->getNameBans();
|
||||
|
||||
if(isset($args[0])){
|
||||
$args[0] = strtolower($args[0]);
|
||||
if($args[0] === "ips"){
|
||||
|
@ -123,8 +123,13 @@ class ParticleCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param string $name
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
* @param int $xd
|
||||
* @param float $yd
|
||||
* @param float $zd
|
||||
* @param int|null $data
|
||||
* @return Particle
|
||||
*/
|
||||
private function getParticle($name, Vector3 $pos, $xd, $yd, $zd, $data){
|
||||
|
@ -104,8 +104,8 @@ abstract class Entity extends Location implements Metadatable{
|
||||
* 53 (unknown) */
|
||||
const DATA_BOUNDING_BOX_WIDTH = 54; //float
|
||||
const DATA_BOUNDING_BOX_HEIGHT = 55; //float
|
||||
/* 56 (unknown)
|
||||
* 57 (vector3f)
|
||||
const DATA_FUSE_LENGTH = 56; //int
|
||||
/* 57 (vector3f)
|
||||
* 58 (byte)
|
||||
* 59 (float)
|
||||
* 60 (float) */
|
||||
@ -1610,6 +1610,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
* @param int $id
|
||||
* @param int $type
|
||||
* @param mixed $value
|
||||
* @param bool $send
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -236,7 +236,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
}
|
||||
|
||||
public function recalculateXpProgress() : float{
|
||||
$this->setXpProgress($this->getRemainderXp() / self::getTotalXpForLevel($this->getXpLevel()));
|
||||
$this->setXpProgress($progress = $this->getRemainderXp() / self::getTotalXpForLevel($this->getXpLevel()));
|
||||
return $progress;
|
||||
}
|
||||
|
||||
public static function getTotalXpForLevel(int $level) : int{
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -15,7 +15,7 @@
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -57,6 +57,9 @@ class PrimedTNT extends Entity implements Explosive{
|
||||
}else{
|
||||
$this->fuse = 80;
|
||||
}
|
||||
|
||||
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_IGNITED, true);
|
||||
$this->setDataProperty(self::DATA_FUSE_LENGTH, self::DATA_TYPE_INT, $this->fuse);
|
||||
}
|
||||
|
||||
|
||||
@ -81,6 +84,11 @@ class PrimedTNT extends Entity implements Explosive{
|
||||
if($tickDiff <= 0 and !$this->justCreated){
|
||||
return true;
|
||||
}
|
||||
|
||||
if($this->fuse % 5 === 0){ //don't spam it every tick, it's not necessary
|
||||
$this->setDataProperty(self::DATA_FUSE_LENGTH, self::DATA_TYPE_INT, $this->fuse);
|
||||
}
|
||||
|
||||
$this->lastUpdate = $currentTick;
|
||||
|
||||
$hasUpdate = $this->entityBaseTick($tickDiff);
|
||||
|
@ -63,8 +63,6 @@ abstract class Event{
|
||||
/**
|
||||
* @param bool $value
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function setCancelled($value = true){
|
||||
|
@ -68,7 +68,7 @@ interface Inventory{
|
||||
*
|
||||
* Returns the Items that did not fit.
|
||||
*
|
||||
* @param Item ...$item
|
||||
* @param Item ...$slots
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
@ -87,7 +87,7 @@ interface Inventory{
|
||||
* Removes the given Item from the inventory.
|
||||
* It will return the Items that couldn't be removed.
|
||||
*
|
||||
* @param Item ...$item
|
||||
* @param Item ...$slots
|
||||
*
|
||||
* @return Item[]
|
||||
*/
|
||||
|
@ -36,4 +36,6 @@ interface Recipe{
|
||||
* @return UUID
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
public function setId(UUID $id);
|
||||
}
|
@ -35,6 +35,7 @@ use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\nbt\tag\Tag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Config;
|
||||
@ -594,6 +595,10 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return Tag|null
|
||||
*/
|
||||
public function getNamedTagEntry($name){
|
||||
$tag = $this->getNamedTag();
|
||||
if($tag !== null){
|
||||
|
@ -89,8 +89,9 @@ class BaseLang{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
* @param string[] $params
|
||||
* @param string $str
|
||||
* @param string[] $params
|
||||
* @param string|null $onlyPrefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -29,6 +29,7 @@ use pocketmine\event\entity\EntityDamageByEntityEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityExplodeEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\particle\HugeExplodeSeedParticle;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Math;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -221,6 +222,8 @@ class Explosion{
|
||||
$pk->records = $send;
|
||||
$this->level->addChunkPacket($source->x >> 4, $source->z >> 4, $pk);
|
||||
|
||||
$this->level->addParticle(new HugeExplodeSeedParticle($source));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -285,6 +285,11 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|int $hash
|
||||
* @param int|null $x
|
||||
* @param int|null $z
|
||||
*/
|
||||
public static function getXZ($hash, &$x, &$z){
|
||||
if(PHP_INT_SIZE === 8){
|
||||
$x = $hash >> 32;
|
||||
@ -1757,7 +1762,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
* Returns the entities colliding the current one inside the AxisAlignedBB
|
||||
*
|
||||
* @param AxisAlignedBB $bb
|
||||
* @param Entity $entity
|
||||
* @param Entity|null $entity
|
||||
*
|
||||
* @return Entity[]
|
||||
*/
|
||||
@ -2267,8 +2272,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
if(count($this->chunkSendQueue) > 0){
|
||||
$this->timings->syncChunkSendTimer->startTiming();
|
||||
|
||||
$x = null;
|
||||
$z = null;
|
||||
foreach($this->chunkSendQueue as $index => $players){
|
||||
if(isset($this->chunkSendTasks[$index])){
|
||||
continue;
|
||||
@ -2730,9 +2733,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
public function doChunkGarbageCollection(){
|
||||
$this->timings->doChunkGC->startTiming();
|
||||
|
||||
$X = null;
|
||||
$Z = null;
|
||||
|
||||
foreach($this->chunks as $index => $chunk){
|
||||
if(!isset($this->unloadQueue[$index]) and (!isset($this->usedChunks[$index]) or count($this->usedChunks[$index]) === 0)){
|
||||
Level::getXZ($index, $X, $Z);
|
||||
|
@ -50,9 +50,11 @@ class Location extends Position{
|
||||
* @param Level|null $level default null
|
||||
* @param float $yaw default 0.0
|
||||
* @param float $pitch default 0.0
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public static function fromObject(Vector3 $pos, Level $level = null, $yaw = 0.0, $pitch = 0.0){
|
||||
return new Location($pos->x, $pos->y, $pos->z, $yaw, $pitch, ($level === null) ? (($pos instanceof Position) ? $pos->level : null) : $level);
|
||||
return new Location($pos->x, $pos->y, $pos->z, $yaw, $pitch, $level ?? (($pos instanceof Position) ? $pos->level : null));
|
||||
}
|
||||
|
||||
public function getYaw(){
|
||||
|
@ -30,8 +30,8 @@ abstract class Particle extends Vector3{
|
||||
const TYPE_CRITICAL = 2;
|
||||
const TYPE_BLOCK_FORCE_FIELD = 3;
|
||||
const TYPE_SMOKE = 4;
|
||||
const TYPE_EXPLODE = 5; //actually steam
|
||||
const TYPE_WHITE_SMOKE = 6; //also steam, maybe bigger?
|
||||
const TYPE_EXPLODE = 5;
|
||||
const TYPE_EVAPORATION = 6;
|
||||
const TYPE_FLAME = 7;
|
||||
const TYPE_LAVA = 8;
|
||||
const TYPE_LARGE_SMOKE = 9;
|
||||
@ -62,7 +62,7 @@ abstract class Particle extends Vector3{
|
||||
const TYPE_ENCHANTMENT_TABLE = 34;
|
||||
const TYPE_TRACKING_EMITTER = 35;
|
||||
const TYPE_NOTE = 36;
|
||||
//37 yet another SpellParticle of some description
|
||||
const TYPE_WITCH_SPELL = 37;
|
||||
const TYPE_CARROT = 38;
|
||||
//39 unknown
|
||||
const TYPE_END_ROD = 40;
|
||||
|
@ -34,14 +34,13 @@ use pocketmine\nbt\tag\IntArrayTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\LongTag;
|
||||
use pocketmine\nbt\tag\NamedTAG;
|
||||
use pocketmine\nbt\tag\NamedTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\nbt\tag\Tag;
|
||||
|
||||
#ifndef COMPILE
|
||||
use pocketmine\utils\Binary;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -532,7 +531,7 @@ class NBT{
|
||||
|
||||
public function writeTag(Tag $tag, bool $network = false){
|
||||
$this->putByte($tag->getType());
|
||||
if($tag instanceof NamedTAG){
|
||||
if($tag instanceof NamedTag){
|
||||
$this->putString($tag->getName(), $network);
|
||||
}
|
||||
$tag->write($this, $network);
|
||||
@ -610,6 +609,7 @@ class NBT{
|
||||
public function getArray(){
|
||||
$data = [];
|
||||
self::toArray($data, $this->data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
private static function toArray(array &$data, Tag $tag){
|
||||
@ -681,4 +681,4 @@ class NBT{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -207,6 +207,8 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{
|
||||
foreach($tags as $tag){
|
||||
$tag->write($nbt, $network);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
|
@ -173,13 +173,13 @@ class Permission{
|
||||
* @param string|Permission $name
|
||||
* @param $value
|
||||
*
|
||||
* @return Permission|void Permission if $name is a string, void if it's a Permission
|
||||
* @return Permission|null Permission if $name is a string, null if it's a Permission
|
||||
*/
|
||||
public function addParent($name, $value){
|
||||
if($name instanceof Permission){
|
||||
$name->getChildren()[$this->getName()] = $value;
|
||||
$name->recalculatePermissibles();
|
||||
return;
|
||||
return null;
|
||||
}else{
|
||||
$perm = Server::getInstance()->getPluginManager()->getPermission($name);
|
||||
if($perm === null){
|
||||
|
@ -89,9 +89,6 @@ class PermissionAttachment{
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool[]
|
||||
*/
|
||||
public function clearPermissions(){
|
||||
$this->permissions = [];
|
||||
$this->permissible->recalculatePermissions();
|
||||
|
@ -259,7 +259,7 @@ abstract class PluginBase implements Plugin{
|
||||
public function reloadConfig(){
|
||||
$this->config = new Config($this->configFile);
|
||||
if(($configStream = $this->getResource("config.yml")) !== null){
|
||||
$this->config->setDefaults(yaml_parse(config::fixYAMLIndexes(stream_get_contents($configStream))));
|
||||
$this->config->setDefaults(yaml_parse(Config::fixYAMLIndexes(stream_get_contents($configStream))));
|
||||
fclose($configStream);
|
||||
}
|
||||
}
|
||||
|
@ -277,18 +277,6 @@ class ServerScheduler{
|
||||
}elseif(!$task->getOwner()->isEnabled()){
|
||||
throw new PluginException("Plugin '" . $task->getOwner()->getName() . "' attempted to register a task while disabled");
|
||||
}
|
||||
}elseif($task instanceof CallbackTask and Server::getInstance()->getProperty("settings.deprecated-verbose", true)){
|
||||
$callable = $task->getCallable();
|
||||
if(is_array($callable)){
|
||||
if(is_object($callable[0])){
|
||||
$taskName = "Callback#" . get_class($callable[0]) . "::" . $callable[1];
|
||||
}else{
|
||||
$taskName = "Callback#" . $callable[0] . "::" . $callable[1];
|
||||
}
|
||||
}else{
|
||||
$taskName = "Callback#" . $callable;
|
||||
}
|
||||
Server::getInstance()->getLogger()->warning("A plugin attempted to register a deprecated CallbackTask ($taskName)");
|
||||
}
|
||||
|
||||
if($delay <= 0){
|
||||
|
@ -22,7 +22,6 @@
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Network;
|
||||
|
||||
interface Container{
|
||||
|
||||
|
@ -168,6 +168,8 @@ class Utils{
|
||||
* BSD => bsd
|
||||
* Other => other
|
||||
*
|
||||
* @param bool $recalculate
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getOS($recalculate = false){
|
||||
|
Loading…
x
Reference in New Issue
Block a user