Remove some remaining hardcoded meta maps

This commit is contained in:
Dylan K. Taylor 2018-09-16 18:00:16 +01:00
parent 8aab51c532
commit 31e4093882
2 changed files with 6 additions and 34 deletions

View File

@ -59,13 +59,7 @@ class ItemFrame extends Flowable{
} }
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
$sides = [ if(!$this->getSide(Facing::opposite(5 - $this->meta))->isSolid()){
0 => Facing::WEST,
1 => Facing::EAST,
2 => Facing::NORTH,
3 => Facing::SOUTH
];
if(!$this->getSide($sides[$this->meta])->isSolid()){
$this->level->useBreakOn($this); $this->level->useBreakOn($this);
} }
} }
@ -75,14 +69,7 @@ class ItemFrame extends Flowable{
return false; return false;
} }
$faces = [ $this->meta = 5 - $face;
Facing::NORTH => 3,
Facing::SOUTH => 2,
Facing::WEST => 1,
Facing::EAST => 0
];
$this->meta = $faces[$face];
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){ if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
Tile::createTile(Tile::ITEM_FRAME, $this->getLevel(), TileItemFrame::createNBT($this, $face, $item, $player)); Tile::createTile(Tile::ITEM_FRAME, $this->getLevel(), TileItemFrame::createNBT($this, $face, $item, $player));

View File

@ -46,17 +46,9 @@ class Torch extends Flowable{
public function onNearbyBlockChange() : void{ public function onNearbyBlockChange() : void{
$below = $this->getSide(Facing::DOWN); $below = $this->getSide(Facing::DOWN);
$side = $this->getDamage(); $face = $this->meta === 0 ? Facing::DOWN : Facing::opposite(6 - $this->meta);
static $faces = [
0 => Facing::DOWN,
1 => Facing::WEST,
2 => Facing::EAST,
3 => Facing::NORTH,
4 => Facing::SOUTH,
5 => Facing::DOWN
];
if($this->getSide($faces[$side])->isTransparent() and !($faces[$side] === Facing::DOWN and ($below->getId() === self::FENCE or $below->getId() === self::COBBLESTONE_WALL))){ if($this->getSide($face)->isTransparent() and !($face === Facing::DOWN and ($below->getId() === self::FENCE or $below->getId() === self::COBBLESTONE_WALL))){
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);
} }
} }
@ -65,18 +57,11 @@ class Torch extends Flowable{
$below = $this->getSide(Facing::DOWN); $below = $this->getSide(Facing::DOWN);
if(!$blockClicked->isTransparent() and $face !== Facing::DOWN){ if(!$blockClicked->isTransparent() and $face !== Facing::DOWN){
static $faces = [ $this->meta = 6 - $face;
Facing::UP => 5,
Facing::NORTH => 4,
Facing::SOUTH => 3,
Facing::WEST => 2,
Facing::EAST => 1
];
$this->meta = $faces[$face];
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}elseif(!$below->isTransparent() or $below->getId() === self::FENCE or $below->getId() === self::COBBLESTONE_WALL){ }elseif(!$below->isTransparent() or $below->getId() === self::FENCE or $below->getId() === self::COBBLESTONE_WALL){
$this->meta = 0; $this->meta = 5; //attached to block below
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
} }