Jump to content

[1.10.2] [SOLVED] How to test block is air or fire etc.


DasKaktus

Recommended Posts

How can i test if a block is Material.Air or Blocks.FIRE etc.. ?

 

I found this function in Minecraft block:

 

/**
     * Get a material of block
     */
    @Deprecated
    public Material getMaterial(IBlockState state)
    {
        return this.blockMaterial;
    }

 

Which as you see is deprecated. (and why do you need to pass along IBlockState?!)

 

So is there any similar function that is'nt deprecated?

Not all things in the world are red, there are round objects too!

Link to comment
Share on other sites

Mojang uses @Deprecated wrongly, they use it to mean nobody should use it unless they are Mojang or are overriding the method. The IBlockState parameter is necessary so blocks can change their material based on their state. Use IBlockState#getMaterial to get the material of a given state.

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

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

Developer of many mods

Link to comment
Share on other sites

Ok, thanks.

 

I can do this?

 

Material m = blockIn.getBlockState().getBaseState().getMaterial();
        	if(m == Material.AIR){ return true; }

 

But how do I check if blockIn (which is Block) is Blocks.FIRE ?

 

blockIn.getBlockState().getBlock()

?

Not all things in the world are red, there are round objects too!

Link to comment
Share on other sites

blockIn.getBlockState().getBlock()

Wait for it

 == 

Drum roll please!

Blocks.FIRE

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.

Link to comment
Share on other sites

blockIn.getBlockState().getBlock()

Ahem... this is the same as just
blockIn

.

Actually, no, that does not even compile.

 

You are correct.  I just blindly copied the half he already had in order to beat him with the stupid stick of "how to check if something is equal."

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.

Link to comment
Share on other sites

Mojang uses @Deprecated wrongly, they use it to mean nobody should use it unless they are Mojang or are overriding the method. The IBlockState parameter is necessary so blocks can change their material based on their state. Use IBlockState#getMaterial to get the material of a given state.

Umm... No Mojang is using @Deprecated JUST FINE.

You SHOULD NOT be calling this function.

Overriding @Deprecated methods is fine because it is a in-work process so things may not always be the final form.

However in this case ITS FREAKING OBVIOUS you should NEVER CALL this method directly.

IBlockState, The replacement for directly calling Block methods HAS THIS FUNCTION.

So, world.getBlockState(pos).getMaterial() DONE!

Seriously this isnt complicated, please stop spreading stupidity on my forums about things you don't understand.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

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.