Solved Simple Code??

Discussion in 'Plugin Development' started by Cooper PluginDev, Mar 29, 2014.

Thread Status:
Not open for further replies.
  1. How come this isn't working? It's setting my hunger to full when I place the block but not when I right click it?
    Code:
    Code:java
    1. @SuppressWarnings("deprecation")
    2. @EventHandler
    3. public void onCheeseClick(PlayerInteractEvent e) {
    4. Player p = e.getPlayer();
    5. Block blockclicked = e.getClickedBlock();
    6. if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    7. if(blockclicked.setTypeId(19)) {
    8. p.setFoodLevel(20);
    9. p.sendMessage(ChatColor.BLUE + "Cheese Of Life> " + ChatColor.GRAY + "You ate some " + ChatColor.GREEN + "Cheese Of Life" + ChatColor.GRAY + ".");
    10. }
    11.  
    12. }
    13.  
    14. }
    15.  
     
  2. Offline

    Shayana

    You are using setTypeId() while, I guess you want to call the getTypeId() method, however I suggest to use

    Code:java
    1. if(blockClicked.getType().equals(Material.WHAT_EVER_IS_19)) {
    2. //do your stuff
    3. }
    4.  
     
Thread Status:
Not open for further replies.

Share This Page