mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 13:25:16 +00:00
Revert "ItemBlock: drop the charade about overriding built-in block types"
This reverts commit f64dc01bd1c14ff3f79bd6c18d0c337dbc0e87e0. I forgot that the ItemBlock constructor implicitly strips off any states of the origin block, which is something that we unfortunately can't do any other way right now, since the blocks don't remember their default states.
This commit is contained in:
parent
f64dc01bd1
commit
7c974a12e1
@ -51,11 +51,11 @@ class Anvil extends Transparent implements Fallable{
|
|||||||
|
|
||||||
private int $damage = self::UNDAMAGED;
|
private int $damage = self::UNDAMAGED;
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED, $this->damage);
|
$w->boundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED, $this->damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class Bamboo extends Transparent{
|
|||||||
protected bool $ready = false;
|
protected bool $ready = false;
|
||||||
protected int $leafSize = self::NO_LEAVES;
|
protected int $leafSize = self::NO_LEAVES;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(2, self::NO_LEAVES, self::LARGE_LEAVES, $this->leafSize);
|
$w->boundedInt(2, self::NO_LEAVES, self::LARGE_LEAVES, $this->leafSize);
|
||||||
$w->bool($this->thick);
|
$w->bool($this->thick);
|
||||||
$w->bool($this->ready);
|
$w->bool($this->ready);
|
||||||
|
@ -36,7 +36,7 @@ use pocketmine\world\BlockTransaction;
|
|||||||
final class BambooSapling extends Flowable{
|
final class BambooSapling extends Flowable{
|
||||||
private bool $ready = false;
|
private bool $ready = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->ready);
|
$w->bool($this->ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class Barrel extends Opaque{
|
|||||||
|
|
||||||
protected bool $open = false;
|
protected bool $open = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->facing($this->facing);
|
$w->facing($this->facing);
|
||||||
$w->bool($this->open);
|
$w->bool($this->open);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ class Bed extends Transparent{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->bool($this->occupied);
|
$w->bool($this->occupied);
|
||||||
$w->bool($this->head);
|
$w->bool($this->head);
|
||||||
|
@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
class Bedrock extends Opaque{
|
class Bedrock extends Opaque{
|
||||||
private bool $burnsForever = false;
|
private bool $burnsForever = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->burnsForever);
|
$w->bool($this->burnsForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ final class Bell extends Transparent{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bellAttachmentType($this->attachmentType);
|
$w->bellAttachmentType($this->attachmentType);
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
}
|
}
|
||||||
|
@ -214,11 +214,11 @@ class Block{
|
|||||||
return $writer->getValue();
|
return $writer->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
//NOOP
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
//NOOP
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class BrewingStand extends Transparent{
|
|||||||
*/
|
*/
|
||||||
protected array $slots = [];
|
protected array $slots = [];
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->brewingStandSlots($this->slots);
|
$w->brewingStandSlots($this->slots);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ abstract class Button extends Flowable{
|
|||||||
|
|
||||||
protected bool $pressed = false;
|
protected bool $pressed = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->facing($this->facing);
|
$w->facing($this->facing);
|
||||||
$w->bool($this->pressed);
|
$w->bool($this->pressed);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class Cactus extends Transparent{
|
|||||||
|
|
||||||
protected int $age = 0;
|
protected int $age = 0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
|
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class Cake extends BaseCake{
|
|||||||
|
|
||||||
protected int $bites = 0;
|
protected int $bites = 0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(3, 0, self::MAX_BITES, $this->bites);
|
$w->boundedInt(3, 0, self::MAX_BITES, $this->bites);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class Candle extends Transparent{
|
|||||||
|
|
||||||
private int $count = self::MIN_COUNT;
|
private int $count = self::MIN_COUNT;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$this->encodeLitState($w);
|
$this->encodeLitState($w);
|
||||||
$w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
|
$w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ final class ChorusFlower extends Flowable{
|
|||||||
|
|
||||||
private int $age = self::MIN_AGE;
|
private int $age = self::MIN_AGE;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(3, self::MIN_AGE, self::MAX_AGE, $this->age);
|
$w->boundedInt(3, self::MIN_AGE, self::MAX_AGE, $this->age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class CocoaBlock extends Transparent{
|
|||||||
|
|
||||||
protected int $age = 0;
|
protected int $age = 0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
|
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ abstract class Crops extends Flowable{
|
|||||||
|
|
||||||
protected int $age = 0;
|
protected int $age = 0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(3, 0, self::MAX_AGE, $this->age);
|
$w->boundedInt(3, 0, self::MAX_AGE, $this->age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class DaylightSensor extends Transparent{
|
|||||||
|
|
||||||
protected bool $inverted = false;
|
protected bool $inverted = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(4, 0, 15, $this->signalStrength);
|
$w->boundedInt(4, 0, 15, $this->signalStrength);
|
||||||
$w->bool($this->inverted);
|
$w->bool($this->inverted);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
class DetectorRail extends StraightOnlyRail{
|
class DetectorRail extends StraightOnlyRail{
|
||||||
protected bool $activated = false;
|
protected bool $activated = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
parent::describeState($w);
|
parent::describeState($w);
|
||||||
$w->bool($this->activated);
|
$w->bool($this->activated);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class Dirt extends Opaque{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->dirtType($this->dirtType);
|
$w->dirtType($this->dirtType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class Door extends Transparent{
|
|||||||
protected bool $hingeRight = false;
|
protected bool $hingeRight = false;
|
||||||
protected bool $open = false;
|
protected bool $open = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->bool($this->top);
|
$w->bool($this->top);
|
||||||
$w->bool($this->hingeRight);
|
$w->bool($this->hingeRight);
|
||||||
|
@ -33,7 +33,7 @@ use pocketmine\world\BlockTransaction;
|
|||||||
class DoublePlant extends Flowable{
|
class DoublePlant extends Flowable{
|
||||||
protected bool $top = false;
|
protected bool $top = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->top);
|
$w->bool($this->top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class EndPortalFrame extends Opaque{
|
|||||||
|
|
||||||
protected bool $eye = false;
|
protected bool $eye = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->bool($this->eye);
|
$w->bool($this->eye);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ class Farmland extends Transparent{
|
|||||||
|
|
||||||
protected int $wetness = 0; //"moisture" blockstate property in PC
|
protected int $wetness = 0; //"moisture" blockstate property in PC
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(3, 0, self::MAX_WETNESS, $this->wetness);
|
$w->boundedInt(3, 0, self::MAX_WETNESS, $this->wetness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class FenceGate extends Transparent{
|
|||||||
protected bool $open = false;
|
protected bool $open = false;
|
||||||
protected bool $inWall = false;
|
protected bool $inWall = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->bool($this->open);
|
$w->bool($this->open);
|
||||||
$w->bool($this->inWall);
|
$w->bool($this->inWall);
|
||||||
|
@ -37,7 +37,7 @@ abstract class FillableCauldron extends Transparent{
|
|||||||
|
|
||||||
private int $fillLevel = self::MIN_FILL_LEVEL;
|
private int $fillLevel = self::MIN_FILL_LEVEL;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(3, self::MIN_FILL_LEVEL, self::MAX_FILL_LEVEL, $this->fillLevel);
|
$w->boundedInt(3, self::MIN_FILL_LEVEL, self::MAX_FILL_LEVEL, $this->fillLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class Fire extends BaseFire{
|
|||||||
|
|
||||||
protected int $age = 0;
|
protected int $age = 0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
|
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ use function rad2deg;
|
|||||||
final class FloorCoralFan extends BaseCoral{
|
final class FloorCoralFan extends BaseCoral{
|
||||||
private int $axis = Axis::X;
|
private int $axis = Axis::X;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalAxis($this->axis);
|
$w->horizontalAxis($this->axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ final class Froglight extends SimplePillar{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->froglightType($this->froglightType);
|
$w->froglightType($this->froglightType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class FrostedIce extends Ice{
|
|||||||
|
|
||||||
protected int $age = 0;
|
protected int $age = 0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
|
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class Furnace extends Opaque{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->bool($this->lit);
|
$w->bool($this->lit);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class Hopper extends Transparent{
|
|||||||
|
|
||||||
private int $facing = Facing::DOWN;
|
private int $facing = Facing::DOWN;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->facingExcept($this->facing, Facing::UP);
|
$w->facingExcept($this->facing, Facing::UP);
|
||||||
$w->bool($this->powered);
|
$w->bool($this->powered);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class ItemFrame extends Flowable{
|
|||||||
protected int $itemRotation = 0;
|
protected int $itemRotation = 0;
|
||||||
protected float $itemDropChance = 1.0;
|
protected float $itemDropChance = 1.0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->facing($this->facing);
|
$w->facing($this->facing);
|
||||||
$w->bool($this->hasMap);
|
$w->bool($this->hasMap);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class Lantern extends Transparent{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->hanging);
|
$w->bool($this->hanging);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class Leaves extends Transparent{
|
|||||||
$this->leavesType = $leavesType;
|
$this->leavesType = $leavesType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->noDecay);
|
$w->bool($this->noDecay);
|
||||||
$w->bool($this->checkDecay);
|
$w->bool($this->checkDecay);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class Lectern extends Transparent{
|
|||||||
|
|
||||||
protected bool $producingSignal = false;
|
protected bool $producingSignal = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->bool($this->producingSignal);
|
$w->bool($this->producingSignal);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class Lever extends Flowable{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->leverFacing($this->facing);
|
$w->leverFacing($this->facing);
|
||||||
$w->bool($this->activated);
|
$w->bool($this->activated);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ final class Light extends Flowable{
|
|||||||
|
|
||||||
private int $level = self::MAX_LIGHT_LEVEL;
|
private int $level = self::MAX_LIGHT_LEVEL;
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(4, self::MIN_LIGHT_LEVEL, self::MAX_LIGHT_LEVEL, $this->level);
|
$w->boundedInt(4, self::MIN_LIGHT_LEVEL, self::MAX_LIGHT_LEVEL, $this->level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ abstract class Liquid extends Transparent{
|
|||||||
protected int $decay = 0; //PC "level" property
|
protected int $decay = 0; //PC "level" property
|
||||||
protected bool $still = false;
|
protected bool $still = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(3, 0, self::MAX_DECAY, $this->decay);
|
$w->boundedInt(3, 0, self::MAX_DECAY, $this->decay);
|
||||||
$w->bool($this->falling);
|
$w->bool($this->falling);
|
||||||
$w->bool($this->still);
|
$w->bool($this->still);
|
||||||
|
@ -34,7 +34,7 @@ class NetherPortal extends Transparent{
|
|||||||
|
|
||||||
protected int $axis = Axis::X;
|
protected int $axis = Axis::X;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalAxis($this->axis);
|
$w->horizontalAxis($this->axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class NetherWartPlant extends Flowable{
|
|||||||
|
|
||||||
protected int $age = 0;
|
protected int $age = 0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
|
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class Rail extends BaseRail{
|
|||||||
|
|
||||||
private int $railShape = BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH;
|
private int $railShape = BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->railShape($this->railShape);
|
$w->railShape($this->railShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class RedMushroomBlock extends Opaque{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->mushroomBlockType($this->mushroomBlockType);
|
$w->mushroomBlockType($this->mushroomBlockType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class RedstoneComparator extends Flowable{
|
|||||||
|
|
||||||
protected bool $isSubtractMode = false;
|
protected bool $isSubtractMode = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->bool($this->isSubtractMode);
|
$w->bool($this->isSubtractMode);
|
||||||
$w->bool($this->powered);
|
$w->bool($this->powered);
|
||||||
|
@ -29,7 +29,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
class RedstoneLamp extends Opaque{
|
class RedstoneLamp extends Opaque{
|
||||||
use PoweredByRedstoneTrait;
|
use PoweredByRedstoneTrait;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->powered);
|
$w->bool($this->powered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ use function mt_rand;
|
|||||||
class RedstoneOre extends Opaque{
|
class RedstoneOre extends Opaque{
|
||||||
protected bool $lit = false;
|
protected bool $lit = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->lit);
|
$w->bool($this->lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class RedstoneRepeater extends Flowable{
|
|||||||
|
|
||||||
protected int $delay = self::MIN_DELAY;
|
protected int $delay = self::MIN_DELAY;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->boundedInt(2, self::MIN_DELAY, self::MAX_DELAY, $this->delay);
|
$w->boundedInt(2, self::MIN_DELAY, self::MAX_DELAY, $this->delay);
|
||||||
$w->bool($this->powered);
|
$w->bool($this->powered);
|
||||||
|
@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
class RedstoneTorch extends Torch{
|
class RedstoneTorch extends Torch{
|
||||||
protected bool $lit = true;
|
protected bool $lit = true;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
parent::describeState($w);
|
parent::describeState($w);
|
||||||
$w->bool($this->lit);
|
$w->bool($this->lit);
|
||||||
}
|
}
|
||||||
|
@ -151,6 +151,18 @@ class RuntimeBlockStateRegistry{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* Returns the default state of the block type associated with the given type ID.
|
||||||
|
*/
|
||||||
|
public function fromTypeId(int $typeId) : Block{
|
||||||
|
if(isset($this->typeIndex[$typeId])){
|
||||||
|
return clone $this->typeIndex[$typeId];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \InvalidArgumentException("Block ID $typeId is not registered");
|
||||||
|
}
|
||||||
|
|
||||||
public function fromStateId(int $stateId) : Block{
|
public function fromStateId(int $stateId) : Block{
|
||||||
if($stateId < 0){
|
if($stateId < 0){
|
||||||
throw new \InvalidArgumentException("Block state ID cannot be negative");
|
throw new \InvalidArgumentException("Block state ID cannot be negative");
|
||||||
@ -166,6 +178,22 @@ class RuntimeBlockStateRegistry{
|
|||||||
return $block;
|
return $block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether a specified block state is already registered in the block factory.
|
||||||
|
*/
|
||||||
|
public function isRegistered(int $typeId) : bool{
|
||||||
|
$b = $this->typeIndex[$typeId] ?? null;
|
||||||
|
return $b !== null && !($b instanceof UnknownBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Block[]
|
||||||
|
* @phpstan-return array<int, Block>
|
||||||
|
*/
|
||||||
|
public function getAllKnownTypes() : array{
|
||||||
|
return $this->typeIndex;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Block[]
|
* @return Block[]
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +46,7 @@ class Sapling extends Flowable{
|
|||||||
$this->treeType = $treeType;
|
$this->treeType = $treeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->ready);
|
$w->bool($this->ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class SeaPickle extends Transparent{
|
|||||||
protected int $count = self::MIN_COUNT;
|
protected int $count = self::MIN_COUNT;
|
||||||
protected bool $underwater = false;
|
protected bool $underwater = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
|
$w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
|
||||||
$w->bool($this->underwater);
|
$w->bool($this->underwater);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ use pocketmine\world\BlockTransaction;
|
|||||||
class ShulkerBox extends Opaque{
|
class ShulkerBox extends Opaque{
|
||||||
use AnyFacingTrait;
|
use AnyFacingTrait;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
//NOOP - we don't read or write facing here, because the tile persists it
|
//NOOP - we don't read or write facing here, because the tile persists it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
abstract class SimplePressurePlate extends PressurePlate{
|
abstract class SimplePressurePlate extends PressurePlate{
|
||||||
protected bool $pressed = false;
|
protected bool $pressed = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->pressed);
|
$w->bool($this->pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +49,11 @@ class Skull extends Flowable{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->skullType($this->skullType);
|
$w->skullType($this->skullType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->facingExcept($this->facing, Facing::DOWN);
|
$w->facingExcept($this->facing, Facing::DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class Slab extends Transparent{
|
|||||||
$this->slabType = SlabType::BOTTOM();
|
$this->slabType = SlabType::BOTTOM();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->slabType($this->slabType);
|
$w->slabType($this->slabType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class SnowLayer extends Flowable implements Fallable{
|
|||||||
|
|
||||||
protected int $layers = self::MIN_LAYERS;
|
protected int $layers = self::MIN_LAYERS;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(3, self::MIN_LAYERS, self::MAX_LAYERS, $this->layers);
|
$w->boundedInt(3, self::MIN_LAYERS, self::MAX_LAYERS, $this->layers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
class Sponge extends Opaque{
|
class Sponge extends Opaque{
|
||||||
protected bool $wet = false;
|
protected bool $wet = false;
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->wet);
|
$w->bool($this->wet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class Stair extends Transparent{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->bool($this->upsideDown);
|
$w->bool($this->upsideDown);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class StraightOnlyRail extends BaseRail{
|
|||||||
|
|
||||||
private int $railShape = BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH;
|
private int $railShape = BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->straightOnlyRailShape($this->railShape);
|
$w->straightOnlyRailShape($this->railShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class Sugarcane extends Flowable{
|
|||||||
|
|
||||||
protected int $age = 0;
|
protected int $age = 0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
|
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class SweetBerryBush extends Flowable{
|
|||||||
|
|
||||||
protected int $age = self::STAGE_SAPLING;
|
protected int $age = self::STAGE_SAPLING;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(3, self::STAGE_SAPLING, self::STAGE_MATURE, $this->age);
|
$w->boundedInt(3, self::STAGE_SAPLING, self::STAGE_MATURE, $this->age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +45,11 @@ class TNT extends Opaque{
|
|||||||
protected bool $unstable = false; //TODO: Usage unclear, seems to be a weird hack in vanilla
|
protected bool $unstable = false; //TODO: Usage unclear, seems to be a weird hack in vanilla
|
||||||
protected bool $worksUnderwater = false;
|
protected bool $worksUnderwater = false;
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->worksUnderwater);
|
$w->bool($this->worksUnderwater);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->unstable);
|
$w->bool($this->unstable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class Torch extends Flowable{
|
|||||||
|
|
||||||
protected int $facing = Facing::UP;
|
protected int $facing = Facing::UP;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->facingExcept($this->facing, Facing::DOWN);
|
$w->facingExcept($this->facing, Facing::DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class Trapdoor extends Transparent{
|
|||||||
protected bool $open = false;
|
protected bool $open = false;
|
||||||
protected bool $top = false;
|
protected bool $top = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->bool($this->top);
|
$w->bool($this->top);
|
||||||
$w->bool($this->open);
|
$w->bool($this->open);
|
||||||
|
@ -33,7 +33,7 @@ class Tripwire extends Flowable{
|
|||||||
protected bool $connected = false;
|
protected bool $connected = false;
|
||||||
protected bool $disarmed = false;
|
protected bool $disarmed = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->triggered);
|
$w->bool($this->triggered);
|
||||||
$w->bool($this->suspended);
|
$w->bool($this->suspended);
|
||||||
$w->bool($this->connected);
|
$w->bool($this->connected);
|
||||||
|
@ -38,7 +38,7 @@ class TripwireHook extends Flowable{
|
|||||||
protected bool $connected = false;
|
protected bool $connected = false;
|
||||||
protected bool $powered = false;
|
protected bool $powered = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
$w->bool($this->connected);
|
$w->bool($this->connected);
|
||||||
$w->bool($this->powered);
|
$w->bool($this->powered);
|
||||||
|
@ -38,7 +38,7 @@ class UnknownBlock extends Transparent{
|
|||||||
$this->stateData = $stateData;
|
$this->stateData = $stateData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
//use type instead of state, so we don't lose any information like colour
|
//use type instead of state, so we don't lose any information like colour
|
||||||
//this might be an improperly registered plugin block
|
//this might be an improperly registered plugin block
|
||||||
$w->int(Block::INTERNAL_STATE_DATA_BITS, $this->stateData);
|
$w->int(Block::INTERNAL_STATE_DATA_BITS, $this->stateData);
|
||||||
|
@ -39,7 +39,7 @@ class Vine extends Flowable{
|
|||||||
/** @var int[] */
|
/** @var int[] */
|
||||||
protected array $faces = [];
|
protected array $faces = [];
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacingFlags($this->faces);
|
$w->horizontalFacingFlags($this->faces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class Wall extends Transparent{
|
|||||||
protected array $connections = [];
|
protected array $connections = [];
|
||||||
protected bool $post = false;
|
protected bool $post = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->wallConnections($this->connections);
|
$w->wallConnections($this->connections);
|
||||||
$w->bool($this->post);
|
$w->bool($this->post);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ use pocketmine\world\BlockTransaction;
|
|||||||
final class WallCoralFan extends BaseCoral{
|
final class WallCoralFan extends BaseCoral{
|
||||||
use HorizontalFacingTrait;
|
use HorizontalFacingTrait;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class Wood extends Opaque{
|
|||||||
|
|
||||||
private bool $stripped = false;
|
private bool $stripped = false;
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->stripped);
|
$w->bool($this->stripped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
trait AnalogRedstoneSignalEmitterTrait{
|
trait AnalogRedstoneSignalEmitterTrait{
|
||||||
protected int $signalStrength = 0;
|
protected int $signalStrength = 0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(4, 0, 15, $this->signalStrength);
|
$w->boundedInt(4, 0, 15, $this->signalStrength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ use pocketmine\math\Facing;
|
|||||||
trait AnyFacingTrait{
|
trait AnyFacingTrait{
|
||||||
protected int $facing = Facing::DOWN;
|
protected int $facing = Facing::DOWN;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->facing($this->facing);
|
$w->facing($this->facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ use pocketmine\world\sound\FlintSteelSound;
|
|||||||
trait CandleTrait{
|
trait CandleTrait{
|
||||||
private bool $lit = false;
|
private bool $lit = false;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->lit);
|
$w->bool($this->lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ trait ColoredTrait{
|
|||||||
private $color;
|
private $color;
|
||||||
|
|
||||||
/** @see Block::describeType() */
|
/** @see Block::describeType() */
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->dyeColor($this->color);
|
$w->dyeColor($this->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ trait CopperTrait{
|
|||||||
parent::__construct($identifier, $name, $typeInfo);
|
parent::__construct($identifier, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->copperOxidation($this->oxidation);
|
$w->copperOxidation($this->oxidation);
|
||||||
$w->bool($this->waxed);
|
$w->bool($this->waxed);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ trait CoralTypeTrait{
|
|||||||
protected bool $dead = false;
|
protected bool $dead = false;
|
||||||
|
|
||||||
/** @see Block::describeType() */
|
/** @see Block::describeType() */
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$w->coralType($this->coralType);
|
$w->coralType($this->coralType);
|
||||||
$w->bool($this->dead);
|
$w->bool($this->dead);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ use pocketmine\math\Facing;
|
|||||||
trait HorizontalFacingTrait{
|
trait HorizontalFacingTrait{
|
||||||
protected int $facing = Facing::NORTH;
|
protected int $facing = Facing::NORTH;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ use pocketmine\world\BlockTransaction;
|
|||||||
trait PillarRotationTrait{
|
trait PillarRotationTrait{
|
||||||
protected int $axis = Axis::Y;
|
protected int $axis = Axis::Y;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->axis($this->axis);
|
$w->axis($this->axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
trait RailPoweredByRedstoneTrait{
|
trait RailPoweredByRedstoneTrait{
|
||||||
use PoweredByRedstoneTrait;
|
use PoweredByRedstoneTrait;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
parent::describeState($w);
|
parent::describeState($w);
|
||||||
$w->bool($this->powered);
|
$w->bool($this->powered);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ trait SignLikeRotationTrait{
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
private $rotation = 0;
|
private $rotation = 0;
|
||||||
|
|
||||||
public function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(4, 0, 15, $this->rotation);
|
$w->boundedInt(4, 0, 15, $this->rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
|
use pocketmine\block\RuntimeBlockStateRegistry;
|
||||||
|
use pocketmine\block\VanillaBlocks;
|
||||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,29 +35,47 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
* just place wheat crops when used on the ground).
|
* just place wheat crops when used on the ground).
|
||||||
*/
|
*/
|
||||||
final class ItemBlock extends Item{
|
final class ItemBlock extends Item{
|
||||||
public function __construct(
|
private int $blockTypeId;
|
||||||
private Block $block
|
private int $blockTypeData;
|
||||||
){
|
|
||||||
|
private int $fuelTime;
|
||||||
|
private bool $fireProof;
|
||||||
|
private int $maxStackSize;
|
||||||
|
|
||||||
|
public function __construct(Block $block){
|
||||||
parent::__construct(ItemIdentifier::fromBlock($block), $block->getName());
|
parent::__construct(ItemIdentifier::fromBlock($block), $block->getName());
|
||||||
|
$this->blockTypeId = $block->getTypeId();
|
||||||
|
$this->blockTypeData = $block->computeTypeData();
|
||||||
|
|
||||||
|
$this->fuelTime = $block->getFuelTime();
|
||||||
|
$this->fireProof = $block->isFireProofAsItem();
|
||||||
|
$this->maxStackSize = $block->getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeType(RuntimeDataDescriber $w) : void{
|
||||||
$this->block->describeType($w);
|
$w->int(Block::INTERNAL_STATE_DATA_BITS, $this->blockTypeData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBlock(?int $clickedFace = null) : Block{
|
public function getBlock(?int $clickedFace = null) : Block{
|
||||||
return clone $this->block;
|
//TODO: HACKY MESS, CLEAN IT UP
|
||||||
|
$factory = RuntimeBlockStateRegistry::getInstance();
|
||||||
|
if(!$factory->isRegistered($this->blockTypeId)){
|
||||||
|
return VanillaBlocks::AIR();
|
||||||
|
}
|
||||||
|
$blockType = $factory->fromTypeId($this->blockTypeId);
|
||||||
|
$blockType->decodeTypeData($this->blockTypeData);
|
||||||
|
return $blockType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFuelTime() : int{
|
public function getFuelTime() : int{
|
||||||
return $this->block->getFuelTime();
|
return $this->fuelTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isFireProof() : bool{
|
public function isFireProof() : bool{
|
||||||
return $this->block->isFireProofAsItem();
|
return $this->fireProof;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxStackSize() : int{
|
public function getMaxStackSize() : int{
|
||||||
return $this->block->getMaxStackSize();
|
return $this->maxStackSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,16 @@ class BlockTest extends TestCase{
|
|||||||
* Test registering a new block which does not yet exist
|
* Test registering a new block which does not yet exist
|
||||||
*/
|
*/
|
||||||
public function testRegisterNewBlock() : void{
|
public function testRegisterNewBlock() : void{
|
||||||
$b = new StrangeNewBlock(new BlockIdentifier(BlockTypeIds::newId()), "Strange New Block", new BlockTypeInfo(BlockBreakInfo::instant()));
|
for($i = BlockTypeIds::FIRST_UNUSED_BLOCK_ID; $i < BlockTypeIds::FIRST_UNUSED_BLOCK_ID + 256; ++$i){
|
||||||
|
if(!$this->blockFactory->isRegistered($i)){
|
||||||
|
$b = new StrangeNewBlock(new BlockIdentifier($i), "Strange New Block", new BlockTypeInfo(BlockBreakInfo::instant()));
|
||||||
$this->blockFactory->register($b);
|
$this->blockFactory->register($b);
|
||||||
self::assertInstanceOf(StrangeNewBlock::class, $this->blockFactory->fromStateId($b->getStateId()));
|
self::assertInstanceOf(StrangeNewBlock::class, $this->blockFactory->fromStateId($b->getStateId()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \RuntimeException("Can't test registering new blocks because no unused spaces left");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user