#Remember What block the player interacted with

1 messages · Page 1 of 1 (latest)

white quartz
#
package com.coldary.events

import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;

public class SuperPickaxe implements Listener{
    @EventHandler
    //the player has to right click a block to be able to use the super tool.
    //but how would make the tool work for just the player as i cant use public variables or create any as that will interfere with others tools
    public void rightClickEvent(PlayerInteractEvent e) {
        if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
            //e.getClickedBlock().getType()
        }
    }
    
    
    @EventHandler
    public void BreakEvent(BlockBreakEvent e) {
        
        int radius = 5;
        int BX = e.getBlock().getLocation().getBlockX();        
        int BY = e.getBlock().getLocation().getBlockY();
        int BZ = e.getBlock().getLocation().getBlockZ();
        
        for(int x = BX-radius; x < BX+radius; x++) {
            for(int y = BY-radius; y < BY+radius; y++) {
                for(int z = BZ-radius; z < BZ+radius; z++) {
                    if(e.getPlayer().getWorld().getBlockAt(x,y,z).getType() == Material.STONE) {
                        e.getPlayer().getWorld().getBlockAt(x,y,z).setType(Material.AIR);
                    }
                }
            }
        }
    }
}```