Custom GUI Names? (Non-Chest)

Discussion in 'Plugin Development' started by bobacadodl, Apr 11, 2014.

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

    bobacadodl

    As you might know, in recent versions of minecraft, its possible to have inventories with custom names. If you rename a workbench in an anvil, then place it, when you open the workbench it will be titled whatever you renamed it to.
    (Also works with hoppers, dispensers, droppers, enchanting tables, etc.)

    I have been trying to do this with craftbukkit, but it doesnt seem to work unless you have a TileEntity object.

    However, I'm trying to create a virtual named furnace. (Bukkit.createInventory). Does anyone know if this is possible?

    Yes, it is definitely impossible with the bukkit API. However, it is likely possible to do it using NMS or CraftBukkit code

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

    bobacadodl

  3. Offline

    xTigerRebornx

  4. Offline

    bobacadodl

  5. Offline

    bobacadodl

    xTigerRebornx

    Unfortunately, this didnt work. Bukkit.createInventory() doesnt create a CraftFurnace, so I still cant figure out how to get the TileEntityFurnace. It seems to create a CraftInventoryCustom instead.
     
  6. Offline

    xTigerRebornx

    bobacadodl Looking at CraftBukkit's source, TileEntityFurnace has a public constructor, you could attempt to create your own, then create your own CraftInventoryFurnace with it, then open that CraftInventoryFurnace to the Player (since it implements FurnaceInventory, which implements Inventory)
     
  7. Offline

    Plo124

    bobacadodl
    http://wiki.vg/Protocol#Open_Window
    I made a ProtocolLib handler for this too
    Code:java
    1. public YourClassNameHere(){
    2. ProtocolLibrary.getProtocolManager().addPacketListener(new PacketListener(){
    3. public Plugin getPlugin() {return Bukkit.getPluginManager().getPlugin("YourPluginNameHere");}
    4. public ListeningWhitelist getReceivingWhitelist() {return ListeningWhitelist.newBuilder().gamePhase(GamePhase.PLAYING).highest().types(PacketType.Play.Server.OPEN_WINDOW).build();}
    5. public ListeningWhitelist getSendingWhitelist() {return ListeningWhitelist.newBuilder().gamePhase(GamePhase.PLAYING).highest().types(PacketType.Play.Server.OPEN_WINDOW).build();}
    6. public void onPacketReceiving(PacketEvent e) {return;}
    7. @Override
    8. public void onPacketSending(PacketEvent e) {
    9. if (!(e.getPacket().getType() == PacketType.Play.Server.OPEN_WINDOW)) return;
    10. PacketContainer wrapper = e.getPacket();
    11. wrapper.getStrings().writeSafely(0,invTitle);
    12. e.setPacket(wrapper);
    13. setMenuTitle = false;
    14. }
    15.  
    16. });
    17. }
    18. String invTitle = "Custom Furnace Name";
    19. boolean setMenuTitle = true;
    20. public InventoryView openCustomFurnace(Player p){
    21. setMenuTitle = true;
    22. return p.openInventory(Bukkit.createInventory(null,InventoryType.FURNACE));
    23. }


    NOTE:
    This is untested!
     
    ThatCoffeeBean and bobacadodl like this.
  8. Offline

    bobacadodl

    Not a bad idea, I might end up doing this if necessary, although it would be nice to have a dependency-free way of doing this
     
Thread Status:
Not open for further replies.

Share This Page