Jump to content

Recommended Posts

Posted

Hi

 

This link about blocks might help.

http://greyminecraftcoder.blogspot.co.at/2014/12/blocks-18.html

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

Posted

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.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

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

Posted

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.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

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

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.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.