Jump to content

Recommended Posts

Posted

I want to check if there there isn't a block in specific coodinates

 

Block block = world.getBlock(x, y, z);

 

so have i to say

 

if (block == null).... or if(block == Blocks.air)....  ??

 

or is it the same?

Actually i don't know what to write in this signature soooo.... anyway

Posted

Do instead

 

if (block == null || block.material == Material.air)

 

The first one checks to make sure the block isn't null (to avoid null reference errors) the second check checks to see if the block that is there is of the material air, because with mods there can be blocks that should be treated like air, but are not air.

 

(Gasses, technical lighting blocks, etc.)

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

The whole point of getBlock is to return a block no matter what.

It can't be null, at worst it would already crash while trying to get the block.

It defaults to Blocks.air in most cases.

By the way, you have World#isAirBlock.

Posted

I want to check if there there isn't a block in specific coodinates

 

Block block = world.getBlock(x, y, z);

 

so have i to say

 

if (block == null).... or if(block == Blocks.air)....  ??

 

or is it the same?

 

if(block .isAir(world, x, y, z))

 

would check for air just remember if you pull the code form a specific block when your checking around that block to increase the coordinates as needed

 

if(block .isAir(world, x, y + 1, z)) would check if there's an air block above the Block

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.