Jump to content

Recommended Posts

Posted

With the Minecraft setblock command (in game): we can do this: 

/setblock -4 4 -132 minecraft:player_head[rotation=0]{SkullOwner:{Name:"playerName"}}

. That will place a player head of the specified player with the specified rotation.

 

How can I accomplish this in my mod.

 

I know that I can set a block to be a player head using setBlockState and having 

setBlockState( BlockPos, Blocks.PLAYER_HEAD.getBlock().getDefaultState() 

I also know that we can add a rotation to it by adding

.with(BlockStateProperties.ROTATION_0_15, 3)

 

But I am lost on how I would go about setting the nbt data for skull owner SkullOwner. If anyone could point me in the right direction that would be great.

 

Thanks,

Posted

The only two ways I can think of is either use

SkullTileEntity.setPlayerProfile()

or call

onBlockPlacedBy()

and pass in a stack with the nbt data you want.

Both of them basically do the same thing.

  • Like 1

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.