BlockBreakEvent getLocation from specific Block

Discussion in 'Plugin Development' started by EnveRuleZZ, Aug 19, 2014.

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

    EnveRuleZZ

    Hey Guys I'm trying to replace a broken Block with the same block who was broken.
    So my code at the moment is:

    Code:java
    1. @EventHandler
    2. public void onBreak(BlockBreakEvent e) {
    3. Player p = e.getPlayer();
    4. Location loc = e.getBlock().getLocation();
    5. Material b = e.getBlock().getType();
    6. int xp = this.getConfig().getInt("levels");
    7. if(b == Material.COAL_ORE) {
    8. p.giveExpLevels(xp);
    9. loc.getBlock().setType(Material.COAL_ORE);


    Eclipse doesn't give me any errors, neither does Minecraft.
    I understand how to get the location from a block, but I don't know how to get it from a specific Block like Coal Ore or something

    I hope you guys can help me, Bye:D
     
  2. Offline

    br456

  3. Offline

    EnveRuleZZ

    What do you mean with levels? :eek: br456
     
  4. Offline

    br456

    EnveRuleZZ
    Before you set the type to coal ore, you give the player some xp, do you get this xp?
     
  5. Offline

    EnveRuleZZ

    Code:java
    1. int xp = this.getConfig().getInt("levels");


    br456

    The thing with the exp works fine, only the setBlock doesn't work

    br456

    Oh, oops yes I get the XP in-game :D

    br456

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

    br456

    EnveRuleZZ
    Try just cancelling the event after you give the levels
     
  7. Offline

    EnveRuleZZ

    I thought of that too, but I want that the Block drops something...

    br456
     
  8. Offline

    br456

Thread Status:
Not open for further replies.

Share This Page