mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 19:28:55 +00:00
Resolved 1️⃣ in #3961
This commit is contained in:
parent
05530bedc6
commit
80250aa78e
@ -21,6 +21,7 @@
|
||||
|
||||
namespace pocketmine;
|
||||
|
||||
use pocketmine\block\Air;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\entity\Arrow;
|
||||
@ -76,11 +77,9 @@ use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\inventory\ShapedRecipe;
|
||||
use pocketmine\inventory\ShapelessRecipe;
|
||||
use pocketmine\inventory\SimpleTransactionGroup;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\ChunkLoader;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\level\format\LevelProvider;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Location;
|
||||
use pocketmine\level\Position;
|
||||
@ -93,13 +92,12 @@ use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\ByteTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\DoubleTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\LongTag;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\Network;
|
||||
use pocketmine\network\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\protocol\AnimatePacket;
|
||||
use pocketmine\network\protocol\BatchPacket;
|
||||
@ -110,20 +108,19 @@ use pocketmine\network\protocol\DisconnectPacket;
|
||||
use pocketmine\network\protocol\EntityEventPacket;
|
||||
use pocketmine\network\protocol\FullChunkDataPacket;
|
||||
use pocketmine\network\protocol\Info as ProtocolInfo;
|
||||
use pocketmine\network\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\protocol\PlayStatusPacket;
|
||||
use pocketmine\network\protocol\RespawnPacket;
|
||||
use pocketmine\network\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\protocol\TextPacket;
|
||||
|
||||
use pocketmine\network\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\protocol\SetDifficultyPacket;
|
||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\network\protocol\SetHealthPacket;
|
||||
use pocketmine\network\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\protocol\SetSpawnPositionPacket;
|
||||
use pocketmine\network\protocol\SetTimePacket;
|
||||
use pocketmine\network\protocol\StartGamePacket;
|
||||
use pocketmine\network\protocol\TakeItemEntityPacket;
|
||||
use pocketmine\network\protocol\TextPacket;
|
||||
use pocketmine\network\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\SourceInterface;
|
||||
use pocketmine\permission\PermissibleBase;
|
||||
@ -133,10 +130,9 @@ use pocketmine\tile\Sign;
|
||||
use pocketmine\tile\Spawnable;
|
||||
use pocketmine\tile\Tile;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
|
||||
use raklib\Binary;
|
||||
|
||||
|
||||
/**
|
||||
* Main class that handles networking, recovery, and packet sending to the server part
|
||||
*/
|
||||
@ -221,7 +217,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
protected $viewDistance;
|
||||
protected $chunksPerTick;
|
||||
protected $spawnThreshold;
|
||||
protected $spawnThreshold;
|
||||
/** @var null|Position */
|
||||
private $spawnPosition = null;
|
||||
|
||||
@ -505,7 +501,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->clientID = $clientID;
|
||||
$this->loaderId = Level::generateChunkLoaderId($this);
|
||||
$this->chunksPerTick = (int) $this->server->getProperty("chunk-sending.per-tick", 4);
|
||||
$this->spawnThreshold = (int) $this->server->getProperty("chunk-sending.spawn-threshold", 56);
|
||||
$this->spawnThreshold = (int) $this->server->getProperty("chunk-sending.spawn-threshold", 56);
|
||||
$this->spawnPosition = null;
|
||||
$this->gamemode = $this->server->getGamemode();
|
||||
$this->setLevel($this->server->getDefaultLevel());
|
||||
@ -559,9 +555,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return $this->displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setDisplayName($name){
|
||||
$this->displayName = $name;
|
||||
if($this->spawned){
|
||||
@ -1906,13 +1902,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){
|
||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
||||
$this->inventory->setHeldItemSlot($packet->slot);
|
||||
}else{
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){
|
||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
||||
$this->inventory->setHeldItemSlot($packet->slot);
|
||||
}else{
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}elseif($item === null or $slot === -1 or !$item->deepEquals($packet->item)){ // packet error or not implemented
|
||||
$this->inventory->sendContents($this);
|
||||
@ -1922,13 +1918,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->inventory->setItem($packet->selectedSlot, $item);
|
||||
$this->inventory->setHeldItemSlot($packet->selectedSlot);
|
||||
}else{
|
||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){
|
||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
||||
$this->inventory->setHeldItemSlot($slot);
|
||||
}else{
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){
|
||||
$this->inventory->setHeldItemIndex($packet->selectedSlot);
|
||||
$this->inventory->setHeldItemSlot($slot);
|
||||
}else{
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
||||
@ -2062,6 +2058,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:
|
||||
@ -2069,9 +2069,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_RELEASE_ITEM:
|
||||
if($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)){
|
||||
if($this->inventory->getItemInHand()->getId() === Item::BOW) {
|
||||
if($this->inventory->getItemInHand()->getId() === Item::BOW){
|
||||
$bow = $this->inventory->getItemInHand();
|
||||
if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, 0, 1))) {
|
||||
if($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, 0, 1))){
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
@ -2100,35 +2100,35 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$f = min((($p ** 2) + $p * 2) / 3, 1) * 2;
|
||||
$ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
|
||||
|
||||
if ($f < 0.1 or $diff < 5) {
|
||||
if($f < 0.1 or $diff < 5){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
|
||||
if ($ev->isCancelled()) {
|
||||
if($ev->isCancelled()){
|
||||
$ev->getProjectile()->kill();
|
||||
$this->inventory->sendContents($this);
|
||||
} else {
|
||||
}else{
|
||||
$ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
|
||||
if($this->isSurvival()){
|
||||
$this->inventory->removeItem(Item::get(Item::ARROW, 0, 1));
|
||||
$bow->setDamage($bow->getDamage() + 1);
|
||||
if ($bow->getDamage() >= 385) {
|
||||
if($bow->getDamage() >= 385){
|
||||
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
|
||||
} else {
|
||||
}else{
|
||||
$this->inventory->setItemInHand($bow);
|
||||
}
|
||||
}
|
||||
if ($ev->getProjectile() instanceof Projectile) {
|
||||
if($ev->getProjectile() instanceof Projectile){
|
||||
$this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
|
||||
if ($projectileEv->isCancelled()) {
|
||||
if($projectileEv->isCancelled()){
|
||||
$ev->getProjectile()->kill();
|
||||
} else {
|
||||
}else{
|
||||
$ev->getProjectile()->spawnToAll();
|
||||
$this->level->addSound(new LaunchSound($this), $this->getViewers());
|
||||
}
|
||||
} else {
|
||||
}else{
|
||||
$ev->getProjectile()->spawnToAll();
|
||||
}
|
||||
}
|
||||
@ -2146,7 +2146,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->dataPacket($pk);
|
||||
Server::broadcastPacket($this->getViewers(), $pk);
|
||||
|
||||
if ($this->isSurvival()) {
|
||||
if($this->isSurvival()){
|
||||
$slot = $this->inventory->getItemInHand();
|
||||
--$slot->count;
|
||||
$this->inventory->setItemInHand($slot);
|
||||
@ -2274,7 +2274,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
$this->level->sendBlocks([$this], [$target], UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||
|
||||
$this->inventory->sendHeldItem($this);
|
||||
$this->inventory->sendHeldItem($this);
|
||||
|
||||
if($tile instanceof Spawnable){
|
||||
$tile->spawnTo($this);
|
||||
@ -2481,7 +2481,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
if(is_array($amount)){
|
||||
$amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0;
|
||||
}
|
||||
$ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING);
|
||||
$ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING);
|
||||
$this->heal($ev->getAmount(), $ev);
|
||||
|
||||
--$slot->count;
|
||||
@ -2645,7 +2645,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$result = $packet->output[0];
|
||||
|
||||
if(!$canCraft or !$recipe->getResult()->deepEquals($result)){
|
||||
$this->server->getLogger()->debug("Unmatched recipe ". $recipe->getId() ." from player ". $this->getName() .": expected " . $recipe->getResult() . ", got ". $result .", using: " . implode(", ", $ingredients));
|
||||
$this->server->getLogger()->debug("Unmatched recipe " . $recipe->getId() . " from player " . $this->getName() . ": expected " . $recipe->getResult() . ", got " . $result . ", using: " . implode(", ", $ingredients));
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
@ -2669,7 +2669,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
if(!$canCraft){
|
||||
$this->server->getLogger()->debug("Unmatched recipe ". $recipe->getId() ." from player ". $this->getName() .": client does not have enough items, using: " . implode(", ", $ingredients));
|
||||
$this->server->getLogger()->debug("Unmatched recipe " . $recipe->getId() . " from player " . $this->getName() . ": client does not have enough items, using: " . implode(", ", $ingredients));
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}
|
||||
@ -2883,11 +2883,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerKickEvent($this, $reason, $this->getLeaveMessage()));
|
||||
if(!$ev->isCancelled()){
|
||||
if($isAdmin){
|
||||
if(!$this->isBanned()) {
|
||||
$message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : "");
|
||||
}else{
|
||||
$message = $reason;
|
||||
}
|
||||
if(!$this->isBanned()){
|
||||
$message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : "");
|
||||
}else{
|
||||
$message = $reason;
|
||||
}
|
||||
}else{
|
||||
if($reason === ""){
|
||||
$message = "disconnectionScreen.noReason";
|
||||
@ -2910,11 +2910,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
*/
|
||||
public function sendMessage($message){
|
||||
if($message instanceof TextContainer){
|
||||
if ($message instanceof TranslationContainer) {
|
||||
$this->sendTranslation($message->getText(), $message->getParameters());
|
||||
return;
|
||||
}
|
||||
$message = $message->getText();
|
||||
if($message instanceof TranslationContainer){
|
||||
$this->sendTranslation($message->getText(), $message->getParameters());
|
||||
return;
|
||||
}
|
||||
$message = $message->getText();
|
||||
|
||||
}
|
||||
|
||||
@ -2966,7 +2966,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
*
|
||||
* @param string $message Message to be broadcasted
|
||||
* @param string $reason Reason showed in console
|
||||
* @param bool $notify
|
||||
* @param bool $notify
|
||||
*/
|
||||
public final function close($message = "", $reason = "generic reason", $notify = true){
|
||||
|
||||
@ -3250,13 +3250,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->isCreative()
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_MAGIC
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_VOID
|
||||
){
|
||||
$source->setCancelled();
|
||||
}elseif($this->allowFlight and $source->getCause() === EntityDamageEvent::CAUSE_FALL){
|
||||
if($this->isCreative()
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_MAGIC
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE
|
||||
and $source->getCause() !== EntityDamageEvent::CAUSE_VOID
|
||||
){
|
||||
$source->setCancelled();
|
||||
}elseif($this->allowFlight and $source->getCause() === EntityDamageEvent::CAUSE_FALL){
|
||||
$source->setCancelled();
|
||||
}
|
||||
|
||||
@ -3355,11 +3355,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
/**
|
||||
* @param Vector3|Position|Location $pos
|
||||
* @param float $yaw
|
||||
* @param float $pitch
|
||||
* @param float $yaw
|
||||
* @param float $pitch
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
*/
|
||||
public function teleport(Vector3 $pos, $yaw = null, $pitch = null){
|
||||
if(!$this->isOnline()){
|
||||
return false;
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user