mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Block: Separate encoding of type and state data
the terminology of this needs improvement, but... the basic concept here is that 'type' data will persist on an itemstack, while 'state' data will not. Type data consists of things like: - Colour - Coral type - Wet/dry (sponges) - Live/dead (coral) - Wood type State data consists of things like: - Facing - Axis - Powered/unpowered - Open/closed In the past, with the old system, this information was separated by way of getStateBitmask(). This solution was fraught with problems, but achieved the basic goal: removing unwanted block properties from items.
This commit is contained in:
@ -51,15 +51,23 @@ class Anvil extends Transparent implements Fallable{
|
||||
return $this->damage << 2;
|
||||
}
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
public function getRequiredTypeDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeType(BlockDataReader $r) : void{
|
||||
$this->setDamage($r->readBoundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED));
|
||||
}
|
||||
|
||||
protected function encodeType(BlockDataWriter $w) : void{
|
||||
$w->writeInt(2, $this->getDamage());
|
||||
}
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(BlockDataReader $r) : void{
|
||||
$this->setDamage($r->readBoundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED));
|
||||
$this->setFacing($r->readHorizontalFacing());
|
||||
}
|
||||
|
||||
protected function encodeState(BlockDataWriter $w) : void{
|
||||
$w->writeInt(2, $this->getDamage());
|
||||
$w->writeHorizontalFacing($this->getFacing());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user