Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Call to unknown member function Chest::getInventory?

Comments in 'Plugin Development' started by MyNameIsTriXz, Jan 15, 2016.

  1. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    It happens when I choose a chest with getBlock(), how can I bypass or solve it?
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    A chest is a Tile.
    AndrewBit and applqpak like this.
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Yeah, but how can I convert it to an inventory holder?
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Do you read? A Chest is a tile, not a block(well, it is a block, but you need the tile). You get it? No?
    PHP:
    Level::getTile(Vector3 $pos);
    AndrewBit and applqpak like this.
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I got it, how can I get then if a block is a tile or a block? :/
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    How about learning this(click)?
    PHP:
    if($chest instanceof Chest){ // Chest as a Tile, not the block.

    }
    AndrewBit and Samueljh1H8sLag like this.
  7. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    So much lol
    Why is there even an documentation for if?
  8. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    So you think I dont know instanceof? That was not my question... Its already solved
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You asked to know if a block is a tile or a block.
    A block is a block, not a tile. A block can contain a tile, but itself isn't a tile. So you check if it contains a tile if getTile with it returns a tile, using instanceof (although you can actually use !==null as well).
    MyNameIsTriXz, AndrewBit and applqpak like this.

Share This Page

Advertisement