1.16.5 Sphere break problem

Discussion in 'Spigot Plugin Development' started by DarkArmY, Jul 19, 2021.

  1. Can someone help me
    I want him to break a bullet, but it doesn't work with this code.
    In another class I managed to do this, but it has to count every block and that's why I use this method but in this one it only breaks down several cubes.


    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.plugin.Plugin;

    import java.io.File;

    public class MeteorEnchant1 implements Listener {

    private long block = 0;

    public static Plugin plugin;

    public MeteorEnchant1(Plugin plugin) {
    this.plugin = plugin;
    }


    @EventHandler(priority = EventPriority.HIGHEST)

    public void onBreak(BlockBreakEvent event) {

    if (event instanceof ExplosiveEnchant) return;
    if (event.isCancelled())
    return;
    File file2 = new File("plugins/Prison", "pickaxe.yml");
    FileConfiguration cfg2 = YamlConfiguration.loadConfiguration(file2);
    String uuid = event.getPlayer().getUniqueId().toString();
    boolean exploactive = cfg2.getBoolean(uuid + ".exploactive");
    int level = cfg2.getInt(uuid + ".jackhammer");
    double chance = 0.000008 * level;
    int radius_1 = 2;
    int radius_2 = level/1000;
    int radius_3 = level/1250;
    int radius = radius_1+radius_2;
    int radiusdown = radius_3+radius_1;


    ExploactiveEvent object = new ExploactiveEvent(plugin);


    Location brokenBlockLoc = event.getBlock().getLocation();
    int bX = brokenBlockLoc.getBlockX();
    int bY = brokenBlockLoc.getBlockY();
    int bZ = brokenBlockLoc.getBlockZ();
    for (int x = -radius; x <= radius; x++) {
    for (int y = -radiusdown; y <= radiusdown;y++) {
    for (int z = -radius; z <= radius; z++) {
    double distance = ((bX - x) * (bX - x) + ((bZ - z) * (bZ - z)) + ((bY - y)* 0.3 * (bY - y)*0.3));
    if (x == 0 && y == 0 && z == 0)
    if (distance < radius * radius )
    continue;
    Block b = event.getPlayer().getWorld().getBlockAt(
    brokenBlockLoc.getBlockX() + x,
    brokenBlockLoc.getBlockY() + y,
    brokenBlockLoc.getBlockZ() + z);
    if (b.getType() == Material.BEDROCK || b.isLiquid())
    continue;
    if (b.getType() == Material.AIR || b.isLiquid())
    continue;

    MeteorEvent cubeBlockBreakEvent = new MeteorEvent(b, event.getPlayer());
    Bukkit.getPluginManager().callEvent(cubeBlockBreakEvent);

    if (!cubeBlockBreakEvent.isCancelled()) {
    b.setType(Material.AIR);

    }
    }
    }
    }
    }

    }
     
  2. First. Did you register the event in the main class?
     
  3. yes
    it dismantles several cubes until the server crashes