How to set the display name of a chest block

Discussion in 'Plugin Development' started by Father Of Time, May 13, 2013.

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

    Father Of Time

    Good afternoon all,

    I was curious if anyone knew how to set the display name of a chest block in the world programmatically? I know how to do it while it's in item form:

            ItemStack chestStack = new ItemStack( Material.CHEST );
            ItemMeta meta = chestStack.getItemMeta();
            meta.setDisplayName( "Name goes here" );
            player.getInventory().addItem( chestStack );
    But unfortunately this won't meet my needs. I need to first change an air block to a chest, then once its a placed chest rename it to something specific. In case you aren't aware of what I mean by rename, if you open a chest in the upper left corner it says "chest", this can be renamed to anything you'd like; but for the life of me I can't figure out how to do it programmatically once placed.

    if anyone could assist with answering this I would be greatly appreciative. Thank you in advance for your time and guidance.
  2. Offline


    When they open an chest, my guess is you would have to open an inventory with the contents of the chest. Then when they close save it? (It might save into the chest by its self if you open the actual inventory and not just a copy). You should just then be able to rename it this way.
Thread Status:
Not open for further replies.

Share This Page