Don't know how to do something

Discussion in 'Plugin Development' started by leland22, Mar 13, 2014.

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

    leland22

    I would like to create a block that when a player issues a command and right clicks it the block (a workbench) changes, not in the actual block but now when you click on it it opens a GUI. No clue how to see if the block the player clicks on is the specific block. I'm think its MetaData but don't really know.
     
  2. Offline

    Wizehh

    You could setup some system to add the block to a list, and then check if the block is in the list when they interact with it.
     
  3. Offline

    leland22

    Wizehh
    Could you explain what a custom tile entity is?
     
  4. Offline

    LexLaiden

    Are you referring to a specific block type or a block at a specific location?
     
  5. Offline

    leland22

    LexLaiden
    Don't know, I basically want to make a new block type with an existing block that opens a GUI when clicked instead of the usual crafting interface
     
  6. Offline

    skyrimfan1


    This is not possible with Bukkit. But it is possible to create a GUI that opens when a player has clicked a block.
    Code:java
    1. @EventHandler
    2. public void onPlayerInteractEvent(PlayerInteractEvent event) {
    3. if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { // Can be whatever you want, left click block, etc.
    4. Block block = event.getClickedBlock();
    5. if (block.getType() == Material.WORKBENCH) { // So its a workbench
    6. Inventory inventory = Bukkit.createInventory(event.getPlayer(), InventoryType.CRAFTING);
    7. inventory.setMaxStackSize(yourmaxsize);
    8. inventory.setContents(yourcontents);
    9. player.closeInventory(); // Close the current inventory (i.e crafting inv)
    10. player.openInventory(inventory); // Open the new one
    11. }
    12. }
    13. }
     
  7. Offline

    leland22

    skyrimfan1
    I know that it isn't possible to make a new block, but how would I differentiate this workbench from any other workbench out there? I wan't just ones that have been turned into specific workstations to open the GUI
     
  8. Offline

    skyrimfan1


    You can store a list of serialized locations in a config file or whatnot, and then check if the location of the workstation you are clicking matches the location stored in the config.
     
Thread Status:
Not open for further replies.

Share This Page