mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 17:59:41 +00:00
Hacks for dealing with negative item IDs...
This commit is contained in:
parent
9d2e9e1663
commit
ed1c511c3c
@ -111,7 +111,13 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getItemId() : int{
|
public function getItemId() : int{
|
||||||
return $this->itemId ?? $this->getId();
|
if($this->itemId !== null){
|
||||||
|
return $this->itemId;
|
||||||
|
}
|
||||||
|
if($this->id > 255){
|
||||||
|
return 255 - $this->id;
|
||||||
|
}
|
||||||
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,14 +61,14 @@ class BlockFactory{
|
|||||||
* this if you need to reset the block factory back to its original defaults for whatever reason.
|
* this if you need to reset the block factory back to its original defaults for whatever reason.
|
||||||
*/
|
*/
|
||||||
public static function init() : void{
|
public static function init() : void{
|
||||||
self::$fullList = new \SplFixedArray(4096);
|
self::$fullList = new \SplFixedArray(8192);
|
||||||
self::$getInterceptors = new \SplFixedArray(4096);
|
self::$getInterceptors = new \SplFixedArray(8192);
|
||||||
|
|
||||||
self::$lightFilter = \SplFixedArray::fromArray(array_fill(0, 256, 1));
|
self::$lightFilter = \SplFixedArray::fromArray(array_fill(0, 512, 1));
|
||||||
self::$diffusesSkyLight = \SplFixedArray::fromArray(array_fill(0, 256, false));
|
self::$diffusesSkyLight = \SplFixedArray::fromArray(array_fill(0, 512, false));
|
||||||
self::$blastResistance = \SplFixedArray::fromArray(array_fill(0, 256, 0));
|
self::$blastResistance = \SplFixedArray::fromArray(array_fill(0, 512, 0));
|
||||||
|
|
||||||
self::$stateMasks = \SplFixedArray::fromArray(array_fill(0, 256, 0));
|
self::$stateMasks = \SplFixedArray::fromArray(array_fill(0, 512, 0));
|
||||||
|
|
||||||
self::registerBlock(new Air());
|
self::registerBlock(new Air());
|
||||||
|
|
||||||
|
@ -39,8 +39,15 @@ class ItemBlock extends Item{
|
|||||||
* @param int|null $itemId
|
* @param int|null $itemId
|
||||||
*/
|
*/
|
||||||
public function __construct(int $blockId, int $meta = 0, int $itemId = null){
|
public function __construct(int $blockId, int $meta = 0, int $itemId = null){
|
||||||
|
if($blockId < 0){ //extended blocks
|
||||||
|
if($itemId === null){
|
||||||
|
$itemId = $blockId;
|
||||||
|
}
|
||||||
|
$blockId = 255 - $blockId;
|
||||||
|
}
|
||||||
$this->blockId = $blockId;
|
$this->blockId = $blockId;
|
||||||
$this->setDamage($meta);
|
$this->setDamage($meta);
|
||||||
|
|
||||||
parent::__construct($itemId ?? $blockId, $meta, $this->getBlock()->getName());
|
parent::__construct($itemId ?? $blockId, $meta, $this->getBlock()->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user