Solved Get the type of a clicked block

Discussion in 'Plugin Development' started by AntonioC94, Dec 7, 2019.

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

    AntonioC94

    Hi there, sooo i just want to know, how can i get the type of a right clicked block. I tried with this code and another code, but without results


    P.D: my code doesnt run here "if (pot.getType() == Material.FLOWER_POT) {"
    P.D2: All right, i was testing a litle bit more and when i do a system.out. i have " LEGACY_AIR" when i do a click in the pot, so.. what is happening?
    P.D3: All right its done, i just need to add in my plugin.yml "api-version: 1.14"

    Code:
    
        @EventHandler
        public void bloque(PlayerInteractEvent event) {
            System.out.println("test");
            Player player = event.getPlayer();
            Block pot= event.getClickedBlock();
            if (player != null) {
                System.out.println("1");
                if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                    System.out.println("2");
                    if (pot.getType() == Material.FLOWER_POT) {
                        player.sendMessage("huehuehue");
                    }
                }
            }
        }
    
     
    Last edited: Dec 7, 2019
Thread Status:
Not open for further replies.

Share This Page