Jump to content

Recommended Posts

Posted

Simple question, how do you create a blockstate based on a registry name. 

 

What I essentially want to do is to be able to pass regName as a parameter, and have said block be created above the current block.

BlockPos pos = getPos();
String regName = "minecraft:stone";
world.setBlockState(new BlockPos(pos.getX(), (pos.getY() + 1), pos.getZ()), regName);

However, I understand that the second parameter is an instance of IBlockState, but I'm a little lost as to how I can create this using the registry name of a block, which I can then pass in as the variable.

 

Thanks,
Jordan

Why bother?

Posted (edited)

To get blockstate use Block#getDefaultState()

Block is the block you want to place, you can get it from block list like Blocks class

To get block by registry name, try going through ForgeRegistry

Edited by Toma™
  • Like 2

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.