Refactor Block & Tile: getPos() to getPosition() (#4395)

this also changes the name of the class property 'pos' to 'position' as well as Block->getPosOffset() to Block->getPositionOffset()
This commit is contained in:
SalmonDE
2021-08-23 15:01:32 +02:00
committed by GitHub
parent 22316976fa
commit 7fd712c1ff
93 changed files with 402 additions and 402 deletions

View File

@@ -46,8 +46,8 @@ class Bucket extends Item{
$ev = new PlayerBucketFillEvent($player, $blockReplace, $face, $this, $resultItem);
$ev->call();
if(!$ev->isCancelled()){
$player->getWorld()->setBlock($blockClicked->getPos(), VanillaBlocks::AIR());
$player->getWorld()->addSound($blockClicked->getPos()->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound());
$player->getWorld()->setBlock($blockClicked->getPosition(), VanillaBlocks::AIR());
$player->getWorld()->addSound($blockClicked->getPosition()->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound());
if($player->hasFiniteResources()){
if($stack->getCount() === 0){
$player->getInventory()->setItemInHand($ev->getItem());

View File

@@ -35,8 +35,8 @@ class FlintSteel extends Tool{
public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
if($blockReplace->getId() === BlockLegacyIds::AIR){
$world = $player->getWorld();
$world->setBlock($blockReplace->getPos(), VanillaBlocks::FIRE());
$world->addSound($blockReplace->getPos()->add(0.5, 0.5, 0.5), new FlintSteelSound());
$world->setBlock($blockReplace->getPosition(), VanillaBlocks::FIRE());
$world->addSound($blockReplace->getPosition()->add(0.5, 0.5, 0.5), new FlintSteelSound());
$this->applyDamage(1);

View File

@@ -67,8 +67,8 @@ class LiquidBucket extends Item{
$ev = new PlayerBucketEmptyEvent($player, $blockReplace, $face, $this, VanillaItems::BUCKET());
$ev->call();
if(!$ev->isCancelled()){
$player->getWorld()->setBlock($blockReplace->getPos(), $resultBlock->getFlowingForm());
$player->getWorld()->addSound($blockReplace->getPos()->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound());
$player->getWorld()->setBlock($blockReplace->getPosition(), $resultBlock->getFlowingForm());
$player->getWorld()->addSound($blockReplace->getPosition()->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound());
if($player->hasFiniteResources()){
$player->getInventory()->setItemInHand($ev->getItem());

View File

@@ -51,7 +51,7 @@ class PaintingItem extends Item{
continue;
}
if(Painting::canFit($player->getWorld(), $blockReplace->getPos(), $face, true, $motive)){
if(Painting::canFit($player->getWorld(), $blockReplace->getPosition(), $face, true, $motive)){
if($currentTotalDimension > $totalDimension){
$totalDimension = $currentTotalDimension;
/*
@@ -73,8 +73,8 @@ class PaintingItem extends Item{
/** @var PaintingMotive $motive */
$motive = $motives[array_rand($motives)];
$replacePos = $blockReplace->getPos();
$clickedPos = $blockClicked->getPos();
$replacePos = $blockReplace->getPosition();
$clickedPos = $blockClicked->getPosition();
$entity = new Painting(Location::fromObject($replacePos, $replacePos->getWorld()), $clickedPos, $face, $motive);
$this->pop();

View File

@@ -35,7 +35,7 @@ abstract class SpawnEgg extends Item{
abstract protected function createEntity(World $world, Vector3 $pos, float $yaw, float $pitch) : Entity;
public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
$entity = $this->createEntity($player->getWorld(), $blockReplace->getPos()->add(0.5, 0, 0.5), lcg_value() * 360, 0);
$entity = $this->createEntity($player->getWorld(), $blockReplace->getPosition()->add(0.5, 0, 0.5), lcg_value() * 360, 0);
if($this->hasCustomName()){
$entity->setNameTag($this->getCustomName());