Block near to a specific block

Discussion in 'Spigot Plugin Development' started by GeraldFrito, Dec 3, 2019.

  1. I want to check if a block is near or in a distance of a specific block.

    For example: some block y near to a "emerald_block" the player cannot break that block (the "some" block). I want to protect a certain place that when I put a "emerald_block". I'm learning, I don't use others plugins.

    How can I check that? I've tried a lot with everything I know (I'm not a veteran, I'm new).
  2. You say you're new as in new to development overall or just using the Spigot API? If you're new to development overall, then I'd suggest learning basic java first. If not here's a thread that should get you going in the right direction.

    Also this will show usage of methods within the Location object, which you'll be using to figure out distances between blocks and a 'certain place'

    Edit: Forgot to remove a dumb suggestion from the top of my post :)

  3. I know Java (not like a profesional). I know how use some methods of Spigot and something else.

    I know about distances and things like that. What I don't get the idea it is that I don't know how make that when a player put a "emerald_block" the blocks around that block the player cannot break it. It's easy but I don't get the idea.
  4. Perhaps making a List of placed Emerald Blocks locations, and then check in a BlockBreakEvent if the player is within range of the block.
    • Agree Agree x 1