Replaced literal ints with Vector3 constants for Block->getSide() calls

This commit is contained in:
Dylan K. Taylor
2017-08-04 13:33:23 +01:00
parent 3188f1c053
commit 2103c981a9
23 changed files with 77 additions and 65 deletions

View File

@ -203,10 +203,10 @@ abstract class Door extends Transparent{
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method
if($this->getSide(Vector3::SIDE_DOWN)->getId() === self::AIR){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), false);
if($this->getSide(1) instanceof Door){
$this->getLevel()->setBlock($this->getSide(1), new Air(), false);
if($this->getSide(Vector3::SIDE_UP) instanceof Door){
$this->getLevel()->setBlock($this->getSide(Vector3::SIDE_UP), new Air(), false);
}
return Level::BLOCK_UPDATE_NORMAL;
@ -218,8 +218,8 @@ abstract class Door extends Transparent{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
if($face === 1){
$blockUp = $this->getSide(1);
$blockDown = $this->getSide(0);
$blockUp = $this->getSide(Vector3::SIDE_UP);
$blockDown = $this->getSide(Vector3::SIDE_DOWN);
if($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true){
return false;
}
@ -248,12 +248,12 @@ abstract class Door extends Transparent{
public function onBreak(Item $item){
if(($this->getDamage() & 0x08) === 0x08){
$down = $this->getSide(0);
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === $this->getId()){
$this->getLevel()->setBlock($down, new Air(), true);
}
}else{
$up = $this->getSide(1);
$up = $this->getSide(Vector3::SIDE_UP);
if($up->getId() === $this->getId()){
$this->getLevel()->setBlock($up, new Air(), true);
}
@ -265,7 +265,7 @@ abstract class Door extends Transparent{
public function onActivate(Item $item, Player $player = null){
if(($this->getDamage() & 0x08) === 0x08){ //Top
$down = $this->getSide(0);
$down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === $this->getId()){
$meta = $down->getDamage() ^ 0x04;
$this->level->setBlock($down, Block::get($this->getId(), $meta), true);