mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 00:39:45 +00:00
Make Block->position() accept Level,x,y,z instead of Position
since this is an internal method, it doesn't make sense to force a single parameter that requires potentially constructing a separate object just for the parameters, so we pass primitives instead, which are also easier to typehint against.
This commit is contained in:
parent
c3623478c1
commit
9fb365306a
@ -30,6 +30,7 @@ use pocketmine\entity\Entity;
|
|||||||
use pocketmine\item\enchantment\Enchantment;
|
use pocketmine\item\enchantment\Enchantment;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\item\ItemFactory;
|
use pocketmine\item\ItemFactory;
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\level\Position;
|
use pocketmine\level\Position;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
@ -466,15 +467,18 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the block position to a new Position object
|
* @internal
|
||||||
*
|
*
|
||||||
* @param Position $v
|
* @param Level $level
|
||||||
|
* @param int $x
|
||||||
|
* @param int $y
|
||||||
|
* @param int $z
|
||||||
*/
|
*/
|
||||||
final public function position(Position $v) : void{
|
final public function position(Level $level, int $x, int $y, int $z) : void{
|
||||||
$this->x = (int) $v->x;
|
$this->x = $x;
|
||||||
$this->y = (int) $v->y;
|
$this->y = $y;
|
||||||
$this->z = (int) $v->z;
|
$this->z = $z;
|
||||||
$this->level = $v->level;
|
$this->level = $level;
|
||||||
$this->readStateFromWorld();
|
$this->readStateFromWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ use pocketmine\block\Fallable;
|
|||||||
use pocketmine\entity\Entity;
|
use pocketmine\entity\Entity;
|
||||||
use pocketmine\event\entity\EntityBlockChangeEvent;
|
use pocketmine\event\entity\EntityBlockChangeEvent;
|
||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
use pocketmine\level\Position;
|
|
||||||
use pocketmine\nbt\tag\ByteTag;
|
use pocketmine\nbt\tag\ByteTag;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\IntTag;
|
use pocketmine\nbt\tag\IntTag;
|
||||||
@ -95,9 +94,9 @@ class FallingBlock extends Entity{
|
|||||||
$hasUpdate = parent::entityBaseTick($tickDiff);
|
$hasUpdate = parent::entityBaseTick($tickDiff);
|
||||||
|
|
||||||
if(!$this->isFlaggedForDespawn()){
|
if(!$this->isFlaggedForDespawn()){
|
||||||
$pos = Position::fromObject($this->add(-$this->width / 2, $this->height, -$this->width / 2)->floor(), $this->getLevel());
|
$pos = $this->add(-$this->width / 2, $this->height, -$this->width / 2)->floor();
|
||||||
|
|
||||||
$this->block->position($pos);
|
$this->block->position($this->level, $pos->x, $pos->y, $pos->z);
|
||||||
|
|
||||||
$blockTarget = null;
|
$blockTarget = null;
|
||||||
if($this->block instanceof Fallable){
|
if($this->block instanceof Fallable){
|
||||||
|
@ -1530,13 +1530,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
$this->timings->setBlock->startTiming();
|
$this->timings->setBlock->startTiming();
|
||||||
|
|
||||||
if(!($pos instanceof Position)){
|
|
||||||
$pos = $this->temporalPosition->setComponents($pos->x, $pos->y, $pos->z);
|
|
||||||
}
|
|
||||||
|
|
||||||
$block = clone $block;
|
$block = clone $block;
|
||||||
|
|
||||||
$block->position($pos);
|
$block->position($this, $pos->x, $pos->y, $pos->z);
|
||||||
$block->writeStateToWorld();
|
$block->writeStateToWorld();
|
||||||
|
|
||||||
$chunkHash = Level::chunkHash($pos->x >> 4, $pos->z >> 4);
|
$chunkHash = Level::chunkHash($pos->x >> 4, $pos->z >> 4);
|
||||||
@ -1823,14 +1819,14 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
if($item->canBePlaced()){
|
if($item->canBePlaced()){
|
||||||
$hand = $item->getBlock();
|
$hand = $item->getBlock();
|
||||||
$hand->position($blockReplace);
|
$hand->position($this, $blockReplace->x, $blockReplace->y, $blockReplace->z);
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($hand->canBePlacedAt($blockClicked, $clickVector, $face, true)){
|
if($hand->canBePlacedAt($blockClicked, $clickVector, $face, true)){
|
||||||
$blockReplace = $blockClicked;
|
$blockReplace = $blockClicked;
|
||||||
$hand->position($blockReplace);
|
$hand->position($this, $blockReplace->x, $blockReplace->y, $blockReplace->z);
|
||||||
}elseif(!$hand->canBePlacedAt($blockReplace, $clickVector, $face, false)){
|
}elseif(!$hand->canBePlacedAt($blockReplace, $clickVector, $face, false)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user