Stop block break item drop in certain area not working

Discussion in 'Plugin Development' started by ice374, Aug 18, 2013.

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


    here is what im doing, but it has disabled ALL blocks from dropping item O_O everywhere, not just in the area im tryna stop it in.

        public void BreakBlock(BlockBreakEvent e){
            Block b = e.getBlock();
            int spleefMinX = -1;
            int spleefMaxX = 33;
            int spleefMinZ = 1105;
            int spleefMaxZ = 1133;
            for(int x = spleefMinX; x <= spleefMaxX; x++)
                for(int z = spleefMinZ; z <= spleefMaxZ; z++)
                        Location loc = b.getLocation();
                        Player player = e.getPlayer();
    Thanks in advance, you guys are the best :)
  2. Offline


    You have the right thing in mind, but you are doing it wrong.

    You need to check if the block that is about to be broken lies within your spleef arena area.
    So instead of looping through all blocks of this arena,
    just check if the x, y, and z coordinates of the block are >= your arenas minimum cooridnates and <= your arenas maximum coordinates, and if so, cancel the event and disable drops.
    No loop needed.
    "Math.min()" and "Math.max()" methods may be helfpul here to determine, which of both x, y, and z coordinates is your minimum and your maximum for each dimension.

    Currently you have hardcoded the coordinates. But I guess this is only temporary, hm?
    So better calculate the min/max values.
Thread Status:
Not open for further replies.

Share This Page