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:
Dylan K. Taylor 2023-05-16 14:07:06 +01:00
parent ccb22ceb3f
commit 015c668885
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
95 changed files with 178 additions and 171 deletions

View File

@ -51,11 +51,11 @@ class Anvil extends Transparent implements Fallable{
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);
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
}

View File

@ -55,7 +55,7 @@ class Bamboo extends Transparent{
protected bool $ready = false;
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->bool($this->thick);
$w->bool($this->ready);

View File

@ -36,7 +36,7 @@ use pocketmine\world\BlockTransaction;
final class BambooSapling extends Flowable{
private bool $ready = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->ready);
}

View File

@ -38,7 +38,7 @@ class Barrel extends Opaque{
protected bool $open = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing);
$w->bool($this->open);
}

View File

@ -53,7 +53,7 @@ class Bed extends Transparent{
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->occupied);
$w->bool($this->head);

View File

@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
class Bedrock extends Opaque{
private bool $burnsForever = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->burnsForever);
}

View File

@ -48,7 +48,7 @@ final class Bell extends Transparent{
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bellAttachmentType($this->attachmentType);
$w->horizontalFacing($this->facing);
}

View File

@ -66,9 +66,9 @@ class Block{
/** @var AxisAlignedBB[]|null */
protected ?array $collisionBoxes = null;
private int $requiredTypeDataBits;
private int $requiredStateDataBits;
private int $defaultStateData;
private int $requiredBlockItemStateDataBits;
private int $requiredBlockOnlyStateDataBits;
private int $defaultBlockOnlyStateData;
/**
* @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);
$calculator = new RuntimeDataSizeCalculator();
$this->describeType($calculator);
$this->requiredTypeDataBits = $calculator->getBitsUsed();
$this->describeBlockItemState($calculator);
$this->requiredBlockItemStateDataBits = $calculator->getBitsUsed();
$calculator = new RuntimeDataSizeCalculator();
$this->describeState($calculator);
$this->requiredStateDataBits = $calculator->getBitsUsed();
$this->describeBlockOnlyState($calculator);
$this->requiredBlockOnlyStateDataBits = $calculator->getBitsUsed();
$this->defaultStateData = $this->computeStateData();
$this->defaultBlockOnlyStateData = $this->encodeBlockOnlyState();
}
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,
* 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,
* for example, red wool and green wool have the same type ID.
* Information such as colour, powered, open/closed, etc. is **not** included in this ID.
* If you want to get a state ID that includes this information, use {@link Block::getStateId()} instead.
*
* @see BlockTypeIds
*/
@ -129,21 +129,22 @@ class Block{
* blocks in chunks at runtime.
*
* 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
* 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{
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.
*
* 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.
* Returns whether the given block has the same type ID as this one.
*/
public function hasSameTypeId(Block $other) : bool{
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.
*
* Note: Tile data (e.g. sign text, chest contents) are not compared here.
*/
public function isSameState(Block $other) : bool{
return $this->getStateId() === $other->getStateId();
@ -177,69 +180,69 @@ class Block{
/**
* Returns the block as an item.
* State information such as facing, powered/unpowered, open/closed, etc., is discarded.
* Type information such as colour, wood type, etc. is preserved.
* Block-only state such as facing, powered/unpowered, open/closed, etc., is discarded.
* Block-item state such as colour, wood type, etc. is preserved.
*/
public function asItem() : Item{
$normalized = clone $this;
$normalized->decodeStateData($this->defaultStateData);
$normalized->decodeBlockOnlyState($this->defaultBlockOnlyStateData);
return new ItemBlock($normalized);
}
private function decodeTypeData(int $data) : void{
$reader = new RuntimeDataReader($this->requiredTypeDataBits, $data);
private function decodeBlockItemState(int $data) : void{
$reader = new RuntimeDataReader($this->requiredBlockItemStateDataBits, $data);
$this->describeType($reader);
$this->describeBlockItemState($reader);
$readBits = $reader->getOffset();
if($this->requiredTypeDataBits !== $readBits){
throw new \LogicException(get_class($this) . ": Exactly $this->requiredTypeDataBits bits of type data were provided, but $readBits were read");
if($this->requiredBlockItemStateDataBits !== $readBits){
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{
$reader = new RuntimeDataReader($this->requiredStateDataBits, $data);
private function decodeBlockOnlyState(int $data) : void{
$reader = new RuntimeDataReader($this->requiredBlockOnlyStateDataBits, $data);
$this->describeState($reader);
$this->describeBlockOnlyState($reader);
$readBits = $reader->getOffset();
if($this->requiredStateDataBits !== $readBits){
throw new \LogicException(get_class($this) . ": Exactly $this->requiredStateDataBits bits of state data were provided, but $readBits were read");
if($this->requiredBlockOnlyStateDataBits !== $readBits){
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{
$reader = new RuntimeDataReader($this->requiredTypeDataBits + $this->requiredStateDataBits, $data);
$this->decodeTypeData($reader->readInt($this->requiredTypeDataBits));
$this->decodeStateData($reader->readInt($this->requiredStateDataBits));
private function decodeFullState(int $data) : void{
$reader = new RuntimeDataReader($this->requiredBlockItemStateDataBits + $this->requiredBlockOnlyStateDataBits, $data);
$this->decodeBlockItemState($reader->readInt($this->requiredBlockItemStateDataBits));
$this->decodeBlockOnlyState($reader->readInt($this->requiredBlockOnlyStateDataBits));
}
private function computeTypeData() : int{
$writer = new RuntimeDataWriter($this->requiredTypeDataBits);
private function encodeBlockItemState() : int{
$writer = new RuntimeDataWriter($this->requiredBlockItemStateDataBits);
$this->describeType($writer);
$this->describeBlockItemState($writer);
$writtenBits = $writer->getOffset();
if($this->requiredTypeDataBits !== $writtenBits){
throw new \LogicException(get_class($this) . ": Exactly $this->requiredTypeDataBits bits of type data were expected, but $writtenBits were written");
if($this->requiredBlockItemStateDataBits !== $writtenBits){
throw new \LogicException(get_class($this) . ": Exactly $this->requiredBlockItemStateDataBits bits of block-item state data were expected, but $writtenBits were written");
}
return $writer->getValue();
}
private function computeStateData() : int{
$writer = new RuntimeDataWriter($this->requiredStateDataBits);
private function encodeBlockOnlyState() : int{
$writer = new RuntimeDataWriter($this->requiredBlockOnlyStateDataBits);
$this->describeState($writer);
$this->describeBlockOnlyState($writer);
$writtenBits = $writer->getOffset();
if($this->requiredStateDataBits !== $writtenBits){
throw new \LogicException(get_class($this) . ": Exactly $this->requiredStateDataBits bits of state data were expected, but $writtenBits were written");
if($this->requiredBlockOnlyStateDataBits !== $writtenBits){
throw new \LogicException(get_class($this) . ": Exactly $this->requiredBlockOnlyStateDataBits bits of block-only state data were expected, but $writtenBits were written");
}
return $writer->getValue();
}
private function computeTypeAndStateData() : int{
$writer = new RuntimeDataWriter($this->requiredTypeDataBits + $this->requiredStateDataBits);
$writer->writeInt($this->requiredTypeDataBits, $this->computeTypeData());
$writer->writeInt($this->requiredStateDataBits, $this->computeStateData());
private function encodeFullState() : int{
$writer = new RuntimeDataWriter($this->requiredBlockItemStateDataBits + $this->requiredBlockOnlyStateDataBits);
$writer->writeInt($this->requiredBlockItemStateDataBits, $this->encodeBlockItemState());
$writer->writeInt($this->requiredBlockOnlyStateDataBits, $this->encodeBlockOnlyState());
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
* 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
}
@ -264,7 +267,7 @@ class Block{
* 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.
*/
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
//NOOP
}
@ -278,16 +281,16 @@ class Block{
public function generateStatePermutations() : \Generator{
//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
$bits = $this->requiredTypeDataBits + $this->requiredStateDataBits;
$bits = $this->requiredBlockItemStateDataBits + $this->requiredBlockOnlyStateDataBits;
if($bits > Block::INTERNAL_STATE_DATA_BITS){
throw new \LogicException("Block state data cannot use more than " . Block::INTERNAL_STATE_DATA_BITS . " bits");
}
for($stateData = 0; $stateData < (1 << $bits); ++$stateData){
$v = clone $this;
try{
$v->decodeTypeAndStateData($stateData);
if($v->computeTypeAndStateData() !== $stateData){
throw new \LogicException(static::class . "::decodeStateData() accepts invalid state data (returned " . $v->computeTypeAndStateData() . " for input $stateData)");
$v->decodeFullState($stateData);
if($v->encodeFullState() !== $stateData){
throw new \LogicException(static::class . "::decodeStateData() accepts invalid state data (returned " . $v->encodeFullState() . " for input $stateData)");
}
}catch(InvalidSerializedRuntimeDataException){ //invalid property combination, leave it
continue;
@ -732,7 +735,7 @@ class Block{
* @return string
*/
public function __toString(){
return "Block[" . $this->getName() . "] (" . $this->getTypeId() . ":" . $this->computeTypeAndStateData() . ")";
return "Block[" . $this->getName() . "] (" . $this->getTypeId() . ":" . $this->encodeFullState() . ")";
}
/**

View File

@ -43,7 +43,7 @@ class BrewingStand extends Transparent{
*/
protected array $slots = [];
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->brewingStandSlots($this->slots);
}

View File

@ -38,7 +38,7 @@ abstract class Button extends Flowable{
protected bool $pressed = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing);
$w->bool($this->pressed);
}

View File

@ -41,7 +41,7 @@ class Cactus extends Transparent{
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);
}

View File

@ -36,7 +36,7 @@ class Cake extends BaseCake{
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);
}

View File

@ -37,7 +37,7 @@ use pocketmine\world\BlockTransaction;
class Candle extends Transparent{
use CandleTrait {
describeState as encodeLitState;
describeBlockOnlyState as encodeLitState;
getLightLevel as getBaseLightLevel;
}
@ -46,7 +46,7 @@ class Candle extends Transparent{
private int $count = self::MIN_COUNT;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$this->encodeLitState($w);
$w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
}

View File

@ -44,7 +44,7 @@ class CaveVines extends Flowable{
protected bool $berries = 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->bool($this->berries);
$w->bool($this->head);

View File

@ -49,7 +49,7 @@ final class ChorusFlower extends Flowable{
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);
}

View File

@ -46,7 +46,7 @@ class CocoaBlock extends Transparent{
protected int $age = 0;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
}

View File

@ -38,7 +38,7 @@ abstract class Crops extends Flowable{
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);
}

View File

@ -41,7 +41,7 @@ class DaylightSensor extends Transparent{
protected bool $inverted = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, 15, $this->signalStrength);
$w->bool($this->inverted);
}

View File

@ -28,8 +28,8 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
class DetectorRail extends StraightOnlyRail{
protected bool $activated = false;
protected function describeState(RuntimeDataDescriber $w) : void{
parent::describeState($w);
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
parent::describeBlockOnlyState($w);
$w->bool($this->activated);
}

View File

@ -45,7 +45,7 @@ class Dirt extends Opaque{
parent::__construct($idInfo, $name, $typeInfo);
}
public function describeType(RuntimeDataDescriber $w) : void{
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->dirtType($this->dirtType);
}

View File

@ -41,7 +41,7 @@ class Door extends Transparent{
protected bool $hingeRight = false;
protected bool $open = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->top);
$w->bool($this->hingeRight);

View File

@ -33,7 +33,7 @@ use pocketmine\world\BlockTransaction;
class DoublePlant extends Flowable{
protected bool $top = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->top);
}

View File

@ -35,7 +35,7 @@ class EndPortalFrame extends Opaque{
protected bool $eye = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->eye);
}

View File

@ -37,7 +37,7 @@ class Farmland extends Transparent{
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);
}

View File

@ -42,7 +42,7 @@ class FenceGate extends Transparent{
protected bool $open = false;
protected bool $inWall = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->open);
$w->bool($this->inWall);

View File

@ -37,7 +37,7 @@ abstract class FillableCauldron extends Transparent{
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);
}

View File

@ -39,7 +39,7 @@ class Fire extends BaseFire{
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);
}

View File

@ -37,7 +37,7 @@ use function rad2deg;
final class FloorCoralFan extends BaseCoral{
private int $axis = Axis::X;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalAxis($this->axis);
}

View File

@ -35,7 +35,7 @@ final class Froglight extends SimplePillar{
parent::__construct($idInfo, $name, $typeInfo);
}
public function describeType(RuntimeDataDescriber $w) : void{
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->froglightType($this->froglightType);
}

View File

@ -32,7 +32,7 @@ class FrostedIce extends Ice{
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);
}

View File

@ -46,7 +46,7 @@ class Furnace extends Opaque{
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->lit);
}

View File

@ -39,7 +39,7 @@ class Hopper extends Transparent{
private int $facing = Facing::DOWN;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->facingExcept($this->facing, Facing::UP);
$w->bool($this->powered);
}

View File

@ -50,7 +50,7 @@ class ItemFrame extends Flowable{
protected int $itemRotation = 0;
protected float $itemDropChance = 1.0;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing);
$w->bool($this->hasMap);
}

View File

@ -43,7 +43,7 @@ class Lantern extends Transparent{
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->hanging);
}

View File

@ -47,7 +47,7 @@ class Leaves extends Transparent{
$this->leavesType = $leavesType;
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->noDecay);
$w->bool($this->checkDecay);
}

View File

@ -46,7 +46,7 @@ class Lectern extends Transparent{
protected bool $producingSignal = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->producingSignal);
}

View File

@ -44,7 +44,7 @@ class Lever extends Flowable{
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->leverFacing($this->facing);
$w->bool($this->activated);
}

View File

@ -34,7 +34,7 @@ final class Light extends Flowable{
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);
}

View File

@ -48,7 +48,7 @@ abstract class Liquid extends Transparent{
protected int $decay = 0; //PC "level" property
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->bool($this->falling);
$w->bool($this->still);

View File

@ -34,7 +34,7 @@ class NetherPortal extends Transparent{
protected int $axis = Axis::X;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalAxis($this->axis);
}

View File

@ -52,7 +52,7 @@ class NetherVines extends Flowable{
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);
}

View File

@ -37,7 +37,7 @@ class NetherWartPlant extends Flowable{
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);
}

View File

@ -34,7 +34,7 @@ class Rail extends BaseRail{
private int $railShape = BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->railShape($this->railShape);
}

View File

@ -36,7 +36,7 @@ class RedMushroomBlock extends Opaque{
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),
//so this information needs to be kept in the type info
$w->mushroomBlockType($this->mushroomBlockType);

View File

@ -44,7 +44,7 @@ class RedstoneComparator extends Flowable{
protected bool $isSubtractMode = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->isSubtractMode);
$w->bool($this->powered);

View File

@ -29,7 +29,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
class RedstoneLamp extends Opaque{
use PoweredByRedstoneTrait;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->powered);
}

View File

@ -33,7 +33,7 @@ use function mt_rand;
class RedstoneOre extends Opaque{
protected bool $lit = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->lit);
}

View File

@ -43,7 +43,7 @@ class RedstoneRepeater extends Flowable{
protected int $delay = self::MIN_DELAY;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->boundedInt(2, self::MIN_DELAY, self::MAX_DELAY, $this->delay);
$w->bool($this->powered);

View File

@ -28,8 +28,8 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
class RedstoneTorch extends Torch{
protected bool $lit = true;
protected function describeState(RuntimeDataDescriber $w) : void{
parent::describeState($w);
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
parent::describeBlockOnlyState($w);
$w->bool($this->lit);
}

View File

@ -46,7 +46,7 @@ class Sapling extends Flowable{
$this->saplingType = $saplingType;
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->ready);
}

View File

@ -38,7 +38,7 @@ class SeaPickle extends Transparent{
protected int $count = self::MIN_COUNT;
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->bool($this->underwater);
}

View File

@ -34,7 +34,7 @@ use pocketmine\world\BlockTransaction;
class ShulkerBox extends Opaque{
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
}

View File

@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
abstract class SimplePressurePlate extends PressurePlate{
protected bool $pressed = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->pressed);
}

View File

@ -49,11 +49,11 @@ class Skull extends Flowable{
parent::__construct($idInfo, $name, $typeInfo);
}
public function describeType(RuntimeDataDescriber $w) : void{
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->skullType($this->skullType);
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->facingExcept($this->facing, Facing::DOWN);
}

View File

@ -41,7 +41,7 @@ class Slab extends Transparent{
parent::__construct($idInfo, $name . " Slab", $typeInfo);
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->slabType($this->slabType);
}

View File

@ -46,7 +46,7 @@ class SnowLayer extends Flowable implements Fallable{
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);
}

View File

@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
class Sponge extends Opaque{
protected bool $wet = false;
public function describeType(RuntimeDataDescriber $w) : void{
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->bool($this->wet);
}

View File

@ -46,7 +46,7 @@ class Stair extends Transparent{
parent::__construct($idInfo, $name, $typeInfo);
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->upsideDown);
}

View File

@ -36,7 +36,7 @@ class StraightOnlyRail extends BaseRail{
private int $railShape = BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->straightOnlyRailShape($this->railShape);
}

View File

@ -38,7 +38,7 @@ class Sugarcane extends Flowable{
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);
}

View File

@ -45,7 +45,7 @@ class SweetBerryBush extends Flowable{
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);
}

View File

@ -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 $worksUnderwater = false;
public function describeType(RuntimeDataDescriber $w) : void{
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->bool($this->worksUnderwater);
}
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->unstable);
}

View File

@ -36,7 +36,7 @@ class Torch extends Flowable{
protected int $facing = Facing::UP;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->facingExcept($this->facing, Facing::DOWN);
}

View File

@ -40,7 +40,7 @@ class Trapdoor extends Transparent{
protected bool $open = false;
protected bool $top = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->top);
$w->bool($this->open);

View File

@ -33,7 +33,7 @@ class Tripwire extends Flowable{
protected bool $connected = false;
protected bool $disarmed = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->triggered);
$w->bool($this->suspended);
$w->bool($this->connected);

View File

@ -38,7 +38,7 @@ class TripwireHook extends Flowable{
protected bool $connected = false;
protected bool $powered = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->connected);
$w->bool($this->powered);

View File

@ -38,7 +38,7 @@ class UnknownBlock extends Transparent{
$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
//this might be an improperly registered plugin block
$w->int(Block::INTERNAL_STATE_DATA_BITS, $this->stateData);

View File

@ -39,7 +39,7 @@ class Vine extends Flowable{
/** @var int[] */
protected array $faces = [];
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacingFlags($this->faces);
}

View File

@ -42,7 +42,7 @@ class Wall extends Transparent{
protected array $connections = [];
protected bool $post = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->wallConnections($this->connections);
$w->bool($this->post);
}

View File

@ -36,7 +36,7 @@ use pocketmine\world\BlockTransaction;
final class WallCoralFan extends BaseCoral{
use HorizontalFacingTrait;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
}

View File

@ -38,7 +38,7 @@ class Wood extends Opaque{
private bool $stripped = false;
public function describeType(RuntimeDataDescriber $w) : void{
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->bool($this->stripped);
}

View File

@ -28,7 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
trait AnalogRedstoneSignalEmitterTrait{
protected int $signalStrength = 0;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, 15, $this->signalStrength);
}

View File

@ -29,7 +29,7 @@ use pocketmine\math\Facing;
trait AnyFacingTrait{
protected int $facing = Facing::DOWN;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing);
}

View File

@ -39,7 +39,7 @@ use pocketmine\world\sound\FlintSteelSound;
trait CandleTrait{
private bool $lit = false;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->bool($this->lit);
}

View File

@ -30,8 +30,8 @@ trait ColoredTrait{
/** @var DyeColor */
private $color;
/** @see Block::describeType() */
public function describeType(RuntimeDataDescriber $w) : void{
/** @see Block::describeBlockItemState() */
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->dyeColor($this->color);
}

View File

@ -44,7 +44,7 @@ trait CopperTrait{
parent::__construct($identifier, $name, $typeInfo);
}
public function describeType(RuntimeDataDescriber $w) : void{
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->copperOxidation($this->oxidation);
$w->bool($this->waxed);
}

View File

@ -30,8 +30,8 @@ trait CoralTypeTrait{
protected CoralType $coralType;
protected bool $dead = false;
/** @see Block::describeType() */
public function describeType(RuntimeDataDescriber $w) : void{
/** @see Block::describeBlockItemState() */
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
$w->coralType($this->coralType);
$w->bool($this->dead);
}

View File

@ -30,7 +30,7 @@ use pocketmine\math\Facing;
trait HorizontalFacingTrait{
protected int $facing = Facing::NORTH;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
}

View File

@ -35,7 +35,7 @@ use pocketmine\world\BlockTransaction;
trait PillarRotationTrait{
protected int $axis = Axis::Y;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->axis($this->axis);
}

View File

@ -28,8 +28,8 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
trait RailPoweredByRedstoneTrait{
use PoweredByRedstoneTrait;
protected function describeState(RuntimeDataDescriber $w) : void{
parent::describeState($w);
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
parent::describeBlockOnlyState($w);
$w->bool($this->powered);
}
}

View File

@ -30,7 +30,7 @@ trait SignLikeRotationTrait{
/** @var int */
private $rotation = 0;
protected function describeState(RuntimeDataDescriber $w) : void{
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, 15, $this->rotation);
}

View File

@ -103,7 +103,7 @@ class CraftingManager{
*/
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.
($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;
}
@ -142,7 +142,7 @@ class CraftingManager{
foreach($outputs as $o){
//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.
$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())));
}
@ -283,8 +283,8 @@ class CraftingManager{
}
public function matchBrewingRecipe(Item $input, Item $ingredient) : ?BrewingRecipe{
$inputHash = morton2d_encode($input->getTypeId(), $input->computeTypeData());
$ingredientHash = morton2d_encode($ingredient->getTypeId(), $ingredient->computeTypeData());
$inputHash = morton2d_encode($input->getTypeId(), $input->computeStateData());
$ingredientHash = morton2d_encode($ingredient->getTypeId(), $ingredient->computeStateData());
$cached = $this->brewingRecipeCache[$inputHash][$ingredientHash] ?? null;
if($cached !== null){
return $cached;

View File

@ -66,7 +66,7 @@ final class FurnaceRecipeManager{
}
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;
if($simpleRecipe !== null){
return $simpleRecipe;

View File

@ -63,7 +63,7 @@ class Banner extends ItemBlockWallOrFloor{
return $this;
}
protected function describeType(RuntimeDataDescriber $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->dyeColor($this->color);
}

View File

@ -33,7 +33,7 @@ use pocketmine\math\Facing;
final class CoralFan extends Item{
use CoralTypeTrait {
describeType as encodeCoralType;
describeBlockItemState as encodeCoralType;
}
public function __construct(ItemIdentifier $identifier){
@ -41,7 +41,7 @@ final class CoralFan extends Item{
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
//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.

View File

@ -34,7 +34,7 @@ class Dye extends Item{
parent::__construct($identifier, $name);
}
protected function describeType(RuntimeDataDescriber $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->dyeColor($this->color);
}

View File

@ -469,13 +469,17 @@ class Item implements \JsonSerializable{
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
$this->describeType($writer);
$this->describeState($writer);
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
}
@ -627,7 +631,7 @@ class Item implements \JsonSerializable{
*/
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
return $this->getTypeId() === $item->getTypeId() &&
$this->computeTypeData() === $item->computeTypeData() &&
$this->computeStateData() === $item->computeStateData() &&
(!$checkCompound || $this->getNamedTag()->equals($item->getNamedTag()));
}
@ -646,7 +650,7 @@ class Item implements \JsonSerializable{
}
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()))) : "");
}
/**

View File

@ -39,8 +39,8 @@ final class ItemBlock extends Item{
parent::__construct(ItemIdentifier::fromBlock($block), $block->getName());
}
protected function describeType(RuntimeDataDescriber $w) : void{
$this->block->describeType($w);
protected function describeState(RuntimeDataDescriber $w) : void{
$this->block->describeBlockItemState($w);
}
public function getBlock(?int $clickedFace = null) : Block{

View File

@ -36,7 +36,7 @@ class Medicine extends Item implements ConsumableItem{
parent::__construct($identifier, $name);
}
protected function describeType(RuntimeDataDescriber $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->medicineType($this->medicineType);
}

View File

@ -36,7 +36,7 @@ class Potion extends Item implements ConsumableItem{
parent::__construct($identifier, $name);
}
protected function describeType(RuntimeDataDescriber $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->potionType($this->potionType);
}

View File

@ -38,7 +38,7 @@ class SplashPotion extends ProjectileItem{
parent::__construct($identifier, $name);
}
protected function describeType(RuntimeDataDescriber $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->potionType($this->potionType);
}

View File

@ -1540,7 +1540,7 @@ final class StringToItemParser extends StringToTParser{
public function register(string $alias, \Closure $callback) : void{
parent::register($alias, $callback);
$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 */
@ -1559,7 +1559,7 @@ final class StringToItemParser extends StringToTParser{
* @phpstan-return list<string>
*/
public function lookupAliases(Item $item) : array{
$aliases = $this->reverseMap[$item->getTypeId()][$item->computeTypeData()] ?? [];
$aliases = $this->reverseMap[$item->getTypeId()][$item->computeStateData()] ?? [];
return array_keys($aliases);
}

View File

@ -34,7 +34,7 @@ class SuspiciousStew extends Food{
parent::__construct($identifier, $name);
}
protected function describeType(RuntimeDataDescriber $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->suspiciousStewType($this->suspiciousStewType);
}

View File

@ -222,7 +222,7 @@ class TypeConverter{
if($nbt === null){
$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{
[$id, $meta, $blockRuntimeId] = $idMeta;
}

View File

@ -687,7 +687,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
*/
public function getItemCooldownExpiry(Item $item) : int{
$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{
$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{
$ticks = $ticks ?? $item->getCooldownTicks();
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;
}
}