Java Code Examples for net.minecraft.item.ItemStack#clearCustomName()

The following examples show how to use net.minecraft.item.ItemStack#clearCustomName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnvilUpdateEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void updateItemName(AnvilUpdateEvent event, ItemStack outputStack)
{
    String name = event.getName();

    if (StringUtils.isBlank(name) == false)
    {
        outputStack.setStackDisplayName(name);
        event.setCost(event.getCost() + 1);
    }
    else if (outputStack.hasDisplayName())
    {
        // Remove the custom name
        outputStack.clearCustomName();
        event.setCost(event.getCost() + 1);
    }
}
 
Example 2
Source File: TileEntityToolWorkstation.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void renameItem(String name)
{
    ItemStack stack = this.itemHandlerRenameSlot.getStackInSlot(0);

    if (stack.isEmpty() == false)
    {
        if (StringUtils.isBlank(name))
        {
            stack.clearCustomName();
        }
        else
        {
            stack.setStackDisplayName(name);
        }

        this.itemHandlerRenameSlot.setStackInSlot(0, stack);
    }
}
 
Example 3
Source File: TileEntityPortalPanel.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void setTargetName(String name)
{
    int id = this.getActiveTargetId();

    if (id >= 0 && id < 8)
    {
        ItemStack stack = this.itemHandlerBase.getStackInSlot(id);

        if (stack.isEmpty() == false)
        {
            if (StringUtils.isBlank(name))
            {
                stack.clearCustomName();
            }
            else
            {
                stack.setStackDisplayName(name);
            }

            this.itemHandlerBase.setStackInSlot(id, stack);
        }
    }
}
 
Example 4
Source File: ItemTicket.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand){
    if(!worldIn.isRemote) {
        ItemStack stack = playerIn.getHeldItem(hand);
        if(playerIn.isSneaking()) {
            setDestinations(stack, Collections.emptyList());
            stack.clearCustomName();
            playerIn.sendMessage(new TextComponentTranslation("signals.message.cleared_ticket"));
        } else {
            playerIn.openGui(Signals.instance, CommonProxy.EnumGuiId.TICKET_DESTINATION.ordinal(), worldIn, 0, 0, 0);
        }

    }
    return super.onItemRightClick(worldIn, playerIn, hand);
}
 
Example 5
Source File: ItemCoordinateCache.java    From ModdingTutorials with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn)
   {
	if(playerIn.isSneaking())
	{
		if(stack.getTagCompound() != null)
		{
			stack.getTagCompound().removeTag("coords");
			stack.clearCustomName();
		}
	}
       return stack;
   }
 
Example 6
Source File: ItemCoordinateCache.java    From ModdingTutorials with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn)
   {
	if(playerIn.isSneaking())
	{
		if(stack.getTagCompound() != null)
		{
			stack.getTagCompound().removeTag("coords");
			stack.clearCustomName();
		}
	}
       return stack;
   }