mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-04 02:52:25 +00:00
Update for pocketmine/math Axis refactor
This commit is contained in:
parent
7399e6944e
commit
2b044195a5
@ -1 +1 @@
|
||||
Subproject commit 2f422db397509fd9d7161b0c388401ec5be5a46f
|
||||
Subproject commit fadde8d5b2ee97f41f4647ff2c0a97e8aa9d7af0
|
8
composer.lock
generated
8
composer.lock
generated
@ -552,12 +552,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/Math.git",
|
||||
"reference": "2a1a1783123c365a755f1f6d1023466d27d52795"
|
||||
"reference": "a7c9da52c7efcd3383073357c10d3a989bfbb3f2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/2a1a1783123c365a755f1f6d1023466d27d52795",
|
||||
"reference": "2a1a1783123c365a755f1f6d1023466d27d52795",
|
||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/a7c9da52c7efcd3383073357c10d3a989bfbb3f2",
|
||||
"reference": "a7c9da52c7efcd3383073357c10d3a989bfbb3f2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -579,7 +579,7 @@
|
||||
"LGPL-3.0"
|
||||
],
|
||||
"description": "PHP library containing math related code used in PocketMine-MP",
|
||||
"time": "2020-07-09T19:58:18+00:00"
|
||||
"time": "2020-08-06T13:19:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/nbt",
|
||||
|
@ -33,8 +33,8 @@ use pocketmine\entity\Entity;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
@ -485,7 +485,7 @@ class Block{
|
||||
*/
|
||||
public function getHorizontalSides() : \Generator{
|
||||
$world = $this->pos->getWorld();
|
||||
foreach($this->pos->sidesAroundAxis(Facing::AXIS_Y) as $vector3){
|
||||
foreach($this->pos->sidesAroundAxis(Axis::Y) as $vector3){
|
||||
yield $world->getBlock($vector3);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -74,7 +75,7 @@ class CocoaBlock extends Transparent{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(Facing::axis($face) !== Facing::AXIS_Y and $blockClicked instanceof Wood and $blockClicked->getTreeType()->equals(TreeType::JUNGLE())){
|
||||
if(Facing::axis($face) !== Axis::Y and $blockClicked instanceof Wood and $blockClicked->getTreeType()->equals(TreeType::JUNGLE())){
|
||||
$this->facing = $face;
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\utils\AnyFacingTrait;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -41,7 +42,7 @@ class EndRod extends Flowable{
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
$result = BlockDataSerializer::writeFacing($this->facing);
|
||||
if(Facing::axis($this->facing) !== Facing::AXIS_Y){
|
||||
if(Facing::axis($this->facing) !== Axis::Y){
|
||||
$result ^= 1; //TODO: in PC this is always the same as facing, just PE is stupid
|
||||
}
|
||||
|
||||
@ -84,7 +85,7 @@ class EndRod extends Flowable{
|
||||
$myAxis = Facing::axis($this->facing);
|
||||
|
||||
$bb = AxisAlignedBB::one();
|
||||
foreach([Facing::AXIS_Y, Facing::AXIS_Z, Facing::AXIS_X] as $axis){
|
||||
foreach([Axis::Y, Axis::Z, Axis::X] as $axis){
|
||||
if($axis === $myAxis){
|
||||
continue;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use function count;
|
||||
@ -63,7 +64,7 @@ class Fence extends Transparent{
|
||||
if($connectWest or $connectEast){
|
||||
//X axis (west/east)
|
||||
$bbs[] = AxisAlignedBB::one()
|
||||
->squash(Facing::AXIS_Z, $inset)
|
||||
->squash(Axis::Z, $inset)
|
||||
->extend(Facing::UP, 0.5)
|
||||
->trim(Facing::WEST, $connectWest ? 0 : $inset)
|
||||
->trim(Facing::EAST, $connectEast ? 0 : $inset);
|
||||
@ -75,7 +76,7 @@ class Fence extends Transparent{
|
||||
if($connectNorth or $connectSouth){
|
||||
//Z axis (north/south)
|
||||
$bbs[] = AxisAlignedBB::one()
|
||||
->squash(Facing::AXIS_X, $inset)
|
||||
->squash(Axis::X, $inset)
|
||||
->extend(Facing::UP, 0.5)
|
||||
->trim(Facing::NORTH, $connectNorth ? 0 : $inset)
|
||||
->trim(Facing::SOUTH, $connectSouth ? 0 : $inset);
|
||||
|
@ -28,6 +28,7 @@ use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -80,7 +81,7 @@ class Ladder extends Transparent{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$blockClicked->isTransparent() and Facing::axis($face) !== Facing::AXIS_Y){
|
||||
if(!$blockClicked->isTransparent() and Facing::axis($face) !== Axis::Y){
|
||||
$this->facing = $face;
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -59,8 +60,8 @@ class Lantern extends Transparent{
|
||||
AxisAlignedBB::one()
|
||||
->trim(Facing::UP, $this->hanging ? 6 / 16 : 8 / 16)
|
||||
->trim(Facing::DOWN, $this->hanging ? 2 / 16 : 0)
|
||||
->squash(Facing::AXIS_X, 5 / 16)
|
||||
->squash(Facing::AXIS_Z, 5 / 16)
|
||||
->squash(Axis::X, 5 / 16)
|
||||
->squash(Axis::Z, 5 / 16)
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -50,9 +51,9 @@ class Lever extends Flowable{
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
if($this->leverPos === self::BOTTOM){
|
||||
$rotationMeta = Facing::axis($this->facing) === Facing::AXIS_Z ? 7 : 0;
|
||||
$rotationMeta = Facing::axis($this->facing) === Axis::Z ? 7 : 0;
|
||||
}elseif($this->leverPos === self::TOP){
|
||||
$rotationMeta = Facing::axis($this->facing) === Facing::AXIS_Z ? 5 : 6;
|
||||
$rotationMeta = Facing::axis($this->facing) === Axis::Z ? 5 : 6;
|
||||
}else{
|
||||
$rotationMeta = 6 - BlockDataSerializer::writeHorizontalFacing($this->facing);
|
||||
}
|
||||
@ -84,7 +85,7 @@ class Lever extends Flowable{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Facing::axis($face) === Facing::AXIS_Y){
|
||||
if(Facing::axis($face) === Axis::Y){
|
||||
if($player !== null){
|
||||
$this->facing = Facing::opposite($player->getHorizontalFacing());
|
||||
}
|
||||
|
@ -25,23 +25,23 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
class NetherPortal extends Transparent{
|
||||
/** @var int */
|
||||
protected $axis = Facing::AXIS_X;
|
||||
protected $axis = Axis::X;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||
parent::__construct($idInfo, $name, $breakInfo ?? BlockBreakInfo::indestructible(0.0));
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->axis = $stateMeta === BlockLegacyMetadata::NETHER_PORTAL_AXIS_Z ? Facing::AXIS_Z : Facing::AXIS_X; //mojang u dumb
|
||||
$this->axis = $stateMeta === BlockLegacyMetadata::NETHER_PORTAL_AXIS_Z ? Axis::Z : Axis::X; //mojang u dumb
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->axis === Facing::AXIS_Z ? BlockLegacyMetadata::NETHER_PORTAL_AXIS_Z : BlockLegacyMetadata::NETHER_PORTAL_AXIS_X;
|
||||
return $this->axis === Axis::Z ? BlockLegacyMetadata::NETHER_PORTAL_AXIS_Z : BlockLegacyMetadata::NETHER_PORTAL_AXIS_X;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
@ -57,7 +57,7 @@ class NetherPortal extends Transparent{
|
||||
* @return $this
|
||||
*/
|
||||
public function setAxis(int $axis) : self{
|
||||
if($axis !== Facing::AXIS_X and $axis !== Facing::AXIS_Z){
|
||||
if($axis !== Axis::X and $axis !== Axis::Z){
|
||||
throw new \InvalidArgumentException("Invalid axis");
|
||||
}
|
||||
$this->axis = $axis;
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use function count;
|
||||
@ -51,7 +52,7 @@ class Thin extends Transparent{
|
||||
$bbs = [];
|
||||
|
||||
if(isset($this->connections[Facing::WEST]) or isset($this->connections[Facing::EAST])){
|
||||
$bb = AxisAlignedBB::one()->squash(Facing::AXIS_Z, $inset);
|
||||
$bb = AxisAlignedBB::one()->squash(Axis::Z, $inset);
|
||||
|
||||
if(!isset($this->connections[Facing::WEST])){
|
||||
$bb->trim(Facing::WEST, $inset);
|
||||
@ -62,7 +63,7 @@ class Thin extends Transparent{
|
||||
}
|
||||
|
||||
if(isset($this->connections[Facing::NORTH]) or isset($this->connections[Facing::SOUTH])){
|
||||
$bb = AxisAlignedBB::one()->squash(Facing::AXIS_X, $inset);
|
||||
$bb = AxisAlignedBB::one()->squash(Axis::X, $inset);
|
||||
|
||||
if(!isset($this->connections[Facing::NORTH])){
|
||||
$bb->trim(Facing::NORTH, $inset);
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -60,7 +61,7 @@ class TripwireHook extends Flowable{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(Facing::axis($face) !== Facing::AXIS_Y){
|
||||
if(Facing::axis($face) !== Axis::Y){
|
||||
//TODO: check face is valid
|
||||
$this->facing = $face;
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -89,7 +90,7 @@ class Vine extends Flowable{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$blockClicked->isSolid() or Facing::axis($face) === Facing::AXIS_Y){
|
||||
if(!$blockClicked->isSolid() or Facing::axis($face) === Axis::Y){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\ToolTier;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
final class BlockDataSerializer{
|
||||
@ -69,14 +70,14 @@ final class BlockDataSerializer{
|
||||
*/
|
||||
public static function readHorizontalFacing(int $facing) : int{
|
||||
$facing = self::readFacing($facing);
|
||||
if(Facing::axis($facing) === Facing::AXIS_Y){
|
||||
if(Facing::axis($facing) === Axis::Y){
|
||||
throw new InvalidBlockStateException("Invalid Y-axis facing $facing");
|
||||
}
|
||||
return $facing;
|
||||
}
|
||||
|
||||
public static function writeHorizontalFacing(int $facing) : int{
|
||||
if(Facing::axis($facing) === Facing::AXIS_Y){
|
||||
if(Facing::axis($facing) === Axis::Y){
|
||||
throw new \InvalidArgumentException("Invalid Y-axis facing");
|
||||
}
|
||||
return self::writeFacing($facing);
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\block\utils;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -33,7 +34,7 @@ use pocketmine\world\BlockTransaction;
|
||||
trait PillarRotationTrait{
|
||||
|
||||
/** @var int */
|
||||
protected $axis = Facing::AXIS_Y;
|
||||
protected $axis = Axis::Y;
|
||||
|
||||
protected function getAxisMetaShift() : int{
|
||||
return 2; //default
|
||||
@ -62,9 +63,9 @@ trait PillarRotationTrait{
|
||||
|
||||
protected function readAxisFromMeta(int $meta) : void{
|
||||
static $map = [
|
||||
0 => Facing::AXIS_Y,
|
||||
1 => Facing::AXIS_X,
|
||||
2 => Facing::AXIS_Z
|
||||
0 => Axis::Y,
|
||||
1 => Axis::X,
|
||||
2 => Axis::Z
|
||||
];
|
||||
$axis = $meta >> $this->getAxisMetaShift();
|
||||
if(!isset($map[$axis])){
|
||||
@ -75,9 +76,9 @@ trait PillarRotationTrait{
|
||||
|
||||
protected function writeAxisToMeta() : int{
|
||||
static $bits = [
|
||||
Facing::AXIS_Y => 0,
|
||||
Facing::AXIS_Z => 2,
|
||||
Facing::AXIS_X => 1
|
||||
Axis::Y => 0,
|
||||
Axis::Z => 2,
|
||||
Axis::X => 1
|
||||
];
|
||||
return $bits[$this->axis] << $this->getAxisMetaShift();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\block\Block;
|
||||
use pocketmine\entity\Location;
|
||||
use pocketmine\entity\object\Painting;
|
||||
use pocketmine\entity\object\PaintingMotive;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -37,7 +38,7 @@ use function count;
|
||||
class PaintingItem extends Item{
|
||||
|
||||
public function onActivate(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
|
||||
if(Facing::axis($face) === Facing::AXIS_Y){
|
||||
if(Facing::axis($face) === Axis::Y){
|
||||
return ItemUseResult::NONE();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user