mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-14 22:01:59 +00:00
Use bit operations for rotations instead of hardcoded values
This commit is contained in:
parent
15764543b4
commit
b9de2e8b4b
@ -112,13 +112,7 @@ class Ladder extends Transparent{
|
|||||||
|
|
||||||
public function onUpdate(int $type){
|
public function onUpdate(int $type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
$sides = [
|
if(!$this->getSide($this->meta ^ 0x01)->isSolid()){ //Replace with common break method
|
||||||
2 => 3,
|
|
||||||
3 => 2,
|
|
||||||
4 => 5,
|
|
||||||
5 => 4
|
|
||||||
];
|
|
||||||
if(!$this->getSide($sides[$this->meta])->isSolid()){ //Replace with common break method
|
|
||||||
$this->level->useBreakOn($this);
|
$this->level->useBreakOn($this);
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -34,19 +34,11 @@ class WallSign extends SignPost{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate(int $type){
|
public function onUpdate(int $type){
|
||||||
$faces = [
|
|
||||||
2 => 3,
|
|
||||||
3 => 2,
|
|
||||||
4 => 5,
|
|
||||||
5 => 4
|
|
||||||
];
|
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if(isset($faces[$this->meta])){
|
if($this->getSide($this->meta ^ 0x01)->getId() === self::AIR){
|
||||||
if($this->getSide($faces[$this->meta])->getId() === self::AIR){
|
$this->getLevel()->useBreakOn($this);
|
||||||
$this->getLevel()->useBreakOn($this);
|
|
||||||
}
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
|
||||||
}
|
}
|
||||||
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user