Jump to content

[1.12.2] Custom inventory name when using capabilities [Solved]


Dipo

Recommended Posts

Minecraft version: 1.12.2

Forge version: 1.12.2-14.23.5.2824

Java version: Version 8 Update 211 (build 1.8.0_211-b12)

 

When there was IInventory and ISidedInventory, inventory names were simple to use (getInventoryName, hasCustomInventoryName), but now there are capabilities and they don't have anything like inventory name.

How Am I supposed to change name of inventory of TileEntity in GuiContainer ? I want to display in GUI the name of block renamed in anvil. I know how to save it in NBT, I just want to know if there is some way to retrieve it.

Edited by Dipo
Link to comment
Share on other sites

I know how to tell client about change, but i mean how to retrieve the name of it on the server side. I want to do exactly what is in chest. When u rename chest block in anvil and place it, then open it, the name of the item chest is shown above the inventory. But I don't know how to "move" the name of the ItemStack to the tileentity.

 

But I've figured it out by overriding onBlockPlacedBy in my block class:

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
	TileEntity atm = world.getTileEntity(pos);

	if (atm instanceof TileEntityATM)
		((TileEntityATM) atm).setCustomName(stack.getDisplayName());
}

 

But thanks anyway

Edited by Dipo
Link to comment
Share on other sites

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.