mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 23:29:54 +00:00
Change confusing 'type data' and 'state data' terminology for blocks and items
For blocks, we now use 'block-item state' and 'block-only state', which should be much clearer for people implementing custom stuff. 'block-item state', as the name suggests, sticks to the item when the block is acquired as an item. 'block-only state' applies only to the block and is discarded when the block is acquired as an item. 'type data' for items was also renamed, since 'type' is too ambiguous to be anything but super confusing.
This commit is contained in:
parent
ccb22ceb3f
commit
015c668885
@ -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{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED, $this->damage);
|
$w->boundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED, $this->damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bellAttachmentType($this->attachmentType);
|
$w->bellAttachmentType($this->attachmentType);
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
}
|
}
|
||||||
|
@ -66,9 +66,9 @@ class Block{
|
|||||||
/** @var AxisAlignedBB[]|null */
|
/** @var AxisAlignedBB[]|null */
|
||||||
protected ?array $collisionBoxes = null;
|
protected ?array $collisionBoxes = null;
|
||||||
|
|
||||||
private int $requiredTypeDataBits;
|
private int $requiredBlockItemStateDataBits;
|
||||||
private int $requiredStateDataBits;
|
private int $requiredBlockOnlyStateDataBits;
|
||||||
private int $defaultStateData;
|
private int $defaultBlockOnlyStateData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name English name of the block type (TODO: implement translations)
|
* @param string $name English name of the block type (TODO: implement translations)
|
||||||
@ -80,14 +80,14 @@ class Block{
|
|||||||
$this->position = new Position(0, 0, 0, null);
|
$this->position = new Position(0, 0, 0, null);
|
||||||
|
|
||||||
$calculator = new RuntimeDataSizeCalculator();
|
$calculator = new RuntimeDataSizeCalculator();
|
||||||
$this->describeType($calculator);
|
$this->describeBlockItemState($calculator);
|
||||||
$this->requiredTypeDataBits = $calculator->getBitsUsed();
|
$this->requiredBlockItemStateDataBits = $calculator->getBitsUsed();
|
||||||
|
|
||||||
$calculator = new RuntimeDataSizeCalculator();
|
$calculator = new RuntimeDataSizeCalculator();
|
||||||
$this->describeState($calculator);
|
$this->describeBlockOnlyState($calculator);
|
||||||
$this->requiredStateDataBits = $calculator->getBitsUsed();
|
$this->requiredBlockOnlyStateDataBits = $calculator->getBitsUsed();
|
||||||
|
|
||||||
$this->defaultStateData = $this->computeStateData();
|
$this->defaultBlockOnlyStateData = $this->encodeBlockOnlyState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __clone(){
|
public function __clone(){
|
||||||
@ -111,10 +111,10 @@ class Block{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a type ID that identifies this type of block. This allows comparing basic block types, e.g. wool, stone,
|
* Returns a type ID that identifies this type of block. This allows comparing basic block types, e.g. wool, stone,
|
||||||
* glass, etc.
|
* glass, etc. Type ID will not change for a given block type.
|
||||||
*
|
*
|
||||||
* This does **NOT** include information like facing, open/closed, powered/unpowered, colour, etc. This means that,
|
* Information such as colour, powered, open/closed, etc. is **not** included in this ID.
|
||||||
* for example, red wool and green wool have the same type ID.
|
* If you want to get a state ID that includes this information, use {@link Block::getStateId()} instead.
|
||||||
*
|
*
|
||||||
* @see BlockTypeIds
|
* @see BlockTypeIds
|
||||||
*/
|
*/
|
||||||
@ -129,21 +129,22 @@ class Block{
|
|||||||
* blocks in chunks at runtime.
|
* blocks in chunks at runtime.
|
||||||
*
|
*
|
||||||
* This usually encodes all properties of the block, such as facing, open/closed, powered/unpowered, colour, etc.
|
* This usually encodes all properties of the block, such as facing, open/closed, powered/unpowered, colour, etc.
|
||||||
* However, some blocks (such as signs and chests) may store additional properties in an associated "tile" if they
|
* State ID may change depending on the properties of the block (e.g. a torch facing east will have a different
|
||||||
|
* state ID to one facing west).
|
||||||
|
*
|
||||||
|
* Some blocks (such as signs and chests) may store additional properties in an associated "tile" if they
|
||||||
* have too many possible values to be encoded into the state ID. These extra properties are **NOT** included in
|
* have too many possible values to be encoded into the state ID. These extra properties are **NOT** included in
|
||||||
* this function's result.
|
* this function's result.
|
||||||
*
|
*
|
||||||
* This ID can be used to later obtain a copy of this block using {@link RuntimeBlockStateRegistry::fromStateId()}.
|
* This ID can be used to later obtain a copy of the block with the same state properties by using
|
||||||
|
* {@link RuntimeBlockStateRegistry::fromStateId()}.
|
||||||
*/
|
*/
|
||||||
public function getStateId() : int{
|
public function getStateId() : int{
|
||||||
return ($this->getTypeId() << self::INTERNAL_STATE_DATA_BITS) | $this->computeTypeAndStateData();
|
return ($this->getTypeId() << self::INTERNAL_STATE_DATA_BITS) | $this->encodeFullState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the given block has an equivalent type to this one. This compares the type IDs.
|
* Returns whether the given block has the same type ID as this one.
|
||||||
*
|
|
||||||
* Type properties (e.g. colour, skull type, etc.) are not compared. This means that different colours of wool,
|
|
||||||
* concrete, etc. will all be considered as having the same type.
|
|
||||||
*/
|
*/
|
||||||
public function hasSameTypeId(Block $other) : bool{
|
public function hasSameTypeId(Block $other) : bool{
|
||||||
return $this->getTypeId() === $other->getTypeId();
|
return $this->getTypeId() === $other->getTypeId();
|
||||||
@ -151,6 +152,8 @@ class Block{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the given block has the same type and properties as this block.
|
* Returns whether the given block has the same type and properties as this block.
|
||||||
|
*
|
||||||
|
* Note: Tile data (e.g. sign text, chest contents) are not compared here.
|
||||||
*/
|
*/
|
||||||
public function isSameState(Block $other) : bool{
|
public function isSameState(Block $other) : bool{
|
||||||
return $this->getStateId() === $other->getStateId();
|
return $this->getStateId() === $other->getStateId();
|
||||||
@ -177,69 +180,69 @@ class Block{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the block as an item.
|
* Returns the block as an item.
|
||||||
* State information such as facing, powered/unpowered, open/closed, etc., is discarded.
|
* Block-only state such as facing, powered/unpowered, open/closed, etc., is discarded.
|
||||||
* Type information such as colour, wood type, etc. is preserved.
|
* Block-item state such as colour, wood type, etc. is preserved.
|
||||||
*/
|
*/
|
||||||
public function asItem() : Item{
|
public function asItem() : Item{
|
||||||
$normalized = clone $this;
|
$normalized = clone $this;
|
||||||
$normalized->decodeStateData($this->defaultStateData);
|
$normalized->decodeBlockOnlyState($this->defaultBlockOnlyStateData);
|
||||||
return new ItemBlock($normalized);
|
return new ItemBlock($normalized);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decodeTypeData(int $data) : void{
|
private function decodeBlockItemState(int $data) : void{
|
||||||
$reader = new RuntimeDataReader($this->requiredTypeDataBits, $data);
|
$reader = new RuntimeDataReader($this->requiredBlockItemStateDataBits, $data);
|
||||||
|
|
||||||
$this->describeType($reader);
|
$this->describeBlockItemState($reader);
|
||||||
$readBits = $reader->getOffset();
|
$readBits = $reader->getOffset();
|
||||||
if($this->requiredTypeDataBits !== $readBits){
|
if($this->requiredBlockItemStateDataBits !== $readBits){
|
||||||
throw new \LogicException(get_class($this) . ": Exactly $this->requiredTypeDataBits bits of type data were provided, but $readBits were read");
|
throw new \LogicException(get_class($this) . ": Exactly $this->requiredBlockItemStateDataBits bits of block-item state data were provided, but $readBits were read");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decodeStateData(int $data) : void{
|
private function decodeBlockOnlyState(int $data) : void{
|
||||||
$reader = new RuntimeDataReader($this->requiredStateDataBits, $data);
|
$reader = new RuntimeDataReader($this->requiredBlockOnlyStateDataBits, $data);
|
||||||
|
|
||||||
$this->describeState($reader);
|
$this->describeBlockOnlyState($reader);
|
||||||
$readBits = $reader->getOffset();
|
$readBits = $reader->getOffset();
|
||||||
if($this->requiredStateDataBits !== $readBits){
|
if($this->requiredBlockOnlyStateDataBits !== $readBits){
|
||||||
throw new \LogicException(get_class($this) . ": Exactly $this->requiredStateDataBits bits of state data were provided, but $readBits were read");
|
throw new \LogicException(get_class($this) . ": Exactly $this->requiredBlockOnlyStateDataBits bits of block-only state data were provided, but $readBits were read");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function decodeTypeAndStateData(int $data) : void{
|
private function decodeFullState(int $data) : void{
|
||||||
$reader = new RuntimeDataReader($this->requiredTypeDataBits + $this->requiredStateDataBits, $data);
|
$reader = new RuntimeDataReader($this->requiredBlockItemStateDataBits + $this->requiredBlockOnlyStateDataBits, $data);
|
||||||
$this->decodeTypeData($reader->readInt($this->requiredTypeDataBits));
|
$this->decodeBlockItemState($reader->readInt($this->requiredBlockItemStateDataBits));
|
||||||
$this->decodeStateData($reader->readInt($this->requiredStateDataBits));
|
$this->decodeBlockOnlyState($reader->readInt($this->requiredBlockOnlyStateDataBits));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function computeTypeData() : int{
|
private function encodeBlockItemState() : int{
|
||||||
$writer = new RuntimeDataWriter($this->requiredTypeDataBits);
|
$writer = new RuntimeDataWriter($this->requiredBlockItemStateDataBits);
|
||||||
|
|
||||||
$this->describeType($writer);
|
$this->describeBlockItemState($writer);
|
||||||
$writtenBits = $writer->getOffset();
|
$writtenBits = $writer->getOffset();
|
||||||
if($this->requiredTypeDataBits !== $writtenBits){
|
if($this->requiredBlockItemStateDataBits !== $writtenBits){
|
||||||
throw new \LogicException(get_class($this) . ": Exactly $this->requiredTypeDataBits bits of type data were expected, but $writtenBits were written");
|
throw new \LogicException(get_class($this) . ": Exactly $this->requiredBlockItemStateDataBits bits of block-item state data were expected, but $writtenBits were written");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $writer->getValue();
|
return $writer->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function computeStateData() : int{
|
private function encodeBlockOnlyState() : int{
|
||||||
$writer = new RuntimeDataWriter($this->requiredStateDataBits);
|
$writer = new RuntimeDataWriter($this->requiredBlockOnlyStateDataBits);
|
||||||
|
|
||||||
$this->describeState($writer);
|
$this->describeBlockOnlyState($writer);
|
||||||
$writtenBits = $writer->getOffset();
|
$writtenBits = $writer->getOffset();
|
||||||
if($this->requiredStateDataBits !== $writtenBits){
|
if($this->requiredBlockOnlyStateDataBits !== $writtenBits){
|
||||||
throw new \LogicException(get_class($this) . ": Exactly $this->requiredStateDataBits bits of state data were expected, but $writtenBits were written");
|
throw new \LogicException(get_class($this) . ": Exactly $this->requiredBlockOnlyStateDataBits bits of block-only state data were expected, but $writtenBits were written");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $writer->getValue();
|
return $writer->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function computeTypeAndStateData() : int{
|
private function encodeFullState() : int{
|
||||||
$writer = new RuntimeDataWriter($this->requiredTypeDataBits + $this->requiredStateDataBits);
|
$writer = new RuntimeDataWriter($this->requiredBlockItemStateDataBits + $this->requiredBlockOnlyStateDataBits);
|
||||||
$writer->writeInt($this->requiredTypeDataBits, $this->computeTypeData());
|
$writer->writeInt($this->requiredBlockItemStateDataBits, $this->encodeBlockItemState());
|
||||||
$writer->writeInt($this->requiredStateDataBits, $this->computeStateData());
|
$writer->writeInt($this->requiredBlockOnlyStateDataBits, $this->encodeBlockOnlyState());
|
||||||
|
|
||||||
return $writer->getValue();
|
return $writer->getValue();
|
||||||
}
|
}
|
||||||
@ -252,7 +255,7 @@ class Block{
|
|||||||
* The method implementation must NOT use conditional logic to determine which properties are written. It must
|
* The method implementation must NOT use conditional logic to determine which properties are written. It must
|
||||||
* always write the same properties in the same order, regardless of the current state of the block.
|
* always write the same properties in the same order, regardless of the current state of the block.
|
||||||
*/
|
*/
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
//NOOP
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +267,7 @@ class Block{
|
|||||||
* The method implementation must NOT use conditional logic to determine which properties are written. It must
|
* The method implementation must NOT use conditional logic to determine which properties are written. It must
|
||||||
* always write the same properties in the same order, regardless of the current state of the block.
|
* always write the same properties in the same order, regardless of the current state of the block.
|
||||||
*/
|
*/
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
//NOOP
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,16 +281,16 @@ class Block{
|
|||||||
public function generateStatePermutations() : \Generator{
|
public function generateStatePermutations() : \Generator{
|
||||||
//TODO: this bruteforce approach to discovering all valid states is very inefficient for larger state data sizes
|
//TODO: this bruteforce approach to discovering all valid states is very inefficient for larger state data sizes
|
||||||
//at some point we'll need to find a better way to do this
|
//at some point we'll need to find a better way to do this
|
||||||
$bits = $this->requiredTypeDataBits + $this->requiredStateDataBits;
|
$bits = $this->requiredBlockItemStateDataBits + $this->requiredBlockOnlyStateDataBits;
|
||||||
if($bits > Block::INTERNAL_STATE_DATA_BITS){
|
if($bits > Block::INTERNAL_STATE_DATA_BITS){
|
||||||
throw new \LogicException("Block state data cannot use more than " . Block::INTERNAL_STATE_DATA_BITS . " bits");
|
throw new \LogicException("Block state data cannot use more than " . Block::INTERNAL_STATE_DATA_BITS . " bits");
|
||||||
}
|
}
|
||||||
for($stateData = 0; $stateData < (1 << $bits); ++$stateData){
|
for($stateData = 0; $stateData < (1 << $bits); ++$stateData){
|
||||||
$v = clone $this;
|
$v = clone $this;
|
||||||
try{
|
try{
|
||||||
$v->decodeTypeAndStateData($stateData);
|
$v->decodeFullState($stateData);
|
||||||
if($v->computeTypeAndStateData() !== $stateData){
|
if($v->encodeFullState() !== $stateData){
|
||||||
throw new \LogicException(static::class . "::decodeStateData() accepts invalid state data (returned " . $v->computeTypeAndStateData() . " for input $stateData)");
|
throw new \LogicException(static::class . "::decodeStateData() accepts invalid state data (returned " . $v->encodeFullState() . " for input $stateData)");
|
||||||
}
|
}
|
||||||
}catch(InvalidSerializedRuntimeDataException){ //invalid property combination, leave it
|
}catch(InvalidSerializedRuntimeDataException){ //invalid property combination, leave it
|
||||||
continue;
|
continue;
|
||||||
@ -732,7 +735,7 @@ class Block{
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function __toString(){
|
public function __toString(){
|
||||||
return "Block[" . $this->getName() . "] (" . $this->getTypeId() . ":" . $this->computeTypeAndStateData() . ")";
|
return "Block[" . $this->getName() . "] (" . $this->getTypeId() . ":" . $this->encodeFullState() . ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +43,7 @@ class BrewingStand extends Transparent{
|
|||||||
*/
|
*/
|
||||||
protected array $slots = [];
|
protected array $slots = [];
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(3, 0, self::MAX_BITES, $this->bites);
|
$w->boundedInt(3, 0, self::MAX_BITES, $this->bites);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ use pocketmine\world\BlockTransaction;
|
|||||||
|
|
||||||
class Candle extends Transparent{
|
class Candle extends Transparent{
|
||||||
use CandleTrait {
|
use CandleTrait {
|
||||||
describeState as encodeLitState;
|
describeBlockOnlyState as encodeLitState;
|
||||||
getLightLevel as getBaseLightLevel;
|
getLightLevel as getBaseLightLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class Candle extends Transparent{
|
|||||||
|
|
||||||
private int $count = self::MIN_COUNT;
|
private int $count = self::MIN_COUNT;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class CaveVines extends Flowable{
|
|||||||
protected bool $berries = false;
|
protected bool $berries = false;
|
||||||
protected bool $head = false;
|
protected bool $head = false;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(5, 0, self::MAX_AGE, $this->age);
|
$w->boundedInt(5, 0, self::MAX_AGE, $this->age);
|
||||||
$w->bool($this->berries);
|
$w->bool($this->berries);
|
||||||
$w->bool($this->head);
|
$w->bool($this->head);
|
||||||
|
@ -49,7 +49,7 @@ final class ChorusFlower extends Flowable{
|
|||||||
|
|
||||||
private int $age = self::MIN_AGE;
|
private int $age = self::MIN_AGE;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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,8 +28,8 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
class DetectorRail extends StraightOnlyRail{
|
class DetectorRail extends StraightOnlyRail{
|
||||||
protected bool $activated = false;
|
protected bool $activated = false;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
parent::describeState($w);
|
parent::describeBlockOnlyState($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{
|
public function describeBlockItemState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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{
|
public function describeBlockItemState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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{
|
public function describeBlockItemState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalAxis($this->axis);
|
$w->horizontalAxis($this->axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class NetherVines extends Flowable{
|
|||||||
parent::__construct($idInfo, $name, $typeInfo);
|
parent::__construct($idInfo, $name, $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(5, 0, self::MAX_AGE, $this->age);
|
$w->boundedInt(5, 0, self::MAX_AGE, $this->age);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class NetherWartPlant extends Flowable{
|
|||||||
|
|
||||||
protected int $age = 0;
|
protected int $age = 0;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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 describeType(RuntimeDataDescriber $w) : void{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
//these blocks always drop as all-cap, but may exist in other forms in the inventory (particularly creative),
|
//these blocks always drop as all-cap, but may exist in other forms in the inventory (particularly creative),
|
||||||
//so this information needs to be kept in the type info
|
//so this information needs to be kept in the type info
|
||||||
$w->mushroomBlockType($this->mushroomBlockType);
|
$w->mushroomBlockType($this->mushroomBlockType);
|
||||||
|
@ -44,7 +44,7 @@ class RedstoneComparator extends Flowable{
|
|||||||
|
|
||||||
protected bool $isSubtractMode = false;
|
protected bool $isSubtractMode = false;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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,8 +28,8 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
class RedstoneTorch extends Torch{
|
class RedstoneTorch extends Torch{
|
||||||
protected bool $lit = true;
|
protected bool $lit = true;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
parent::describeState($w);
|
parent::describeBlockOnlyState($w);
|
||||||
$w->bool($this->lit);
|
$w->bool($this->lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class Sapling extends Flowable{
|
|||||||
$this->saplingType = $saplingType;
|
$this->saplingType = $saplingType;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
$w->skullType($this->skullType);
|
$w->skullType($this->skullType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->facingExcept($this->facing, Facing::DOWN);
|
$w->facingExcept($this->facing, Facing::DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class Slab extends Transparent{
|
|||||||
parent::__construct($idInfo, $name . " Slab", $typeInfo);
|
parent::__construct($idInfo, $name . " Slab", $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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{
|
public function describeBlockItemState(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->worksUnderwater);
|
$w->bool($this->worksUnderwater);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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{
|
public function describeBlockItemState(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 = [];
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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{
|
public function describeBlockItemState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bool($this->lit);
|
$w->bool($this->lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ trait ColoredTrait{
|
|||||||
/** @var DyeColor */
|
/** @var DyeColor */
|
||||||
private $color;
|
private $color;
|
||||||
|
|
||||||
/** @see Block::describeType() */
|
/** @see Block::describeBlockItemState() */
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
public function describeBlockItemState(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{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
$w->copperOxidation($this->oxidation);
|
$w->copperOxidation($this->oxidation);
|
||||||
$w->bool($this->waxed);
|
$w->bool($this->waxed);
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@ trait CoralTypeTrait{
|
|||||||
protected CoralType $coralType;
|
protected CoralType $coralType;
|
||||||
protected bool $dead = false;
|
protected bool $dead = false;
|
||||||
|
|
||||||
/** @see Block::describeType() */
|
/** @see Block::describeBlockItemState() */
|
||||||
public function describeType(RuntimeDataDescriber $w) : void{
|
public function describeBlockItemState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->axis($this->axis);
|
$w->axis($this->axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
trait RailPoweredByRedstoneTrait{
|
trait RailPoweredByRedstoneTrait{
|
||||||
use PoweredByRedstoneTrait;
|
use PoweredByRedstoneTrait;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
parent::describeState($w);
|
parent::describeBlockOnlyState($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;
|
||||||
|
|
||||||
protected function describeState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->boundedInt(4, 0, 15, $this->rotation);
|
$w->boundedInt(4, 0, 15, $this->rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class CraftingManager{
|
|||||||
*/
|
*/
|
||||||
public static function sort(Item $i1, Item $i2) : int{
|
public static function sort(Item $i1, Item $i2) : int{
|
||||||
//Use spaceship operator to compare each property, then try the next one if they are equivalent.
|
//Use spaceship operator to compare each property, then try the next one if they are equivalent.
|
||||||
($retval = $i1->getTypeId() <=> $i2->getTypeId()) === 0 && ($retval = $i1->computeTypeData() <=> $i2->computeTypeData()) === 0 && ($retval = $i1->getCount() <=> $i2->getCount()) === 0;
|
($retval = $i1->getTypeId() <=> $i2->getTypeId()) === 0 && ($retval = $i1->computeStateData() <=> $i2->computeStateData()) === 0 && ($retval = $i1->getCount() <=> $i2->getCount()) === 0;
|
||||||
|
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ class CraftingManager{
|
|||||||
foreach($outputs as $o){
|
foreach($outputs as $o){
|
||||||
//count is not written because the outputs might be from multiple repetitions of a single recipe
|
//count is not written because the outputs might be from multiple repetitions of a single recipe
|
||||||
//this reduces the accuracy of the hash, but it won't matter in most cases.
|
//this reduces the accuracy of the hash, but it won't matter in most cases.
|
||||||
$result->putVarInt(morton2d_encode($o->getTypeId(), $o->computeTypeData()));
|
$result->putVarInt(morton2d_encode($o->getTypeId(), $o->computeStateData()));
|
||||||
$result->put((new LittleEndianNbtSerializer())->write(new TreeRoot($o->getNamedTag())));
|
$result->put((new LittleEndianNbtSerializer())->write(new TreeRoot($o->getNamedTag())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,8 +283,8 @@ class CraftingManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function matchBrewingRecipe(Item $input, Item $ingredient) : ?BrewingRecipe{
|
public function matchBrewingRecipe(Item $input, Item $ingredient) : ?BrewingRecipe{
|
||||||
$inputHash = morton2d_encode($input->getTypeId(), $input->computeTypeData());
|
$inputHash = morton2d_encode($input->getTypeId(), $input->computeStateData());
|
||||||
$ingredientHash = morton2d_encode($ingredient->getTypeId(), $ingredient->computeTypeData());
|
$ingredientHash = morton2d_encode($ingredient->getTypeId(), $ingredient->computeStateData());
|
||||||
$cached = $this->brewingRecipeCache[$inputHash][$ingredientHash] ?? null;
|
$cached = $this->brewingRecipeCache[$inputHash][$ingredientHash] ?? null;
|
||||||
if($cached !== null){
|
if($cached !== null){
|
||||||
return $cached;
|
return $cached;
|
||||||
|
@ -66,7 +66,7 @@ final class FurnaceRecipeManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function match(Item $input) : ?FurnaceRecipe{
|
public function match(Item $input) : ?FurnaceRecipe{
|
||||||
$index = morton2d_encode($input->getTypeId(), $input->computeTypeData());
|
$index = morton2d_encode($input->getTypeId(), $input->computeStateData());
|
||||||
$simpleRecipe = $this->lookupCache[$index] ?? null;
|
$simpleRecipe = $this->lookupCache[$index] ?? null;
|
||||||
if($simpleRecipe !== null){
|
if($simpleRecipe !== null){
|
||||||
return $simpleRecipe;
|
return $simpleRecipe;
|
||||||
|
@ -63,7 +63,7 @@ class Banner extends ItemBlockWallOrFloor{
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->dyeColor($this->color);
|
$w->dyeColor($this->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ use pocketmine\math\Facing;
|
|||||||
|
|
||||||
final class CoralFan extends Item{
|
final class CoralFan extends Item{
|
||||||
use CoralTypeTrait {
|
use CoralTypeTrait {
|
||||||
describeType as encodeCoralType;
|
describeBlockItemState as encodeCoralType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(ItemIdentifier $identifier){
|
public function __construct(ItemIdentifier $identifier){
|
||||||
@ -41,7 +41,7 @@ final class CoralFan extends Item{
|
|||||||
parent::__construct($identifier, VanillaBlocks::CORAL_FAN()->getName());
|
parent::__construct($identifier, VanillaBlocks::CORAL_FAN()->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
//this is aliased to ensure a compile error in case the functions in Item or Block start to differ in future
|
//this is aliased to ensure a compile error in case the functions in Item or Block start to differ in future
|
||||||
//right now we can directly reuse encodeType from CoralTypeTrait, but that might silently stop working if Item
|
//right now we can directly reuse encodeType from CoralTypeTrait, but that might silently stop working if Item
|
||||||
//were to be altered. CoralTypeTrait was originally intended for blocks, so it's better not to assume anything.
|
//were to be altered. CoralTypeTrait was originally intended for blocks, so it's better not to assume anything.
|
||||||
|
@ -34,7 +34,7 @@ class Dye extends Item{
|
|||||||
parent::__construct($identifier, $name);
|
parent::__construct($identifier, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->dyeColor($this->color);
|
$w->dyeColor($this->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,13 +469,17 @@ class Item implements \JsonSerializable{
|
|||||||
return $this->identifier->getTypeId();
|
return $this->identifier->getTypeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function computeTypeData() : int{
|
final public function computeStateData() : int{
|
||||||
$writer = new RuntimeDataWriter(16); //TODO: max bits should be a constant instead of being hardcoded all over the place
|
$writer = new RuntimeDataWriter(16); //TODO: max bits should be a constant instead of being hardcoded all over the place
|
||||||
$this->describeType($writer);
|
$this->describeState($writer);
|
||||||
return $writer->getValue();
|
return $writer->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
/**
|
||||||
|
* Describes state properties of the item, such as colour, skull type, etc.
|
||||||
|
* This allows associating basic extra data with the item at runtime in a more efficient format than NBT.
|
||||||
|
*/
|
||||||
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
//NOOP
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,7 +631,7 @@ class Item implements \JsonSerializable{
|
|||||||
*/
|
*/
|
||||||
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
|
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
|
||||||
return $this->getTypeId() === $item->getTypeId() &&
|
return $this->getTypeId() === $item->getTypeId() &&
|
||||||
$this->computeTypeData() === $item->computeTypeData() &&
|
$this->computeStateData() === $item->computeStateData() &&
|
||||||
(!$checkCompound || $this->getNamedTag()->equals($item->getNamedTag()));
|
(!$checkCompound || $this->getNamedTag()->equals($item->getNamedTag()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,7 +650,7 @@ class Item implements \JsonSerializable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
final public function __toString() : string{
|
final public function __toString() : string{
|
||||||
return "Item " . $this->name . " (" . $this->getTypeId() . ":" . $this->computeTypeData() . ")x" . $this->count . ($this->hasNamedTag() ? " tags:0x" . base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($this->getNamedTag()))) : "");
|
return "Item " . $this->name . " (" . $this->getTypeId() . ":" . $this->computeStateData() . ")x" . $this->count . ($this->hasNamedTag() ? " tags:0x" . base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($this->getNamedTag()))) : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,8 +39,8 @@ final class ItemBlock extends Item{
|
|||||||
parent::__construct(ItemIdentifier::fromBlock($block), $block->getName());
|
parent::__construct(ItemIdentifier::fromBlock($block), $block->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$this->block->describeType($w);
|
$this->block->describeBlockItemState($w);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBlock(?int $clickedFace = null) : Block{
|
public function getBlock(?int $clickedFace = null) : Block{
|
||||||
|
@ -36,7 +36,7 @@ class Medicine extends Item implements ConsumableItem{
|
|||||||
parent::__construct($identifier, $name);
|
parent::__construct($identifier, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->medicineType($this->medicineType);
|
$w->medicineType($this->medicineType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class Potion extends Item implements ConsumableItem{
|
|||||||
parent::__construct($identifier, $name);
|
parent::__construct($identifier, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->potionType($this->potionType);
|
$w->potionType($this->potionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class SplashPotion extends ProjectileItem{
|
|||||||
parent::__construct($identifier, $name);
|
parent::__construct($identifier, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->potionType($this->potionType);
|
$w->potionType($this->potionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1540,7 +1540,7 @@ final class StringToItemParser extends StringToTParser{
|
|||||||
public function register(string $alias, \Closure $callback) : void{
|
public function register(string $alias, \Closure $callback) : void{
|
||||||
parent::register($alias, $callback);
|
parent::register($alias, $callback);
|
||||||
$item = $callback($alias);
|
$item = $callback($alias);
|
||||||
$this->reverseMap[$item->getTypeId()][$item->computeTypeData()][$alias] = true;
|
$this->reverseMap[$item->getTypeId()][$item->computeStateData()][$alias] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-param \Closure(string $input) : Block $callback */
|
/** @phpstan-param \Closure(string $input) : Block $callback */
|
||||||
@ -1559,7 +1559,7 @@ final class StringToItemParser extends StringToTParser{
|
|||||||
* @phpstan-return list<string>
|
* @phpstan-return list<string>
|
||||||
*/
|
*/
|
||||||
public function lookupAliases(Item $item) : array{
|
public function lookupAliases(Item $item) : array{
|
||||||
$aliases = $this->reverseMap[$item->getTypeId()][$item->computeTypeData()] ?? [];
|
$aliases = $this->reverseMap[$item->getTypeId()][$item->computeStateData()] ?? [];
|
||||||
return array_keys($aliases);
|
return array_keys($aliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class SuspiciousStew extends Food{
|
|||||||
parent::__construct($identifier, $name);
|
parent::__construct($identifier, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeType(RuntimeDataDescriber $w) : void{
|
protected function describeState(RuntimeDataDescriber $w) : void{
|
||||||
$w->suspiciousStewType($this->suspiciousStewType);
|
$w->suspiciousStewType($this->suspiciousStewType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ class TypeConverter{
|
|||||||
if($nbt === null){
|
if($nbt === null){
|
||||||
$nbt = new CompoundTag();
|
$nbt = new CompoundTag();
|
||||||
}
|
}
|
||||||
$nbt->setLong(self::PM_ID_TAG, morton2d_encode($itemStack->getTypeId(), $itemStack->computeTypeData()));
|
$nbt->setLong(self::PM_ID_TAG, morton2d_encode($itemStack->getTypeId(), $itemStack->computeStateData()));
|
||||||
}else{
|
}else{
|
||||||
[$id, $meta, $blockRuntimeId] = $idMeta;
|
[$id, $meta, $blockRuntimeId] = $idMeta;
|
||||||
}
|
}
|
||||||
|
@ -687,7 +687,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
*/
|
*/
|
||||||
public function getItemCooldownExpiry(Item $item) : int{
|
public function getItemCooldownExpiry(Item $item) : int{
|
||||||
$this->checkItemCooldowns();
|
$this->checkItemCooldowns();
|
||||||
return $this->usedItemsCooldown[morton2d_encode($item->getTypeId(), $item->computeTypeData())] ?? 0;
|
return $this->usedItemsCooldown[morton2d_encode($item->getTypeId(), $item->computeStateData())] ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -695,7 +695,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
*/
|
*/
|
||||||
public function hasItemCooldown(Item $item) : bool{
|
public function hasItemCooldown(Item $item) : bool{
|
||||||
$this->checkItemCooldowns();
|
$this->checkItemCooldowns();
|
||||||
return isset($this->usedItemsCooldown[morton2d_encode($item->getTypeId(), $item->computeTypeData())]);
|
return isset($this->usedItemsCooldown[morton2d_encode($item->getTypeId(), $item->computeStateData())]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -704,7 +704,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
public function resetItemCooldown(Item $item, ?int $ticks = null) : void{
|
public function resetItemCooldown(Item $item, ?int $ticks = null) : void{
|
||||||
$ticks = $ticks ?? $item->getCooldownTicks();
|
$ticks = $ticks ?? $item->getCooldownTicks();
|
||||||
if($ticks > 0){
|
if($ticks > 0){
|
||||||
$this->usedItemsCooldown[morton2d_encode($item->getTypeId(), $item->computeTypeData())] = $this->server->getTick() + $ticks;
|
$this->usedItemsCooldown[morton2d_encode($item->getTypeId(), $item->computeStateData())] = $this->server->getTick() + $ticks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user