Skull: recognize noDrops flag

This commit is contained in:
Dylan K. Taylor 2021-04-27 19:21:29 +01:00
parent 017ca55a58
commit 0aa0d77307
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 8 additions and 2 deletions

View File

@ -201,6 +201,8 @@ final class BlockLegacyMetadata{
public const SEA_PICKLE_FLAG_NOT_UNDERWATER = 0x04;
public const SKULL_FLAG_NO_DROPS = 0x08;
public const SLAB_FLAG_UPPER = 0x08;
public const SPONGE_FLAG_WET = 0x01;

View File

@ -45,6 +45,8 @@ class Skull extends Flowable{
/** @var int */
protected $facing = Facing::NORTH;
protected bool $noDrops = false;
/** @var int */
protected $rotation = 0; //TODO: split this into floor skull and wall skull handling
@ -54,15 +56,17 @@ class Skull extends Flowable{
}
protected function writeStateToMeta() : int{
return $this->facing === Facing::UP ? 1 : BlockDataSerializer::writeHorizontalFacing($this->facing);
return ($this->facing === Facing::UP ? 1 : BlockDataSerializer::writeHorizontalFacing($this->facing)) |
($this->noDrops ? BlockLegacyMetadata::SKULL_FLAG_NO_DROPS : 0);
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->facing = $stateMeta === 1 ? Facing::UP : BlockDataSerializer::readHorizontalFacing($stateMeta);
$this->noDrops = ($stateMeta & BlockLegacyMetadata::SKULL_FLAG_NO_DROPS) !== 0;
}
public function getStateBitmask() : int{
return 0b111;
return 0b1111;
}
public function readStateFromWorld() : void{