Posted January 7, 201510 yr Hey guys, probably a java question: When I for example call world.getBlockState(pos).getBlock() and there is a sand block, I want to have "Blocks.sand" as a String. The closest i got to is world.getBlockState(pos).getBlock().getClass().getTypeName() but well thats the BlockSand class.. So, basically I got the class X with the variable y in it, how can i get the String "X.y"?
January 7, 201510 yr Author Well, I'm writing a tool for structure generation, (I know there are a few out there), so basically u hit 2 blocks with a new item and it should give you the java code for all the blocks in between there like: world.setBlockState(pos, Blocks.sand.getStateFromMeta(..)); So what would you suggest to do? Can I get the block back from the id?
January 7, 201510 yr Author Uhm, lil off-topic, did metadata actually got replaces by the BlockState in 1.8? if not, how do I get the metadata of a block? (sry didnt found something useful with google)
January 7, 201510 yr Author But how do I get the metadata of a block? world.getBlockMetadata() does not exist anymore
January 7, 201510 yr Author I found Block.getStateById & Block.getStateId, that's going to cause problems with other mods, hu?
January 7, 201510 yr Hi This link might help to understand BlockStates and metadata and IDs and such. http://greyminecraftcoder.blogspot.co.at/2014/12/blocks-18.html Bottom line is - you need to think in terms of IBlockStates, not BlockID and metadata. The only part of your code that needs to know about the metadata numbers is the Block itself, which provides translation between metadata and BlockState for vanilla saving & loading to disk only. Everything else uses IBlockStates including other parts of your code that interact with your Block. -TGG
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.