Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.11] Get blocks in a certain radius
The update for 1.13 is being worked on - please be patient. (Updated 02/14/19)
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
Awesome_Spider

[1.11] Get blocks in a certain radius

Started by Awesome_Spider, March 24, 2017

3 posts in this topic

Awesome_Spider    64

Awesome_Spider

Awesome_Spider    64

  • Dragon Slayer
  • Awesome_Spider
  • Forge Modder
  • 64
  • 892 posts
  • Report post
Posted March 24, 2017 (edited)

I am thinking about modding again after a few weeks or so of being swamped with school. What I want to do is get all the blocks within a radius around the player to test each block for different properties. Is there an easy way of doing this?

Edited March 24, 2017 by Awesome_Spider

Share this post


Link to post
Share on other sites

TheMasterGabriel    29

TheMasterGabriel

TheMasterGabriel    29

  • Creeper Killer
  • TheMasterGabriel
  • Forge Modder
  • 29
  • 178 posts
  • Report post
Posted March 24, 2017 (edited)

To my knowledge, you will have to do it yourself. BlockPos has a method (BlockPos#getAllInBox) to retrieve all the BlockPos within a rectangular prism, but not a sphere. In general, I would pull all the blocks with a cube with the player at the center and using your radius as half the side length. You can then filter out the unwanted blocks with a simple distance check (BlockPos#distanceSq).

 

If you want to only get blocks with a certain properties, it might be a good call to use Google's Iterators#filter with the iterator returned from BlockPos and a custom predicate, which would filter for the distance as well as the block properties you want.

Edited March 24, 2017 by TheMasterGabriel
  • Like 1

Share this post


Link to post
Share on other sites

Awesome_Spider    64

Awesome_Spider

Awesome_Spider    64

  • Dragon Slayer
  • Awesome_Spider
  • Forge Modder
  • 64
  • 892 posts
  • Report post
Posted March 24, 2017

Well, I guess I should have been more clear. A cube around the player will work. Thanks for your help. I think BlockPos::getAllInBox is exactly what I want.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0
Go To Topic Listing Modder Support

  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      forge with optifine 1.13.2

      By diesieben07 · Posted 15 minutes ago

      I am not sure what you mean. It is up to Optifine to add Forge compatibility. You would need to ask them for more info.
    • Nerdsjam
      Mods are not working...

      By Nerdsjam · Posted 47 minutes ago

      I got it to work now. Thanks for the help anyways @diesieben07 and @DavidM
    • matieusz
      forge with optifine 1.13.2

      By matieusz · Posted 1 hour ago

      support added after?
    • diesieben07
      forge with optifine 1.13.2

      By diesieben07 · Posted 1 hour ago

      Optifine for 1.13.2 has not added Forge support yet.
    • Choonster
      [1.13.2] Open GUI in Block#onBlockActivated

      By Choonster · Posted 1 hour ago

      Instead of constructing the PacketBuffer, writing to it and then calling openGui, simply call openGui with a lambda function that writes to the supplied PacketBuffer. Forge constructs the PacketBuffer for you.
  • Topics

    • matieusz
      3
      forge with optifine 1.13.2

      By matieusz
      Started 1 hour ago

    • Nerdsjam
      4
      Mods are not working...

      By Nerdsjam
      Started Yesterday at 06:14 AM

    • DavidM
      6
      [1.13.2] Open GUI in Block#onBlockActivated

      By DavidM
      Started 2 hours ago

    • RedBullSlurpie
      3
      {1.13.2} Crops aren't dropping seeds, just the food ?

      By RedBullSlurpie
      Started 12 hours ago

    • d0048
      2
      (1.12.2)Problems trying to load .obj model with a 256x1 palette image as texture

      By d0048
      Started 5 hours ago

  • Who's Online (See full list)

    • WaningMatrix
    • DavidM
    • V0idWa1k3r
    • T-Dark
    • diesieben07
    • xerca
    • AzzaDarko
    • loordgek
    • nickolasdeluca
    • heyitsmenobodyy
    • sunsigne
    • trexxet
    • Choonster
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.11] Get blocks in a certain radius
  • Theme
  • Contact Us

Copyright © 2017 ForgeDevelopment LLC Powered by Invision Community