Okay, so basically I'm trying to implement a Shulker inventory. Which I did successfully, however the only thing I'm encountering is that shulker boxes when placed are facing the wrong directions, they are upside down to be exact. Oh, and colors are wrong as well. This is my understanding of how meta data works - Meta data is an integer value. It indicates the color of the box, and using bit-masking, the orientation of the box. I have no clue on how to do achieve this. All my experiments led to wrong color and/or facing. I tried to take some code out of other blocks such as logs, but they behave (obviously) differently. And wiki pages show no information about this. This is how they are placed right now PHP: public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ $this->getLevel()->setBlock($blockReplace, $this, true, true); $tile = Tile::createTile("ShulkerBox", $this->getLevel(), ShulkerTile::createNBT($this, $face, $item, $player)); return true; } And for VariantBitmask I return simply 0 (zero) PHP: public function getVariantBitmask() : int{ return 0; }
I found out that if I don't set the tile in place method then shulker is facing the way it should, but as I add the tile it is upside down...
Negative meta? Set the scale of the entity to -1 if possible. That's what I know but as I see you make a tile. setScale(-1) makes an entity upside down with the opposite rotation.
I pulled latest PocketMine, in which @dktapps added the Block::$facing variable, basically he separated variant with actual metadata (rotation, etc). However that doesn't work either. Can't show you the attempted code, I'm already late for school, but basically I did exactly what Chest does, and I used same bitmask. Edit: @dktapps I have to ping You, because this is pretty new api change and you (please) need to explain why this does not affect Shulker Boxes.
It's not actually an API change, it's just some internal sanitization of blocks handling. You still need to know how to encode and decode block metadata for this to work, however you don't use it in the code body itself anymore. Shulker boxes do not store their rotation in the metadata as far as I recall. You need to look at the block entity (tile) for that.
Please also bear in mind that the master branch is in a state of heavy change so the internals can and probably will change again before this is done.
I tried adding new String tag "facing" with value "up" as suggested in the wiki, block state, I guess. So the variant is only responsible for color?
Block states are not currently implemented in PE, you need to look at the block entity information (which appears to have been removed from the wiki). You might have to disassemble the game itself and look into it.
What else excluding given options I have? I found this: https://github.com/Nukkit/Nukkit/bl...c/main/java/cn/nukkit/entity/Entity.java#L122 is this how I should do this? via packets?