We've split up the commands, scripting and mods, and add ons category! Please be sure you get your thread in the right place.

11

Get block ID with command

3 Comments

Please sign in to leave a comment.

Sorted by oldest
  • 1
    Registered User commented
    Comment actions Permalink

    the command /block could be added to replace the command /setblock, and add the feature you described in this post, with following syntaxes: 

    /block set <pos> <block>

    • <pos> - the position of the block to be changed.
    • <block> - the new block.
    • /setblock ~ ~1 ~ air will be /block set ~ ~1 ~ air

    /block store <pos> (append|insert <index>|merge|prepend) (block <pos>|entity <target>|storage <target>) <path>

    • <pos> - the position of the block whose namespaced id will be stored.
    • other argruments follow those of /data.
    • /block storage ~ ~1 ~ merge storage minecraft:foo baz.id will get the namespaced id of the block at ~ ~1 ~ and will store to the path "baz.id" in the storage "minecraft:foo". 

    i am not a native english speaker, so do not mind my grammar mistakes :)

  • 1
    Registered User commented
    Comment actions Permalink

    Also the have to be the possibility to also read the current block state. That could also be part of the /block command, that has been already mentioned!

    That command could be for example: /block get <pos> <path>
           And possible paths are for example id or block_state but also Items (for e.g. Chests or Barrels) or LastOutput (for e.g. Commandblocks) so that blockentitys could also be read like this.

  • 0
    Registered User commented
    Comment actions Permalink

    This could have the syntax of:

    getblock ~ ~-1 ~

    which returns the id and block states of the block as a string, ex: "minecraft:oak_log[facing=east]"

     

    getblock ~ ~-1 ~ id

    which returns the id of the block as a string, ex: "minecraft:oak_log"

     

    getblock ~ ~-1 ~ blockstate facing

    which returns the direction the block is facing as a string, ex: "east"

     

    getblock ~ ~-1 ~ blockstate

    which returns all the block states of a block as a string, ex: "[facing=east]"


    This would be so helpful when combined with function macros.

    #testdatapack:convertfallingblock
    data merge storage minecraft:test {Block:"minecraft:grass"}
    execute store result storage minecraft:test Block string run getblock ~ ~ ~ id
    function testdatapack:summonfallingblock1 with storage minecraft:test
    #testdatapack:convertfallingblock1
    $summon falling_block ~ ~ ~ {BlockState:{Name:"$(Block)"},Time:1,DropItem:1b}
    setblock ~ ~ ~ minecraft:air

    This is a simple set of functions which takes the block where it is executed and converts it to a falling block entity. This is a lot harder without a getblock command.