mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Merge branch 'stable' into minor-next
This commit is contained in:
@ -570,6 +570,7 @@ class Server{
|
||||
$playerPromiseResolver = new PromiseResolver();
|
||||
|
||||
$createPlayer = function(Location $location) use ($playerPromiseResolver, $class, $session, $playerInfo, $authenticated, $offlinePlayerData) : void{
|
||||
/** @see Player::__construct() */
|
||||
$player = new $class($this, $session, $playerInfo, $authenticated, $location, $offlinePlayerData);
|
||||
if(!$player->hasPlayedBefore()){
|
||||
$player->onGround = true; //TODO: this hack is needed for new players in-air ticks - they don't get detected as on-ground until they move
|
||||
|
@ -31,7 +31,7 @@ use function str_repeat;
|
||||
|
||||
final class VersionInfo{
|
||||
public const NAME = "PocketMine-MP";
|
||||
public const BASE_VERSION = "5.6.1";
|
||||
public const BASE_VERSION = "5.6.2";
|
||||
public const IS_DEVELOPMENT_BUILD = true;
|
||||
public const BUILD_CHANNEL = "stable";
|
||||
|
||||
|
@ -271,4 +271,8 @@ abstract class BaseSign extends Transparent{
|
||||
public function asItem() : Item{
|
||||
return ($this->asItemCallback)();
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return $this->woodType->isFlammable() ? 200 : 0;
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,12 @@ class Dirt extends Opaque{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
$world = $this->position->getWorld();
|
||||
if($face === Facing::UP && $item instanceof Hoe){
|
||||
if($face !== Facing::DOWN && $item instanceof Hoe){
|
||||
$up = $this->getSide(Facing::UP);
|
||||
if($up->getTypeId() !== BlockTypeIds::AIR){
|
||||
return true;
|
||||
}
|
||||
|
||||
$item->applyDamage(1);
|
||||
|
||||
$newBlock = $this->dirtType === DirtType::NORMAL ? VanillaBlocks::FARMLAND() : VanillaBlocks::DIRT();
|
||||
|
@ -82,7 +82,7 @@ class Grass extends Opaque{
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
if($face !== Facing::UP){
|
||||
if($this->getSide(Facing::UP)->getTypeId() !== BlockTypeIds::AIR){
|
||||
return false;
|
||||
}
|
||||
$world = $this->position->getWorld();
|
||||
@ -91,20 +91,23 @@ class Grass extends Opaque{
|
||||
TallGrassObject::growGrass($world, $this->position, new Random(mt_rand()), 8, 2);
|
||||
|
||||
return true;
|
||||
}elseif($item instanceof Hoe){
|
||||
$item->applyDamage(1);
|
||||
$newBlock = VanillaBlocks::FARMLAND();
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));
|
||||
$world->setBlock($this->position, $newBlock);
|
||||
}
|
||||
if($face !== Facing::DOWN){
|
||||
if($item instanceof Hoe){
|
||||
$item->applyDamage(1);
|
||||
$newBlock = VanillaBlocks::FARMLAND();
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));
|
||||
$world->setBlock($this->position, $newBlock);
|
||||
|
||||
return true;
|
||||
}elseif($item instanceof Shovel && $this->getSide(Facing::UP)->getTypeId() === BlockTypeIds::AIR){
|
||||
$item->applyDamage(1);
|
||||
$newBlock = VanillaBlocks::GRASS_PATH();
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));
|
||||
$world->setBlock($this->position, $newBlock);
|
||||
return true;
|
||||
}elseif($item instanceof Shovel){
|
||||
$item->applyDamage(1);
|
||||
$newBlock = VanillaBlocks::GRASS_PATH();
|
||||
$world->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));
|
||||
$world->setBlock($this->position, $newBlock);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -35,4 +35,8 @@ class WoodenButton extends Button{
|
||||
public function hasEntityCollision() : bool{
|
||||
return false; //TODO: arrows activate wooden buttons
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return $this->woodType->isFlammable() ? 100 : 0;
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,8 @@ use pocketmine\block\utils\WoodTypeTrait;
|
||||
|
||||
class WoodenDoor extends Door{
|
||||
use WoodTypeTrait;
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return $this->woodType->isFlammable() ? 200 : 0;
|
||||
}
|
||||
}
|
||||
|
@ -209,6 +209,7 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->registerBlock("carpet", fn() => Blocks::CARPET());
|
||||
$result->registerBlock("carrot_block", fn() => Blocks::CARROTS());
|
||||
$result->registerBlock("carrots", fn() => Blocks::CARROTS());
|
||||
$result->registerBlock("cartography_table", fn() => Blocks::CARTOGRAPHY_TABLE());
|
||||
$result->registerBlock("carved_pumpkin", fn() => Blocks::CARVED_PUMPKIN());
|
||||
$result->registerBlock("cauldron", fn() => Blocks::CAULDRON());
|
||||
$result->registerBlock("cave_vines", fn() => Blocks::CAVE_VINES());
|
||||
@ -984,6 +985,7 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->registerBlock("slime_block", fn() => Blocks::SLIME());
|
||||
$result->registerBlock("small_amethyst_bud", fn() => Blocks::AMETHYST_CLUSTER()->setStage(AmethystCluster::STAGE_SMALL_BUD));
|
||||
$result->registerBlock("small_dripleaf", fn() => Blocks::SMALL_DRIPLEAF());
|
||||
$result->registerBlock("smithing_table", fn() => Blocks::SMITHING_TABLE());
|
||||
$result->registerBlock("smoker", fn() => Blocks::SMOKER());
|
||||
$result->registerBlock("smooth_basalt", fn() => Blocks::SMOOTH_BASALT());
|
||||
$result->registerBlock("smooth_quartz", fn() => Blocks::SMOOTH_QUARTZ());
|
||||
@ -1056,6 +1058,8 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->registerBlock("stripped_acacia_wood", fn() => Blocks::ACACIA_WOOD()->setStripped(true));
|
||||
$result->registerBlock("stripped_birch_log", fn() => Blocks::BIRCH_LOG()->setStripped(true));
|
||||
$result->registerBlock("stripped_birch_wood", fn() => Blocks::BIRCH_WOOD()->setStripped(true));
|
||||
$result->registerBlock("stripped_cherry_log", fn() => Blocks::CHERRY_LOG()->setStripped(true));
|
||||
$result->registerBlock("stripped_cherry_wood", fn() => Blocks::CHERRY_WOOD()->setStripped(true));
|
||||
$result->registerBlock("stripped_crimson_hyphae", fn() => Blocks::CRIMSON_HYPHAE()->setStripped(true));
|
||||
$result->registerBlock("stripped_crimson_stem", fn() => Blocks::CRIMSON_STEM()->setStripped(true));
|
||||
$result->registerBlock("stripped_dark_oak_log", fn() => Blocks::DARK_OAK_LOG()->setStripped(true));
|
||||
|
@ -41,8 +41,11 @@ final class Promise{
|
||||
* @phpstan-param \Closure() : void $onFailure
|
||||
*/
|
||||
public function onCompletion(\Closure $onSuccess, \Closure $onFailure) : void{
|
||||
if($this->shared->resolved){
|
||||
$this->shared->result === null ? $onFailure() : $onSuccess($this->shared->result);
|
||||
$state = $this->shared->state;
|
||||
if($state === true){
|
||||
$onSuccess($this->shared->result);
|
||||
}elseif($state === false){
|
||||
$onFailure();
|
||||
}else{
|
||||
$this->shared->onSuccess[spl_object_id($onSuccess)] = $onSuccess;
|
||||
$this->shared->onFailure[spl_object_id($onFailure)] = $onFailure;
|
||||
@ -50,6 +53,8 @@ final class Promise{
|
||||
}
|
||||
|
||||
public function isResolved() : bool{
|
||||
return $this->shared->resolved;
|
||||
//TODO: perhaps this should return true when rejected? currently there's no way to tell if a promise was
|
||||
//rejected or just hasn't been resolved yet
|
||||
return $this->shared->state === true;
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ final class PromiseResolver{
|
||||
* @phpstan-param TValue $value
|
||||
*/
|
||||
public function resolve(mixed $value) : void{
|
||||
if($this->shared->resolved){
|
||||
if($this->shared->state !== null){
|
||||
throw new \LogicException("Promise has already been resolved/rejected");
|
||||
}
|
||||
$this->shared->resolved = true;
|
||||
$this->shared->state = true;
|
||||
$this->shared->result = $value;
|
||||
foreach($this->shared->onSuccess as $c){
|
||||
$c($value);
|
||||
@ -54,10 +54,10 @@ final class PromiseResolver{
|
||||
}
|
||||
|
||||
public function reject() : void{
|
||||
if($this->shared->resolved){
|
||||
if($this->shared->state !== null){
|
||||
throw new \LogicException("Promise has already been resolved/rejected");
|
||||
}
|
||||
$this->shared->resolved = true;
|
||||
$this->shared->state = false;
|
||||
foreach($this->shared->onFailure as $c){
|
||||
$c();
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ final class PromiseSharedData{
|
||||
*/
|
||||
public array $onFailure = [];
|
||||
|
||||
public bool $resolved = false;
|
||||
public ?bool $state = null;
|
||||
|
||||
/** @phpstan-var TValue|null */
|
||||
public mixed $result = null;
|
||||
/** @phpstan-var TValue */
|
||||
public mixed $result;
|
||||
}
|
||||
|
@ -1097,19 +1097,22 @@ class World implements ChunkManager{
|
||||
$blockPosition = BlockPosition::fromVector3($b);
|
||||
|
||||
$tile = $this->getTileAt($b->x, $b->y, $b->z);
|
||||
if($tile instanceof Spawnable && count($fakeStateProperties = $tile->getRenderUpdateBugWorkaroundStateProperties($fullBlock)) > 0){
|
||||
$originalStateData = $blockTranslator->internalIdToNetworkStateData($fullBlock->getStateId());
|
||||
$fakeStateData = new BlockStateData(
|
||||
$originalStateData->getName(),
|
||||
array_merge($originalStateData->getStates(), $fakeStateProperties),
|
||||
$originalStateData->getVersion()
|
||||
);
|
||||
$packets[] = UpdateBlockPacket::create(
|
||||
$blockPosition,
|
||||
$blockTranslator->getBlockStateDictionary()->lookupStateIdFromData($fakeStateData) ?? throw new AssumptionFailedError("Unmapped fake blockstate data: " . $fakeStateData->toNbt()),
|
||||
UpdateBlockPacket::FLAG_NETWORK,
|
||||
UpdateBlockPacket::DATA_LAYER_NORMAL
|
||||
);
|
||||
if($tile instanceof Spawnable){
|
||||
$expectedClass = $fullBlock->getIdInfo()->getTileClass();
|
||||
if($expectedClass !== null && $tile instanceof $expectedClass && count($fakeStateProperties = $tile->getRenderUpdateBugWorkaroundStateProperties($fullBlock)) > 0){
|
||||
$originalStateData = $blockTranslator->internalIdToNetworkStateData($fullBlock->getStateId());
|
||||
$fakeStateData = new BlockStateData(
|
||||
$originalStateData->getName(),
|
||||
array_merge($originalStateData->getStates(), $fakeStateProperties),
|
||||
$originalStateData->getVersion()
|
||||
);
|
||||
$packets[] = UpdateBlockPacket::create(
|
||||
$blockPosition,
|
||||
$blockTranslator->getBlockStateDictionary()->lookupStateIdFromData($fakeStateData) ?? throw new AssumptionFailedError("Unmapped fake blockstate data: " . $fakeStateData->toNbt()),
|
||||
UpdateBlockPacket::FLAG_NETWORK,
|
||||
UpdateBlockPacket::DATA_LAYER_NORMAL
|
||||
);
|
||||
}
|
||||
}
|
||||
$packets[] = UpdateBlockPacket::create(
|
||||
$blockPosition,
|
||||
@ -2892,15 +2895,7 @@ class World implements ChunkManager{
|
||||
}elseif($this->getTile($tilePosition) !== null){
|
||||
$logger->error("Cannot add tile at x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z: Another tile is already at that position");
|
||||
}else{
|
||||
$block = $this->getBlockAt($tilePosition->getFloorX(), $tilePosition->getFloorY(), $tilePosition->getFloorZ());
|
||||
$expectedClass = $block->getIdInfo()->getTileClass();
|
||||
if($expectedClass === null){
|
||||
$logger->error("Cannot add tile at x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z: Block at that position (" . $block->getName() . ") does not expect a tile");
|
||||
}elseif(!($tile instanceof $expectedClass)){
|
||||
$logger->error("Cannot add tile at x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z: Tile is of wrong type (expected $expectedClass but have " . get_class($tile) . ")");
|
||||
}else{
|
||||
$this->addTile($tile);
|
||||
}
|
||||
$this->addTile($tile);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user