3 small fixes

This commit is contained in:
GameHerobrine 2023-10-27 19:40:35 +03:00
parent 7768ad03a9
commit 39bfa7115d
5 changed files with 23 additions and 2 deletions

View file

@ -17,7 +17,7 @@ class SignPostBlock extends TransparentBlock{
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($target->isSolid && $face !== 0){
if(($target->isSolid || $target->getID() === SIGN_POST || $target->getID() === WALL_SIGN) && $face !== 0){
if(!isset(self::$faces[$face])){
$this->meta = floor((($player->entity->yaw + 180) * 16 / 360) + 0.5) & 0x0F;
$this->level->setBlock($block, BlockAPI::get(SIGN_POST, $this->meta), true, false, true);

View file

@ -5,11 +5,27 @@ require_once("SignPostBlock.php");
/***REM_END***/
class WallSignBlock extends SignPostBlock{
public static $meta2side = [
2 => 3,
3 => 2,
4 => 5,
5 => 4
];
public function __construct($meta = 0){
TransparentBlock::__construct(WALL_SIGN, $meta, "Wall Sign");
$this->isSolid = false;
}
public function onUpdate($type){
$attached = $this->getSide(self::$meta2side[$this->meta] ?? -1);
if(!($attached instanceof Block) || (!$attached->isSolid && $attached->getID() != SIGN_POST && $attached->getID() != WALL_SIGN)){
$this->level->setBlock($this, new AirBlock(), true, true, true);
(ServerAPI::request())->api->entity->drop(new Position($this->x + 0.5, $this->y + 0.5, $this->z + 0.5, $this->level), BlockAPI::getItem(SIGN, 0, 1));
}
return false;
}
}

View file

@ -15,4 +15,8 @@ class GlowstoneBlock extends TransparentBlock implements LightingBlock{
array(GLOWSTONE_DUST, 0, mt_rand(2, 4)),
);
}
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
}
}