Use bit operations for rotations instead of hardcoded values

This commit is contained in:
Dylan K. Taylor 2017-10-18 16:47:37 +01:00
parent 15764543b4
commit b9de2e8b4b
2 changed files with 4 additions and 18 deletions

View File

@ -112,13 +112,7 @@ class Ladder extends Transparent{
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL){
$sides = [
2 => 3,
3 => 2,
4 => 5,
5 => 4
];
if(!$this->getSide($sides[$this->meta])->isSolid()){ //Replace with common break method
if(!$this->getSide($this->meta ^ 0x01)->isSolid()){ //Replace with common break method
$this->level->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}

View File

@ -34,19 +34,11 @@ class WallSign extends SignPost{
}
public function onUpdate(int $type){
$faces = [
2 => 3,
3 => 2,
4 => 5,
5 => 4
];
if($type === Level::BLOCK_UPDATE_NORMAL){
if(isset($faces[$this->meta])){
if($this->getSide($faces[$this->meta])->getId() === self::AIR){
$this->getLevel()->useBreakOn($this);
}
return Level::BLOCK_UPDATE_NORMAL;
if($this->getSide($this->meta ^ 0x01)->getId() === self::AIR){
$this->getLevel()->useBreakOn($this);
}
return Level::BLOCK_UPDATE_NORMAL;
}
return false;
}