Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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

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.

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.

Check out my website: http://shadowfacts.net

Developer of many mods

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.