Chest Inventory Issues...

Discussion in 'Plugin Development' started by N1T3SLAY3R, Jul 21, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    N1T3SLAY3R

    Hello, i am currently trying to get the contents of a chest to see if they have specific materials in them (and later set them), but im having issues converting the block to an Inventory or getting that inventory since its a scheduled/repetitive event.

    Code Sample:
    Code:
    block = Bukkit.getWorld(w).getBlockAt(x,y,z);
    Chest main = new Chest(0, block.getData());
    if (((Inventory) main).contains(Material.DIRT, 5)) {
    }
    This, is a class cast exception and the chest has no .getInventory() command like in the past.

    Thank you, and if you solve this, is there any way to change the inventory name?
     
  2. Offline

    Pizza371

    N1T3SLAY3R
    cast the blockstate to a chest, if you're sure it's a chest (hint: instanceof). :)
     
  3. Offline

    N1T3SLAY3R

    Pizza371
    Blockstate to inventory is a class cast exception, already tried that and/or the chest class no longer has the .getInventory() command, and these blocks are confirmed chests (other parts of the plugin ensure it)

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  4. Offline

    _LB

Thread Status:
Not open for further replies.

Share This Page