mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 07:09:56 +00:00
Merge branch master
This commit is contained in:
commit
a2641f923d
@ -21,6 +21,7 @@
|
||||
|
||||
namespace pocketmine;
|
||||
|
||||
use pocketmine\block\Air;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\entity\Arrow;
|
||||
@ -132,6 +133,7 @@ use pocketmine\tile\Tile;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use raklib\Binary;
|
||||
|
||||
|
||||
/**
|
||||
* Main class that handles networking, recovery, and packet sending to the server part
|
||||
*/
|
||||
@ -598,6 +600,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return $this->sleeping !== null;
|
||||
}
|
||||
|
||||
public function getInAirTicks(){
|
||||
return $this->inAirTicks;
|
||||
}
|
||||
|
||||
protected function switchLevel(Level $targetLevel){
|
||||
$oldLevel = $this->level;
|
||||
if(parent::switchLevel($targetLevel)){
|
||||
@ -2066,6 +2072,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->inventory->sendHeldItem($this);
|
||||
break;
|
||||
}
|
||||
$block = $target->getSide($packet->face);
|
||||
if($block->getId() === Block::FIRE){
|
||||
$this->level->setBlock($block, new Air());
|
||||
}
|
||||
$this->lastBreak = microtime(true);
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_ABORT_BREAK:
|
||||
@ -3470,9 +3480,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $chunkX
|
||||
* @param $chunkZ
|
||||
* @param $payload
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param string $payload
|
||||
* @param int $ordering
|
||||
*
|
||||
* @return DataPacket
|
||||
*/
|
||||
|
@ -75,8 +75,8 @@ namespace pocketmine {
|
||||
const VERSION = "1.6dev";
|
||||
const API_VERSION = "2.0.0";
|
||||
const CODENAME = "[REDACTED]";
|
||||
const MINECRAFT_VERSION = "v0.14.0.7 alpha";
|
||||
const MINECRAFT_VERSION_NETWORK = "0.14.0.7";
|
||||
const MINECRAFT_VERSION = "v0.14.0.0 alpha";
|
||||
const MINECRAFT_VERSION_NETWORK = "0.14.0.0";
|
||||
|
||||
/*
|
||||
* Startup code. Do not look at it, it may harm you.
|
||||
|
@ -972,6 +972,8 @@ class Server{
|
||||
* @param bool $forceUnload
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \InvalidStateException
|
||||
*/
|
||||
public function unloadLevel(Level $level, $forceUnload = false){
|
||||
if($level === $this->getDefaultLevel() and !$forceUnload){
|
||||
|
@ -22,6 +22,7 @@
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
|
||||
class DoubleWoodSlab extends Solid{
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace pocketmine\block;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\Tool;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\level\sound\DoorSound;
|
||||
use pocketmine\Player;
|
||||
|
||||
class IronTrapdoor extends Transparent{
|
||||
@ -153,4 +154,4 @@ class IronTrapdoor extends Transparent{
|
||||
public function getToolType(){
|
||||
return Tool::TYPE_PICKAXE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,9 @@ class TallGrass extends Flowable{
|
||||
|
||||
public function getDrops(Item $item){
|
||||
if(mt_rand(0, 15) === 0){
|
||||
return [Item::WHEAT_SEEDS, 0, 1];
|
||||
return [
|
||||
[Item::WHEAT_SEEDS, 0, 1]
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -44,6 +44,7 @@ class TeleportCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
$args = array_filter($args);
|
||||
if(count($args) < 1 or count($args) > 6){
|
||||
$sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
|
||||
|
||||
|
@ -83,7 +83,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
const DATA_SILENT = 4;
|
||||
const DATA_POTION_COLOR = 7;
|
||||
const DATA_POTION_AMBIENT = 8;
|
||||
const DATA_NO_AI = 15;
|
||||
const DATA_NO_AI = 15;
|
||||
|
||||
|
||||
const DATA_FLAG_ONFIRE = 0;
|
||||
@ -567,7 +567,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
|
||||
/**
|
||||
* @param Player[]|Player $player
|
||||
* @param array $data Properly formatted entity data, defaults to everything
|
||||
* @param array $data Properly formatted entity data, defaults to everything
|
||||
*/
|
||||
public function sendData($player, array $data = null){
|
||||
$pk = new SetEntityDataPacket();
|
||||
@ -598,23 +598,24 @@ abstract class Entity extends Location implements Metadatable{
|
||||
* @param EntityDamageEvent $source
|
||||
*
|
||||
*/
|
||||
public function attack($damage, EntityDamageEvent $source){
|
||||
if($this->hasEffect(Effect::FIRE_RESISTANCE)
|
||||
and $source->getCause() === EntityDamageEvent::CAUSE_FIRE
|
||||
and $source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK
|
||||
and $source->getCause() === EntityDamageEvent::CAUSE_LAVA){
|
||||
$source->setCancelled();
|
||||
}
|
||||
public function attack($damage, EntityDamageEvent $source){
|
||||
if($this->hasEffect(Effect::FIRE_RESISTANCE)
|
||||
and $source->getCause() === EntityDamageEvent::CAUSE_FIRE
|
||||
and $source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK
|
||||
and $source->getCause() === EntityDamageEvent::CAUSE_LAVA
|
||||
){
|
||||
$source->setCancelled();
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($source);
|
||||
if($source->isCancelled()){
|
||||
return;
|
||||
}
|
||||
$this->server->getPluginManager()->callEvent($source);
|
||||
if($source->isCancelled()){
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setLastDamageCause($source);
|
||||
$this->setLastDamageCause($source);
|
||||
|
||||
$this->setHealth($this->getHealth() - $source->getFinalDamage());
|
||||
}
|
||||
$this->setHealth($this->getHealth() - $source->getFinalDamage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $amount
|
||||
@ -622,13 +623,13 @@ abstract class Entity extends Location implements Metadatable{
|
||||
*
|
||||
*/
|
||||
public function heal($amount, EntityRegainHealthEvent $source){
|
||||
$this->server->getPluginManager()->callEvent($source);
|
||||
if($source->isCancelled()){
|
||||
return;
|
||||
}
|
||||
$this->server->getPluginManager()->callEvent($source);
|
||||
if($source->isCancelled()){
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setHealth($this->getHealth() + $source->getAmount());
|
||||
}
|
||||
$this->setHealth($this->getHealth() + $source->getAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
@ -781,7 +782,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
}
|
||||
|
||||
if($direction === 5){
|
||||
$this->motionY = $force;
|
||||
$this->motionZ = $force;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1555,7 +1556,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $propertyId;
|
||||
* @param int $propertyId
|
||||
* @param int $id
|
||||
* @param bool $value
|
||||
*/
|
||||
|
@ -72,12 +72,14 @@ class Item extends Entity{
|
||||
$this->thrower = $this->namedtag["Thrower"];
|
||||
}
|
||||
|
||||
assert($this->namedtag->Item instanceof CompoundTag);
|
||||
|
||||
if(!isset($this->namedtag->Item)){
|
||||
$this->close();
|
||||
return;
|
||||
}
|
||||
|
||||
assert($this->namedtag->Item instanceof CompoundTag);
|
||||
|
||||
$this->item = NBT::getItemHelper($this->namedtag->Item);
|
||||
|
||||
|
||||
|
@ -69,7 +69,7 @@ class CraftItemEvent extends Event implements Cancellable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \pocktemine\Player
|
||||
* @return \pocketmine\Player
|
||||
*/
|
||||
public function getPlayer(){
|
||||
return $this->player;
|
||||
|
@ -83,4 +83,11 @@ abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{
|
||||
public function getBlockClicked(){
|
||||
return $this->blockClicked;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockFace(){
|
||||
return $this->blockFace;
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
||||
private $keepInventory = false;
|
||||
|
||||
/**
|
||||
* @param Player $entity
|
||||
* @param Item[] $drops
|
||||
* @param Player $entity
|
||||
* @param Item[] $drops
|
||||
* @param string|TextContainer $deathMessage
|
||||
*/
|
||||
public function __construct(Player $entity, array $drops, $deathMessage){
|
||||
@ -50,6 +50,13 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
||||
return $this->entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getPlayer(){
|
||||
return $this->entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TextContainer|string
|
||||
*/
|
||||
|
@ -22,21 +22,11 @@
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
|
||||
use pocketmine\block\Planks;
|
||||
use pocketmine\block\Quartz;
|
||||
use pocketmine\block\Sandstone;
|
||||
use pocketmine\block\Slab;
|
||||
use pocketmine\block\Fence;
|
||||
use pocketmine\block\Stone;
|
||||
use pocketmine\block\StoneBricks;
|
||||
use pocketmine\block\StoneWall;
|
||||
use pocketmine\block\Wood;
|
||||
use pocketmine\block\Wood2;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\utils\UUID;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\Config;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\UUID;
|
||||
|
||||
class CraftingManager{
|
||||
|
||||
@ -55,7 +45,7 @@ class CraftingManager{
|
||||
// load recipes from src/pocketmine/recipes.json
|
||||
$recipes = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/recipes.json", Config::JSON, []);
|
||||
|
||||
MainLogger::getLogger()->Info("Loading recipes...");
|
||||
MainLogger::getLogger()->info("Loading recipes...");
|
||||
foreach($recipes->getAll() as $recipe){
|
||||
switch($recipe["Type"]){
|
||||
case 0:
|
||||
|
@ -2453,6 +2453,8 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @param bool $generate
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \InvalidStateException
|
||||
*/
|
||||
public function loadChunk(int $x, int $z, bool $generate = true) : bool{
|
||||
if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){
|
||||
@ -2599,7 +2601,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @return bool|Position
|
||||
*/
|
||||
public function getSafeSpawn($spawn = null){
|
||||
if(!($spawn instanceof Vector3) or $spawn->y <= 0){
|
||||
if(!($spawn instanceof Vector3) or $spawn->y < 1){
|
||||
$spawn = $this->getSpawnLocation();
|
||||
}
|
||||
if($spawn instanceof Vector3){
|
||||
|
@ -50,6 +50,7 @@ abstract class BaseLevelProvider implements LevelProvider{
|
||||
$levelData = $nbt->getData();
|
||||
if($levelData->Data instanceof CompoundTag){
|
||||
$this->levelData = $levelData->Data;
|
||||
assert(is_int($this->levelData["RandomSeed"]));
|
||||
}else{
|
||||
throw new LevelException("Invalid level.dat");
|
||||
}
|
||||
@ -126,4 +127,4 @@ abstract class BaseLevelProvider implements LevelProvider{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class McRegion extends BaseLevelProvider{
|
||||
"version" => new IntTag("version", 19133),
|
||||
"DayTime" => new IntTag("DayTime", 0),
|
||||
"LastPlayed" => new LongTag("LastPlayed", microtime(true) * 1000),
|
||||
"RandomSeed" => new LongTag("RandomSeed", $seed),
|
||||
"RandomSeed" => new LongTag("RandomSeed", (int) $seed),
|
||||
"SizeOnDisk" => new LongTag("SizeOnDisk", 0),
|
||||
"Time" => new LongTag("Time", 0),
|
||||
"generatorName" => new StringTag("generatorName", Generator::getGeneratorName($generator)),
|
||||
@ -324,4 +324,4 @@ class McRegion extends BaseLevelProvider{
|
||||
}
|
||||
$this->level = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ abstract class Generator{
|
||||
* @param int $z
|
||||
*
|
||||
* @return \SplFixedArray
|
||||
*
|
||||
* @throws \InvalidArgumentCountException
|
||||
*/
|
||||
public static function getFastNoise1D(Noise $noise, $xSize, $samplingRate, $x, $y, $z){
|
||||
if($samplingRate === 0){
|
||||
@ -116,6 +118,9 @@ abstract class Generator{
|
||||
* @param int $z
|
||||
*
|
||||
* @return \SplFixedArray
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \InvalidArgumentCountException
|
||||
*/
|
||||
public static function getFastNoise2D(Noise $noise, $xSize, $zSize, $samplingRate, $x, $y, $z){
|
||||
assert($samplingRate !== 0, new \InvalidArgumentException("samplingRate cannot be 0"));
|
||||
@ -166,6 +171,9 @@ abstract class Generator{
|
||||
* @param int $z
|
||||
*
|
||||
* @return \SplFixedArray
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \InvalidArgumentCountException
|
||||
*/
|
||||
public static function getFastNoise3D(Noise $noise, $xSize, $ySize, $zSize, $xSamplingRate, $ySamplingRate, $zSamplingRate, $x, $y, $z){
|
||||
|
||||
|
@ -29,7 +29,7 @@ class CompressBatchedTask extends AsyncTask{
|
||||
public $level = 7;
|
||||
public $data;
|
||||
public $final;
|
||||
public $targets = [];
|
||||
public $targets;
|
||||
|
||||
public function __construct($data, array $targets, $level = 7){
|
||||
$this->data = $data;
|
||||
@ -47,6 +47,6 @@ class CompressBatchedTask extends AsyncTask{
|
||||
}
|
||||
|
||||
public function onCompletion(Server $server){
|
||||
$server->broadcastPacketsCallback($this->final, $this->targets);
|
||||
$server->broadcastPacketsCallback($this->final, (array) $this->targets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,4 +49,4 @@ class ContainerSetSlotPacket extends DataPacket{
|
||||
$this->putSlot($this->item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,8 @@ interface Plugin extends CommandExecutor{
|
||||
public function isDisabled();
|
||||
|
||||
/**
|
||||
* Gets the plugin's data folder to save files and configuration
|
||||
* Gets the plugin's data folder to save files and configuration.
|
||||
* This directory name has a trailing slash.
|
||||
*/
|
||||
public function getDataFolder();
|
||||
|
||||
@ -111,4 +112,4 @@ interface Plugin extends CommandExecutor{
|
||||
*/
|
||||
public function getPluginLoader();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -251,8 +251,9 @@ abstract class PluginBase implements Plugin{
|
||||
|
||||
public function saveDefaultConfig(){
|
||||
if(!file_exists($this->configFile)){
|
||||
$this->saveResource("config.yml", false);
|
||||
return $this->saveResource("config.yml", false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function reloadConfig(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user