Solved Chest Names

Discussion in 'Plugin Development' started by wizzinangel, Nov 2, 2013.

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

    wizzinangel

    Is there a way to add a name or lore to a chest? Anyone heard of doing this?
     
  2. Offline

    mrCookieSlime

    wizzinangel
    Do you mean a Lore and a Name for the Item, then yes.
    If you mean a name for the Inventory, then yes as well.
    But if you mean like a little Text bar above the Chest like the Player's name tags, then no...
     
    wizzinangel likes this.
  3. Offline

    Mathias Eklund

    I believe you actually can add a name above the chests.
     
  4. Offline

    wouterrr

    Yes you can, if you try to make a custom inventory use this:
    Code:java
    1. Bukkit.getServer().createInventory(
    2. null,
    3. 9,
    4. "Name");


    The 9 means the amount of slots (max is 36).

    Goodluck
     
  5. Offline

    mrCookieSlime

    ^
    No you can't, without mods.
    You can't make a Name Tag above the Chest block.
    But like I said he can change the Name of the Item and the Inventory
     
  6. Offline

    Mathias Eklund

    There are ways to do it.
     
  7. Offline

    mrCookieSlime

    Mathias Eklund
    Yea, you could make an invisible mob with a Custom name at the Position of the chest though...
     
  8. Offline

    Ronbo

    It is definitely do-able (see dungeonrealms.net server, their custom personal shop system can have names above the chest). It's probably done with invisible entities at the position of the chest, as mrCookieSlime said.
     
  9. Offline

    Mathias Eklund

    I'd say this topic is solved as he got his answer.
     
  10. Offline

    Jogy34

    If you want to actually rename a chest instead of using a custom inventory:
    Code:java
    1.  
    2. public static void setChestName(Location loc, String name)
    3. {
    4. try
    5. {
    6. loc.getBlock().setType(Material.CHEST);
    7.  
    8. Field inventoryField = CraftChest.class.getDeclaredField("chest");
    9. inventoryField.setAccessible(true);
    10. TileEntityChest teChest = ((TileEntityChest) inventoryField.get((CraftChest) loc.getBlock().getState()));
    11. teChest.a(name);
    12. }
    13. catch (Exception e)
    14. {
    15. e.printStackTrace();
    16. }
    17. }
    18.  


    This does use NMS and reflection so use at your own risk. Also you would have to use the craftbukkit.jar in addition to the bukkit.jar in your build path.
     
  11. Offline

    wizzinangel

    Thanks guys
     
Thread Status:
Not open for further replies.

Share This Page