## Recommended Posts

As stated, I would like to know a method to know what blocks are in a radius

So that I can do something special for them.

##### Share on other sites

Hi

Edit: Actually, that link is for 1.8.  So it might be a bit confusing.  1.7.10 doesn't have block states, it has getBlock and getBlockMetadata (0-15) instead.  But the picture is still correct.

Basic idea:

1) use for loops to iterate over a cube in x, y, z centred on the player's current location [xp, yp, zp].

2) at each [x,y,z], calculate the squared distance from the player's [xp,yp,zp].  If the squared distance is less than radius*radius, your [x,y,z] is within radius of the player, so then use World.getBlock(x,y,z) to retrieve the block at that location.

-TGG

##### Share on other sites

Now I have a list with target Blocks.

Then I should proceed to:

How to get position of those Blocks?

##### Share on other sites

Now I have a list with target Blocks.

Then I should proceed to:

How to get position of those Blocks?

You should save the coordinates found too.  Use a custom class that stores both the block and its position, and keep a list of those.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

DO NOT PM ME WITH PROBLEMS. No help will be given.

##### Share on other sites

You don't need a cusstom class if you are just getting each of the blocks by using three neseted for loops. You would already have their coordinates, the three different variables from each of the for loops.

Don't make mods if you don't know Java.

Developer of many mods

##### Share on other sites

You don't need a cusstom class if you are just getting each of the blocks by using three neseted for loops. You would already have their coordinates, the three different variables from each of the for loops.

It depends on what he's doing.  If you're doing something "right now because you're looking at this block" then no.  If you're doing something like "get me a list of all the valid locations matching X criteria" and picking one (or more) at random/via sorting algorithm, etc. then yeah, you should use a custom class.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

DO NOT PM ME WITH PROBLEMS. No help will be given.

##### Share on other sites

Yeah, what Draco said.

Don't make mods if you don't know Java.

Developer of many mods

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

### Announcements

×

• #### Activity

×
• Create New...