What is the TileEntityBlock for a CommandBlock? - WorldEdit

Discussion in 'Spigot Plugin Development' started by Bolt, May 5, 2015.

  1. I realize that there are special blocks with their own types like SignBlock, ChestBlock, etc. because they possess special NbtData. I would like to know if there is a special class for the CommandBlock since it possesses special nbtdata as well with regard to its stored command
    #1 Bolt, May 5, 2015
    Last edited: May 5, 2015
  2. CommandBlock commandBlock = (CommandBlock) block.getState();

    Edit: Of course, check that the block is a command block first.
  3. Try this :

    Code (Text):
    public TileEntityCommand getTileCommandbLock(CommandBlock cb) throws Exception {
        CraftCommandBlock ccb = (CraftCommandBlock)cb;
            Field f = ccb.getClass().getDeclaredField("commandBlock");
            TileEntityCommand tec = (TileEntityCommand)f.get(ccb);
    return tec;
    I just made it, not tested, but should work.