Insane96MCP Posted January 16, 2018 Share Posted January 16, 2018 This thing works but is ugly af: world.getBlockState(bedPos).getBlock().getRegistryName().toString().equals(Blocks.BED.getRegistryName().toString()) Quote Link to comment Share on other sites More sharing options...
larsgerrits Posted January 16, 2018 Share Posted January 16, 2018 (edited) You can use == to check Block instances, as they are singletons: world.getBlockState(pos).getBlock() == Blocks.BED. This works for all IForgeRegistrys (look at the ForgeRegistries class). Edited January 16, 2018 by larsgerrits 1 Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/ Link to comment Share on other sites More sharing options...
Insane96MCP Posted January 16, 2018 Author Share Posted January 16, 2018 29 minutes ago, larsgerrits said: You can use == to check Block instances, as they are singletons: world.getBlockState(pos).getBlock() == Blocks.BED. This works for all IForgeRegistrys (look at the ForgeRegistries class). Ok, I need to sleep now. I didn't think about comparing Blocks ... Quote Link to comment Share on other sites More sharing options...
jeffryfisher Posted January 16, 2018 Share Posted January 16, 2018 You may also use instanceof in comparisons where any subclass will do. If some mod makes a custom bed by extending the vanilla class, then an '==' would only match the vanilla bed and not recognize the mod one. What you choose depends on what you're trying to accomplish. Quote The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting. 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.