DasKaktus Posted August 7, 2016 Share Posted August 7, 2016 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? Quote Not all things in the world are red, there are round objects too! Link to comment Share on other sites More sharing options...
shadowfacts Posted August 7, 2016 Share Posted August 7, 2016 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. Quote 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 More sharing options...
DasKaktus Posted August 7, 2016 Author Share Posted August 7, 2016 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() ? Quote Not all things in the world are red, there are round objects too! Link to comment Share on other sites More sharing options...
Draco18s Posted August 7, 2016 Share Posted August 7, 2016 blockIn.getBlockState().getBlock() Wait for it == Drum roll please! Blocks.FIRE Quote 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 More sharing options...
Draco18s Posted August 7, 2016 Share Posted August 7, 2016 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." Quote 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 More sharing options...
DasKaktus Posted August 7, 2016 Author Share Posted August 7, 2016 Actually it compiled, both version worked But i stuck with blockIn == Blocks.Fire check. It was probably too late in the night to test the simpliest thing. Quote Not all things in the world are red, there are round objects too! Link to comment Share on other sites More sharing options...
LexManos Posted August 8, 2016 Share Posted August 8, 2016 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. Quote 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 More sharing options...
Recommended Posts
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.