mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-24 12:24:03 +00:00
Revert "Block: Get rid of state bitmasks"
This reverts commit b7b05e729e4fcfbe74786342882d011f004658fa. Apparently this was premature, because we still need these things to deal with default state remapping.
This commit is contained in:
parent
6cb263fcca
commit
0f7f5362b8
@ -50,7 +50,11 @@ class Anvil extends Transparent implements Fallable{
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
$this->facing = BlockDataValidator::readLegacyHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
|
@ -95,6 +95,10 @@ abstract class BaseRail extends Flowable{
|
||||
$this->connections = $connections;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.7;
|
||||
}
|
||||
|
@ -68,6 +68,10 @@ class Bed extends Transparent{
|
||||
$this->head = ($stateMeta & self::BITFLAG_HEAD) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
//read extra state information from the tile - this is an ugly hack
|
||||
|
@ -43,6 +43,8 @@ use pocketmine\Player;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\tile\TileFactory;
|
||||
use function array_merge;
|
||||
use function assert;
|
||||
use function dechex;
|
||||
use function get_class;
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
@ -80,6 +82,9 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
* @param string $name English name of the block type (TODO: implement translations)
|
||||
*/
|
||||
public function __construct(BlockIdentifier $idInfo, string $name){
|
||||
if(($idInfo->getVariant() & $this->getStateBitmask()) !== 0){
|
||||
throw new \InvalidArgumentException("Variant 0x" . dechex($idInfo->getVariant()) . " collides with state bitmask 0x" . dechex($this->getStateBitmask()));
|
||||
}
|
||||
$this->idInfo = $idInfo;
|
||||
$this->fallbackName = $name;
|
||||
}
|
||||
@ -118,7 +123,9 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
* @return int
|
||||
*/
|
||||
public function getDamage() : int{
|
||||
return $this->idInfo->getVariant() | $this->writeStateToMeta();
|
||||
$stateMeta = $this->writeStateToMeta();
|
||||
assert(($stateMeta & ~$this->getStateBitmask()) === 0);
|
||||
return $this->idInfo->getVariant() | $stateMeta;
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
@ -161,6 +168,15 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bitmask used to extract state bits from block metadata.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStateBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given block has an equivalent type to this one. This compares base legacy ID and variant.
|
||||
*
|
||||
|
@ -527,17 +527,20 @@ class BlockFactory{
|
||||
* $override parameter.
|
||||
*/
|
||||
public static function register(Block $block, bool $override = false) : void{
|
||||
foreach($block->getIdInfo()->getAllBlockIds() as $id){
|
||||
for($m = 0; $m < 16; ++$m){
|
||||
$index = ($id << 4) | $m;
|
||||
$variant = $block->getIdInfo()->getVariant();
|
||||
|
||||
$v = clone $block;
|
||||
try{
|
||||
$v->readStateFromData($id, $m);
|
||||
if($v->getDamage() !== $m){
|
||||
throw new InvalidBlockStateException("Corrupted meta"); //don't register anything that isn't the same when we read it back again
|
||||
}
|
||||
}catch(InvalidBlockStateException $e){ //invalid property combination
|
||||
$stateMask = $block->getStateBitmask();
|
||||
if(($variant & $stateMask) !== 0){
|
||||
throw new \InvalidArgumentException("Block variant collides with state bitmask");
|
||||
}
|
||||
|
||||
foreach($block->getIdInfo()->getAllBlockIds() as $id){
|
||||
if(!$override and self::isRegistered($id, $variant)){
|
||||
throw new \InvalidArgumentException("Block registration $id:$variant conflicts with an existing block");
|
||||
}
|
||||
|
||||
for($m = $variant; $m <= ($variant | $stateMask); ++$m){
|
||||
if(($m & ~$stateMask) !== $variant){
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -545,10 +548,21 @@ class BlockFactory{
|
||||
throw new \InvalidArgumentException("Block registration " . get_class($block) . " has states which conflict with other blocks");
|
||||
}
|
||||
|
||||
$index = ($id << 4) | $m;
|
||||
|
||||
$v = clone $block;
|
||||
try{
|
||||
$v->readStateFromData($id, $m & $stateMask);
|
||||
if($v->getDamage() !== $m){
|
||||
throw new InvalidBlockStateException("Corrupted meta"); //don't register anything that isn't the same when we read it back again
|
||||
}
|
||||
}catch(InvalidBlockStateException $e){ //invalid property combination
|
||||
continue;
|
||||
}
|
||||
|
||||
self::fillStaticArrays($index, $v);
|
||||
}
|
||||
|
||||
$variant = $block->getIdInfo()->getVariant();
|
||||
if(!self::isRegistered($id, $variant)){
|
||||
self::fillStaticArrays(($id << 4) | $variant, $block); //register default state mapped to variant, for blocks which don't use 0 as valid state
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ class BrewingStand extends Transparent{
|
||||
$this->northwestSlot = ($stateMeta & 0x04) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.5;
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ abstract class Button extends Flowable{
|
||||
$this->powered = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
//TODO: check valid target block
|
||||
$this->facing = $face;
|
||||
|
@ -47,6 +47,10 @@ class Cactus extends Transparent{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 15);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.4;
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ class Cake extends Transparent implements FoodSource{
|
||||
$this->bites = BlockDataValidator::readBoundedInt("bites", $stateMeta, 0, 6);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.5;
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ class Chest extends Transparent{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 2.5;
|
||||
}
|
||||
|
@ -51,6 +51,10 @@ class CocoaBlock extends Transparent{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta >> 2, 0, 2);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.2;
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ abstract class Crops extends Flowable{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 7);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($blockReplace->getSide(Facing::DOWN)->getId() === Block::FARMLAND){
|
||||
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
|
@ -57,6 +57,10 @@ class DaylightSensor extends Transparent{
|
||||
$this->inverted = $id === $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function isInverted() : bool{
|
||||
return $this->inverted;
|
||||
}
|
||||
|
@ -67,6 +67,10 @@ abstract class Door extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
|
||||
|
@ -43,6 +43,10 @@ class DoublePlant extends Flowable{
|
||||
$this->top = ($stateMeta & self::BITFLAG_TOP) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1000;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$id = $blockReplace->getSide(Facing::DOWN)->getId();
|
||||
if(($id === Block::GRASS or $id === Block::DIRT) and $blockReplace->getSide(Facing::UP)->canBeReplaced()){
|
||||
|
@ -47,6 +47,10 @@ class EndPortalFrame extends Solid{
|
||||
$this->eye = ($stateMeta & 0x04) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{
|
||||
return 1;
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ class EndRod extends Flowable{
|
||||
$this->facing = BlockDataValidator::readFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->facing = $face;
|
||||
if($blockClicked instanceof EndRod and $blockClicked->facing === $this->facing){
|
||||
|
@ -42,6 +42,10 @@ class Farmland extends Transparent{
|
||||
$this->wetness = BlockDataValidator::readBoundedInt("wetness", $stateMeta, 0, 7);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.6;
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ class FenceGate extends Transparent{
|
||||
$this->inWall = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 2;
|
||||
}
|
||||
|
@ -48,6 +48,10 @@ class Fire extends Flowable{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 15);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function hasEntityCollision() : bool{
|
||||
return true;
|
||||
}
|
||||
|
@ -43,6 +43,10 @@ class FlowerPot extends Flowable{
|
||||
$this->occupied = $stateMeta !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111; //vanilla uses various values, we only care about 1 and 0 for PE
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->contract(3 / 16, 0, 3 / 16)->trim(Facing::UP, 5 / 8);
|
||||
}
|
||||
|
@ -53,6 +53,10 @@ class Furnace extends Solid{
|
||||
$this->lit = $id === $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 3.5;
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ class GlazedTerracotta extends Solid{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 1.4;
|
||||
}
|
||||
|
@ -77,6 +77,10 @@ class ItemFrame extends Flowable{
|
||||
}
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
@ -44,6 +44,10 @@ class Ladder extends Transparent{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function hasEntityCollision() : bool{
|
||||
return true;
|
||||
}
|
||||
|
@ -56,6 +56,10 @@ class Leaves extends Transparent{
|
||||
$this->checkDecay = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1100;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.2;
|
||||
}
|
||||
|
@ -69,6 +69,10 @@ class Lever extends Flowable{
|
||||
$this->powered = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.5;
|
||||
}
|
||||
|
@ -77,6 +77,10 @@ abstract class Liquid extends Transparent{
|
||||
$this->still = $id === $this->idInfo->getSecondId();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function hasEntityCollision() : bool{
|
||||
return true;
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ class NetherReactor extends Solid{
|
||||
$this->state = BlockDataValidator::readBoundedInt("state", $stateMeta, 0, 2);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
public function getToolType() : int{
|
||||
return BlockToolType::TYPE_PICKAXE;
|
||||
}
|
||||
|
@ -45,6 +45,10 @@ class NetherWartPlant extends Flowable{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 3);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() === Block::SOUL_SAND){
|
||||
|
@ -43,6 +43,10 @@ class Pumpkin extends Solid{
|
||||
return Bearing::fromFacing($this->facing);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 1;
|
||||
}
|
||||
|
@ -45,6 +45,10 @@ class RedMushroomBlock extends Solid{
|
||||
$this->rotationData = $stateMeta;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.2;
|
||||
}
|
||||
|
@ -60,6 +60,10 @@ class RedstoneRepeater extends Flowable{
|
||||
return Bearing::fromFacing($this->facing) | (($this->delay - 1) << 2);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->trim(Facing::UP, 7 / 8);
|
||||
}
|
||||
|
@ -38,6 +38,10 @@ class RedstoneWire extends Flowable{
|
||||
return $this->power;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
//TODO: check connections to nearby redstone components
|
||||
|
@ -53,6 +53,10 @@ class Sapling extends Flowable{
|
||||
$this->ready = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1000;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() === self::GRASS or $down->getId() === self::DIRT or $down->getId() === self::FARMLAND){
|
||||
|
@ -43,6 +43,10 @@ class SignPost extends Transparent{
|
||||
$this->rotation = $stateMeta;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 1;
|
||||
}
|
||||
|
@ -35,4 +35,8 @@ abstract class SimplePressurePlate extends PressurePlate{
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->powered = $stateMeta !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1;
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ class Skull extends Flowable{
|
||||
$this->facing = $stateMeta === 1 ? Facing::UP : BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
$tile = $this->level->getTile($this);
|
||||
|
@ -61,6 +61,10 @@ abstract class Slab extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1000;
|
||||
}
|
||||
|
||||
public function isTransparent() : bool{
|
||||
return $this->slabType !== SlabType::DOUBLE();
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ class SnowLayer extends Flowable implements Fallable{
|
||||
$this->layers = BlockDataValidator::readBoundedInt("layers", $stateMeta + 1, 1, 8);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function canBeReplaced() : bool{
|
||||
return $this->layers < 8;
|
||||
}
|
||||
|
@ -37,6 +37,10 @@ class Sponge extends Solid{
|
||||
$this->wet = $stateMeta !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 0.6;
|
||||
}
|
||||
|
@ -53,6 +53,10 @@ abstract class Stair extends Transparent{
|
||||
$this->upsideDown = ($stateMeta & 0x04) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
|
||||
|
@ -46,6 +46,10 @@ class StandingBanner extends Transparent{
|
||||
$this->rotation = $stateMeta;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 1;
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ class Sugarcane extends Flowable{
|
||||
$this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 15);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($item instanceof Fertilizer){
|
||||
if($this->getSide(Facing::DOWN)->getId() !== self::SUGARCANE_BLOCK){
|
||||
|
@ -39,10 +39,13 @@ class Torch extends Flowable{
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$stateMeta &= 0x07;
|
||||
$this->facing = $stateMeta === 5 ? Facing::UP : BlockDataValidator::readHorizontalFacing(6 - $stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{
|
||||
return 14;
|
||||
}
|
||||
|
@ -54,6 +54,10 @@ class Trapdoor extends Transparent{
|
||||
$this->open = ($stateMeta & self::MASK_OPENED) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function getHardness() : float{
|
||||
return 3;
|
||||
}
|
||||
|
@ -45,6 +45,10 @@ class Tripwire extends Flowable{
|
||||
$this->disarmed = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{
|
||||
return false;
|
||||
}
|
||||
|
@ -49,6 +49,10 @@ class TripwireHook extends Flowable{
|
||||
$this->powered = ($stateMeta & 0x08) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(Facing::axis($face) !== Facing::AXIS_Y){
|
||||
//TODO: check face is valid
|
||||
|
@ -57,6 +57,10 @@ class Vine extends Flowable{
|
||||
$this->setFaceFromMeta($stateMeta, self::FLAG_EAST, Facing::EAST);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
private function setFaceFromMeta(int $meta, int $flag, int $face) : void{
|
||||
if(($meta & $flag) !== 0){
|
||||
$this->faces[$face] = true;
|
||||
|
@ -39,6 +39,10 @@ class WallBanner extends StandingBanner{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::opposite($this->facing))->getId() === self::AIR){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
@ -39,6 +39,10 @@ class WallSign extends SignPost{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::opposite($this->facing))->getId() === self::AIR){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
@ -37,4 +37,8 @@ abstract class WeightedPressurePlate extends PressurePlate{
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->power = BlockDataValidator::readBoundedInt("power", $stateMeta, 0, 15);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,14 @@ trait PillarRotationTrait{
|
||||
$this->readAxisFromMeta($stateMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Block::getStateBitmask()
|
||||
* @return int
|
||||
*/
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1100;
|
||||
}
|
||||
|
||||
protected function readAxisFromMeta(int $meta) : void{
|
||||
static $map = [
|
||||
0 => Facing::AXIS_Y,
|
||||
|
Loading…
x
Reference in New Issue
Block a user