changed door collisions to 1.5.2

This commit is contained in:
GameHerobrine 2023-10-27 18:27:33 +03:00
parent f3d726cddf
commit b115c19093
2 changed files with 42 additions and 9 deletions

View file

@ -10,28 +10,61 @@ class DoorBlock extends TransparentBlock{
parent::__construct($id, $meta, $name); parent::__construct($id, $meta, $name);
$this->isSolid = false; $this->isSolid = false;
} }
//TODO opened doors fix
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
$aabb = new AxisAlignedBB(0, 0, 0, 1, 2, 1); $aabb = new AxisAlignedBB(0, 0, 0, 1, 2, 1);
switch(self::getState($level->level->getBlockDamage($x, $y, $z))){ $fullMeta = self::getFullBlockMetadata($level, $x, $y, $z);
switch($fullMeta & 3){
case 0: case 0:
$aabb->setBounds(0, 0, 0, 1, 1, 0.1875); if(($fullMeta & 4) != 0){
if(($fullMeta & 16) == 0) $aabb->setBounds(0, 0, 0, 1, 1, 0.1875);
else $aabb->setBounds(0, 0, 1 - 0.1875, 1, 1, 1);
}else{
$aabb->setBounds(0, 0, 0, 0.1875, 1, 1);
}
break; break;
case 1: case 1:
$aabb->setBounds(1 - 0.1875, 0, 0, 1, 1, 1); if(($fullMeta & 4) != 0){
if(($fullMeta & 16) == 0) $aabb->setBounds(1 - 0.1875, 0, 0, 1, 1, 1);
else $aabb->setBounds(0, 0, 0, 0.1875, 1, 1);
}else{
$aabb->setBounds(0, 0, 0, 1, 1, 0.1875);
}
break; break;
case 2: case 2:
$aabb->setBounds(0, 0, 1 - 0.1875, 1, 1, 1); if(($fullMeta & 4) != 0){
if(($fullMeta & 16) == 0) $aabb->setBounds(0, 0, 1 - 0.1875, 1, 1, 1);
else $aabb->setBounds(0, 0, 0, 1, 1, 0.1875);
}else{
$aabb->setBounds(1 - 0.1875, 0, 0, 1, 1, 1);
}
break; break;
case 3: case 3:
$aabb->setBounds(0, 0, 0, 0.1875, 1, 1); if(($fullMeta & 4) != 0){
if(($fullMeta & 16) == 0) $aabb->setBounds(0, 0, 0, 0.1875, 1, 1);
else $aabb->setBounds(1 - 0.1875, 0, 0, 1, 1, 1);
}else{
$aabb->setBounds(0, 0, 1 - 0.1875, 1, 1, 1);
}
break; break;
} }
return [$aabb->offset($x, $y, $z)]; return [$aabb->offset($x, $y, $z)];
} }
public static function getState($meta){ public static function getFullBlockMetadata(Level $level, $x, $y, $z){
return ($meta & 4) == 0 ? ($meta - 1) & 3 : $meta & 3; $myMeta = $level->level->getBlockDamage($x, $y, $z);
if(($myMeta & 8) != 0){
$metaLower = $level->level->getBlockDamage($x, $y - 1, $z);
$metaUpper = $myMeta;
}else{
$metaLower = $myMeta;
$metaUpper = $level->level->getBlockDamage($x, $y + 1, $z);
}
return $metaLower & 7 | (($myMeta & 8) != 0 ? 8 : 0) | (($metaUpper & 1 != 0) ? 16 : 0);
} }
/** /**

View file

@ -31,7 +31,7 @@ class FenceGateBlock extends TransparentBlock{
); );
} }
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){
$this->meta ^= 0x04; $this->meta ^= 0x04;
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
$players = ServerAPI::request()->api->player->getAll($this->level); $players = ServerAPI::request()->api->player->getAll($this->level);
unset($players[$player->CID]); unset($players[$player->CID]);