Setting data of a block type

Discussion in 'Plugin Development' started by alex123099, Feb 11, 2014.

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

    alex123099

    Hi guys,
    I'm trying to generate a structure in my code, and I need to use spruce logs.

    The Material class only has Material.LOG, so I figured I need to set the data of the block, however the setData() function appears to be deprecated. How would I go about creating a spruce log block?
     
  2. You can use setData(), it's only depreciated because using Materials are preferred but there is no alternative method in the main Block class for that. I think setMetadata() also works but is way more confusing...

    There's also:
    Code:
    block.getState().setData()
    Which isn't depreciated.

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

    alex123099

    KingFaris11
    That function isn't deprecated, however the MaterialData(int type) constructor is.
    This is so confusing, why do they even deprecate these functions.

    And the problem with why I don't want to use deprecated methods is when future updates come, I don't want to change the algorithm to work with the new system.
     
  4. Yes, the reason they depreciated these functions is because they want to make plugin developers use the "Material" class more, and not the "ID" as it will eventually become ambiguous. Also, you don't need to use the constructor for MaterialData as you are not modifying the Material class, but the block which is an instance of Block. So you can use block.getState().setData(); I think. Also, I'd stick with block.setData() as it would never conflict, it's just not "the new thing".
     
  5. Offline

    alex123099

    KingFaris11
    The getState.setData asks for a MaterialData object.
     
  6. Aha, it's a continuous loop of depreciations.
    "block.getState().getData().setData()" is also depreciated... :/
     
Thread Status:
Not open for further replies.

Share This Page