mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
This story dates back to the days when getVariantBitmask() was introduced. The purpose of this function was to allow the variant info to be extracted from the metadata, for use with item drops. This was later changed to state bitmask for reasons I don't clearly recall. In the great 4.0 refactor, we now store variant magic numbers separately, so we don't need any generic bitmask to split up variant and state information anymore. Variant is now only ever serialized and never deserialized. The same thing goes for blockIDs. States are read from the world by matching the full stateID against a table of prefilled known blocks, so the variant doesn't need to be deserialized - only the state does, and the state metadata readers already do bit fuckery by themselves and don't need this mask - notice how little actual changes were required to get rid of this?
61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
|
|
/*
|
|
*
|
|
* ____ _ _ __ __ _ __ __ ____
|
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* @author PocketMine Team
|
|
* @link http://www.pocketmine.net/
|
|
*
|
|
*
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace pocketmine\block;
|
|
|
|
use pocketmine\item\TieredTool;
|
|
|
|
class BrewingStand extends Transparent{
|
|
|
|
/** @var bool */
|
|
protected $eastSlot = false;
|
|
/** @var bool */
|
|
protected $northwestSlot = false;
|
|
/** @var bool */
|
|
protected $southwestSlot = false;
|
|
|
|
protected function writeStateToMeta() : int{
|
|
return ($this->eastSlot ? 0x01 : 0) | ($this->southwestSlot ? 0x02 : 0) | ($this->northwestSlot ? 0x04 : 0);
|
|
}
|
|
|
|
public function readStateFromData(int $id, int $stateMeta) : void{
|
|
$this->eastSlot = ($stateMeta & 0x01) !== 0;
|
|
$this->southwestSlot = ($stateMeta & 0x02) !== 0;
|
|
$this->northwestSlot = ($stateMeta & 0x04) !== 0;
|
|
}
|
|
|
|
public function getHardness() : float{
|
|
return 0.5;
|
|
}
|
|
|
|
public function getToolType() : int{
|
|
return BlockToolType::TYPE_PICKAXE;
|
|
}
|
|
|
|
public function getToolHarvestLevel() : int{
|
|
return TieredTool::TIER_WOODEN;
|
|
}
|
|
|
|
//TODO
|
|
}
|