Quick Question

Discussion in 'Plugin Development' started by Herbert_The_Pervert, Jun 19, 2014.

Thread Status:
Not open for further replies.
  1. How To make a the block you right clicked disappear ?
     
  2. Offline

    Rocoty

    Completely remove it from the world (set it to air), or just make it invisible to players?
     
  3. Offline

    ElliottOlson

    Code:java
    1. @EventHandler
    2. public void onInteract(PlayerInteractEvent e){
    3. if (e.getAction() == Action.RIGHT_CLICK_BLOCK){
    4. Block b = e.getClickedBlock();
    5. b.setType(Material.AIR);
    6. }
    7. }


    There you go
     
  4. Offline

    AoH_Ruthless

    Herbert_The_Pervert
    MMMMMMMMMMmmmmmmmmmmmmmmmm ( :p )

    In a PlayerInteractEvent set it to air to make a block disappear.

    Edit: Woops, ninja'd by Rocoty and didn't even see it..

    ElliottOlson The spoonfeed is strong with this one.
     
  5. Offline

    Rocoty

    L33m4n123 likes this.
  6. Offline

    Graysoldier

    Rocoty What do you approve of then?
     
  7. Offline

    Rocoty

    Graysoldier I approve of actual help. When people at least put an effort in explaining what their code sample does. In an ideal world everyone would write detailed explanations on topics, linking to tutorials and providing examples.

    A block of code with no background or explanation at all is not help. It is a shortcut that gives the OP an opportunity to get the current problem fixed, but not learn. And as a result they are likely to come back with a similar problem at a later time.

    "Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime."
    Maimonides
     
    aaomidi and L33m4n123 like this.
  8. Offline

    Graysoldier

    @Rocoty Oh, that was a misunderstanding then, I thought you meant his code was flawed

    Herbert_The_Pervert Here's an explanation:

    Code:java
    1. @EventHandler
    2. public void onInteract(PlayerInteractEvent e){ // Player Interact event
    3. if (e.getAction() == Action.RIGHT_CLICK_BLOCK){ // If the player clicks a block...
    4. Block b = e.getClickedBlock();
    5. b.setType(Material.AIR); // Set the block to air
    6. }
    7. }
     
  9. Offline

    aaomidi

    I found my new signature.
     
    Rocoty likes this.
  10. Offline

    theguynextdoor

    Don't forget your favourite neighbour's signature

    ''Tell me and I forget. Teach me and I remember. Involve me and I learn'.
     
    Rocoty and L33m4n123 like this.
  11. Rocoty Graysoldier Thank You All For Your Help !!
    btw I Dont need the explanation I know everything in Bukkit [Nearly Atleast]
    I just needed to find out how to set the block rightclicked
     
Thread Status:
Not open for further replies.

Share This Page