1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

ShulkerBox facing

Discussion in 'Development' started by Primus, Oct 22, 2018.

  1. Primus

    Primus Zombie Pigman

    Messages:
    749
    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 $itemBlock $blockReplaceBlock $blockClickedint $faceVector3 $clickVectorPlayer $player null) : bool{
      
      
    $this->getLevel()->setBlock($blockReplace$thistruetrue);
      
    $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;
     }
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    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...
     
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    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.
     
  4. Primus

    Primus Zombie Pigman

    Messages:
    749
    It's not an Entity, but a block. I'm not making a Shulker, but Shulker Box
     
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Anything that has to do with $face?
     
  6. Primus

    Primus Zombie Pigman

    Messages:
    749
    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.
     
  7. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    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.
     
  8. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    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.
     
  9. Primus

    Primus Zombie Pigman

    Messages:
    749
    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?
     
  10. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    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.
     
  11. Primus

    Primus Zombie Pigman

    Messages:
    749
    Last edited: Oct 23, 2018
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.