mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Replaced more literal ints with Vector3 constants
This commit is contained in:
parent
e1d894057c
commit
c394aea803
@ -217,21 +217,21 @@ abstract class Door extends Transparent{
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, int $face, Vector3 $facePos, Player $player = null) : bool{
|
||||
if($face === 1){
|
||||
if($face === Vector3::SIDE_UP){
|
||||
$blockUp = $this->getSide(Vector3::SIDE_UP);
|
||||
$blockDown = $this->getSide(Vector3::SIDE_DOWN);
|
||||
if($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true){
|
||||
return false;
|
||||
}
|
||||
$direction = $player instanceof Player ? $player->getDirection() : 0;
|
||||
$face = [
|
||||
$faces = [
|
||||
0 => 3,
|
||||
1 => 4,
|
||||
2 => 2,
|
||||
3 => 5,
|
||||
];
|
||||
$next = $this->getSide($face[($direction + 2) % 4]);
|
||||
$next2 = $this->getSide($face[$direction]);
|
||||
$next = $this->getSide($faces[($direction + 2) % 4]);
|
||||
$next2 = $this->getSide($faces[$direction]);
|
||||
$metaUp = 0x08;
|
||||
if($next->getId() === $this->getId() or ($next2->isTransparent() === false and $next->isTransparent() === true)){ //Door hinge
|
||||
$metaUp |= 0x01;
|
||||
|
@ -105,15 +105,15 @@ class ItemFrame extends Flowable{
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, int $face, Vector3 $facePos, Player $player = null) : bool{
|
||||
if($face === 0 or $face === 1){
|
||||
if($face === Vector3::SIDE_DOWN or $face === Vector3::SIDE_UP){
|
||||
return false;
|
||||
}
|
||||
|
||||
$faces = [
|
||||
2 => 3,
|
||||
3 => 2,
|
||||
4 => 1,
|
||||
5 => 0
|
||||
Vector3::SIDE_NORTH => 3,
|
||||
Vector3::SIDE_SOUTH => 2,
|
||||
Vector3::SIDE_WEST => 1,
|
||||
Vector3::SIDE_EAST => 0
|
||||
];
|
||||
|
||||
$this->meta = $faces[$face];
|
||||
|
@ -61,7 +61,7 @@ class SignPost extends Transparent{
|
||||
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, int $face, Vector3 $facePos, Player $player = null) : bool{
|
||||
if($face !== 0){
|
||||
if($face !== Vector3::SIDE_DOWN){
|
||||
$nbt = new CompoundTag("", [
|
||||
new StringTag("id", Tile::SIGN),
|
||||
new IntTag("x", $block->x),
|
||||
@ -83,7 +83,7 @@ class SignPost extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
if($face === 1){
|
||||
if($face === Vector3::SIDE_UP){
|
||||
$this->meta = floor((($player->yaw + 180) * 16 / 360) + 0.5) & 0x0f;
|
||||
$this->getLevel()->setBlock($block, $this, true);
|
||||
}else{
|
||||
|
@ -64,9 +64,9 @@ class Skull extends Flowable{
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, int $face, Vector3 $facePos, Player $player = null) : bool{
|
||||
if($face !== 0){
|
||||
if($face !== Vector3::SIDE_DOWN){
|
||||
$this->meta = $face;
|
||||
if($face === 1){
|
||||
if($face === Vector3::SIDE_UP){
|
||||
$rot = floor(($player->yaw * 16 / 360) + 0.5) & 0x0F;
|
||||
}else{
|
||||
$rot = $face;
|
||||
|
@ -138,7 +138,7 @@ abstract class Stair extends Transparent{
|
||||
3 => 3,
|
||||
];
|
||||
$this->meta = $faces[$player->getDirection()] & 0x03;
|
||||
if(($facePos->y > 0.5 and $face !== 1) or $face === 0){
|
||||
if(($facePos->y > 0.5 and $face !== Vector3::SIDE_UP) or $face === Vector3::SIDE_DOWN){
|
||||
$this->meta |= 0x04; //Upside-down stairs
|
||||
}
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
@ -71,13 +71,13 @@ class Torch extends Flowable{
|
||||
public function place(Item $item, Block $block, Block $target, int $face, Vector3 $facePos, Player $player = null) : bool{
|
||||
$below = $this->getSide(Vector3::SIDE_DOWN);
|
||||
|
||||
if($target->isTransparent() === false and $face !== 0){
|
||||
if($target->isTransparent() === false and $face !== Vector3::SIDE_DOWN){
|
||||
$faces = [
|
||||
1 => 5,
|
||||
2 => 4,
|
||||
3 => 3,
|
||||
4 => 2,
|
||||
5 => 1,
|
||||
Vector3::SIDE_UP => 5,
|
||||
Vector3::SIDE_NORTH => 4,
|
||||
Vector3::SIDE_SOUTH => 3,
|
||||
Vector3::SIDE_WEST => 2,
|
||||
Vector3::SIDE_EAST => 1,
|
||||
];
|
||||
$this->meta = $faces[$face];
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
|
@ -56,12 +56,12 @@ class Wood extends Solid{
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, int $face, Vector3 $facePos, Player $player = null) : bool{
|
||||
$faces = [
|
||||
0 => 0,
|
||||
1 => 0,
|
||||
2 => 0b1000,
|
||||
3 => 0b1000,
|
||||
4 => 0b0100,
|
||||
5 => 0b0100,
|
||||
Vector3::SIDE_DOWN => 0,
|
||||
Vector3::SIDE_UP => 0,
|
||||
Vector3::SIDE_NORTH => 0b1000,
|
||||
Vector3::SIDE_SOUTH => 0b1000,
|
||||
Vector3::SIDE_WEST => 0b0100,
|
||||
Vector3::SIDE_EAST => 0b0100,
|
||||
];
|
||||
|
||||
$this->meta = ($this->meta & 0x03) | $faces[$face];
|
||||
|
@ -80,7 +80,7 @@ class WoodenSlab extends Transparent{
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, int $face, Vector3 $facePos, Player $player = null) : bool{
|
||||
$this->meta &= 0x07;
|
||||
if($face === 0){
|
||||
if($face === Vector3::SIDE_DOWN){
|
||||
if($target->getId() === $this->id and ($target->getDamage() & 0x08) === 0x08 and ($target->getDamage() & 0x07) === ($this->meta)){
|
||||
$this->getLevel()->setBlock($target, Block::get($this->doubleId, $this->meta), true);
|
||||
|
||||
@ -92,7 +92,7 @@ class WoodenSlab extends Transparent{
|
||||
}else{
|
||||
$this->meta |= 0x08;
|
||||
}
|
||||
}elseif($face === 1){
|
||||
}elseif($face === Vector3::SIDE_UP){
|
||||
if($target->getId() === $this->id and ($target->getDamage() & 0x08) === 0 and ($target->getDamage() & 0x07) === $this->meta){
|
||||
$this->getLevel()->setBlock($target, Block::get($this->doubleId, $this->meta), true);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user