Cram Nether Portal

again, this is here for the state handling and the implementation is unfinished.
This commit is contained in:
Dylan K. Taylor 2019-02-25 10:54:48 +00:00
parent 74e134136d
commit 1e096a408a
2 changed files with 97 additions and 0 deletions

View File

@ -213,6 +213,7 @@ class BlockFactory{
self::register(new NetherBrick(new BID(Block::RED_NETHER_BRICK), "Red Nether Bricks"));
self::register(new NetherBrickFence(new BID(Block::NETHER_BRICK_FENCE), "Nether Brick Fence"));
self::register(new NetherBrickStairs(new BID(Block::NETHER_BRICK_STAIRS), "Nether Brick Stairs"));
self::register(new NetherPortal(new BID(Block::PORTAL), "Nether Portal"));
self::register(new NetherQuartzOre(new BID(Block::NETHER_QUARTZ_ORE), "Nether Quartz Ore"));
self::register(new NetherReactor(new BID(Block::NETHERREACTOR), "Nether Reactor Core"));
self::register(new NetherWartBlock(new BID(Block::NETHER_WART_BLOCK), "Nether Wart Block"));

View File

@ -0,0 +1,96 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
class NetherPortal extends Transparent{
/** @var int */
protected $axis = Facing::AXIS_X;
public function readStateFromData(int $id, int $stateMeta) : void{
$this->axis = $stateMeta === 2 ? Facing::AXIS_Z : Facing::AXIS_X; //mojang u dumb
}
protected function writeStateToMeta() : int{
return $this->axis === Facing::AXIS_Z ? 2 : 1;
}
public function getStateBitmask() : int{
return 0b11;
}
/**
* @return int
*/
public function getAxis() : int{
return $this->axis;
}
/**
* @param int $axis
* @throws \InvalidArgumentException
*/
public function setAxis(int $axis) : void{
if($axis !== Facing::AXIS_X and $axis !== Facing::AXIS_Z){
throw new \InvalidArgumentException("Invalid axis");
}
$this->axis = $axis;
}
public function getLightLevel() : int{
return 11;
}
public function isSolid() : bool{
return false;
}
public function getBoundingBox() : ?AxisAlignedBB{
return null;
}
public function isBreakable(Item $item) : bool{
return false;
}
public function getHardness() : float{
return -1;
}
public function getBlastResistance() : float{
return 0;
}
public function getDrops(Item $item) : array{
return [];
}
public function onEntityInside(Entity $entity) : void{
//TODO
}
}