public static ItemStack RemovePart(IItemStack parent, string slot) { IModularItem item = parent.Item as IModularItem; if (item != null) { ITreeAttribute ToolSlots = parent.Attributes.GetOrAddTreeAttribute("toolparts"); ItemStack partstack = ToolSlots.GetItemstack(slot); ToolSlots.RemoveAttribute(slot); if (partstack != null) { item.RecalculateAttributes(parent); } return(partstack); } return(null); }