Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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"?

  • 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?

  • 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)

  • Author

But how do I get the metadata of a block? world.getBlockMetadata() does not exist anymore :D

  • Author

I found Block.getStateById & Block.getStateId, that's going to cause problems with other mods, hu?

 

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.

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.